使用 docker 镜像时,zapproxy 全扫描未运行提供的脚本

如何解决使用 docker 镜像时,zapproxy 全扫描未运行提供的脚本

我想在 zap 全面扫描期间针对每个请求启动一个 httpsender 脚本。 所以我做到了

docker run -v $(pwd):/zap/wrk/:rw -h -t owasp/zap2docker-weekly zap-full-scan.py -t https://www.test.com -z "-config script.scripts.name=http_parameters -config script.scripts.engine=ECMAScript -config script.scripts.type=httpsender -config script.scripts.enabled=true -config script.scripts.file=/zap/wrk/http_parameters.js"

我的 http_paramerters.js 是

var URL_TYPE    = org.parosproxy.paros.network.HtmlParameter.Type.url;
var HtmlParameter = Java.type('org.parosproxy.paros.network.HtmlParameter');

var paramName = 'test';
var paramValue = '123';

function sendingRequest(msg,initiator,helper) {
  print(' test')

  if (!msg.getRequestHeader().getURI().toString().contains(paramName + '=' + paramValue)) {
    //You might want to add a check here for the proper domain or path as well..
    var urlParams = msg.getUrlParams();
    var newParam = new HtmlParameter(URL_TYPE,paramName,paramValue);
    urlParams.add(newParam); // you Could print this if you need to see what's up
    msg.setGetParams(urlParams);
  }
  return msg;
}

function responseReceived(msg,helper) {
  //nothing to do here
}
 

预期行为

我的脚本必须执行。

来自 zap.log 文件错误

日志中没有错误,如下所示

20```
21-01-11 17:05:22,349 Could not find custom hooks file at /home/zap/.zap_hooks.py
2021-01-11 17:05:22,349 Trigger hook: cli_opts,args: 1
2021-01-11 17:05:22,350 Using port: 48793
2021-01-11 17:05:22,351 Trigger hook: start_zap,args: 2
2021-01-11 17:05:22,352 Starting ZAP
2021-01-11 17:05:22,352 Params: ['zap-x.sh','-daemon','-port','48793','-host','0.0.0.0','-config','database.recoverylog=false','api.disablekey=true','api.addrs.addr.name=.*','api.addrs.addr.regex=true','spider.maxDuration=0','-addonupdate','-addoninstall','pscanrulesBeta','ascanrulesBeta','pscanrulesAlpha','ascanrulesAlpha','script.scripts.name=http_parameters.js','script.scripts.engine=ECMAScript','script.scripts.type=httpsender','script.scripts.enabled=true','script.scripts.file=/zap/wrk/http_parameters.js']
2021-01-11 17:05:22,363 Starting new HTTP connection (1): localhost:48793
Jan 11,2021 5:05:27 PM java.util.prefs.FileSystemPreferences$1 run
INFO: Created user preferences directory.
2021-01-11 17:05:28,390 Starting new HTTP connection (1): localhost:48793
2021-01-11 17:05:37,460 http://localhost:48793 "GET http://zap/JSON/core/view/version/ HTTP/1.1" 200 26
2021-01-11 17:05:37,462 ZAP Version D-2021-01-04
2021-01-11 17:05:37,462 Took 15 seconds
2021-01-11 17:05:37,462 Trigger hook: zap_started,args: 2
2021-01-11 17:05:37,463 Tune
2021-01-11 17:05:37,463 disable all tags
2021-01-11 17:05:37,466 Starting new HTTP connection (1): localhost:48793
2021-01-11 17:05:37,471 http://localhost:48793 "GET http://zap/JSON/pscan/action/disableAllTags/?apikey= HTTP/1.1" 200 15
2021-01-11 17:05:37,471 Set max pscan alerts
2021-01-11 17:05:37,472 Starting new HTTP connection (1): localhost:48793
2021-01-11 17:05:37,476 http://localhost:48793 "GET http://zap/JSON/pscan/action/setMaxAlertsPerRule/?maxAlerts=10&apikey= HTTP/1.1" 200 15
2021-01-11 17:05:37,477 Trigger hook: zap_tuned,args: 1
2021-01-11 17:05:37,478 Trigger hook: zap_access_target,481 Starting new HTTPS connection (1): test.com:443
2021-01-11 17:05:40,671 Trigger hook: zap_spider,args: 2
2021-01-11 17:05:40,674 Starting new HTTP connection (1): localhost:48793
2021-01-11 17:05:40,681 http://localhost:48793 "GET http://zap/JSON/spider/action/scan/?apikey=&url=https%3A%2F%2Ftest.com HTTP/1.1" 200 12
2021-01-11 17:05:45,685 Starting new HTTP connection (1): localhost:48793
2021-01-11 17:05:45,688 http://localhost:48793 "GET http://zap/JSON/spider/view/status/?scanId=0 HTTP/1.1" 200 15
2021-01-11 17:05:45,690 Starting new HTTP connection (1): localhost:48793
2021-01-11 17:05:45,691 http://localhost:48793 "GET http://zap/JSON/spider/view/status/?scanId=0 HTTP/1.1" 200 15
2021-01-11 17:05:45,692 Spider progress %: 73

解决方法

我遇到了同样的错误,在我的情况下,使用 zap-baseline.py 更改 zap-full-scan.py 足以解决问题

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。

相关推荐


Selenium Web驱动程序和Java。元素在(x,y)点处不可单击。其他元素将获得点击?
Python-如何使用点“。” 访问字典成员?
Java 字符串是不可变的。到底是什么意思?
Java中的“ final”关键字如何工作?(我仍然可以修改对象。)
“loop:”在Java代码中。这是什么,为什么要编译?
java.lang.ClassNotFoundException:sun.jdbc.odbc.JdbcOdbcDriver发生异常。为什么?
这是用Java进行XML解析的最佳库。
Java的PriorityQueue的内置迭代器不会以任何特定顺序遍历数据结构。为什么?
如何在Java中聆听按键时移动图像。
Java“Program to an interface”。这是什么意思?
Java在半透明框架/面板/组件上重新绘画。
Java“ Class.forName()”和“ Class.forName()。newInstance()”之间有什么区别?
在此环境中不提供编译器。也许是在JRE而不是JDK上运行?
Java用相同的方法在一个类中实现两个接口。哪种接口方法被覆盖?
Java 什么是Runtime.getRuntime()。totalMemory()和freeMemory()?
java.library.path中的java.lang.UnsatisfiedLinkError否*****。dll
JavaFX“位置是必需的。” 即使在同一包装中
Java 导入两个具有相同名称的类。怎么处理?
Java 是否应该在HttpServletResponse.getOutputStream()/。getWriter()上调用.close()?
Java RegEx元字符(。)和普通点?