如何在 docker ZAP OWASP zap-full-scan 中的每个 http 请求中添加参数

How to add a parameter in every http request in docker ZAP OWASP zap-full-scan

我正在使用此命令对 https://www.example.com 进行全面扫描。

docker run -v $(pwd):/zap/wrk/:rw -t owasp/zap2docker-stable zap-full-scan.py \
    -t https://www.example.com -g gen.conf -r testreport.html

我需要为每个 http 请求添加一个 http 参数。

像这样添加 http 参数 www.example.com/toto?booking=true&satckoverflow=1

我知道在 ZAP GUI 的 http 发件人部分中有一个 add-extra-headers.js 脚本。但是我不知道怎么用docker 运行 zap-full-scan.

我无法执行 docker zap api 扫描。

更新: 使用了下面提出的第二个解决方案,这是我的脚本

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

var paramName = 'param1';
var paramValue = 'value1';

function sendingRequest(msg, initiator, helper) {
  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, initiator, helper) {
  //Nothing to do here
} 

Dp 您需要添加 HTTP header 或其他一些参数吗? header 可以通过环境变量轻松添加:https://www.zaproxy.org/docs/desktop/start/features/authentication/#envvars

如果您需要添加另一种参数,则可以通过脚本完成,但您需要告诉 ZAP 从何处加载它们。

首先在 ZAP GUI 中实施和测试您的 scipt - 它更容易看到那里发生了什么。一旦正常工作,您需要将脚本放在您根据 https://www.zaproxy.org/docs/docker/full-scan/ Finally you have to configure ZAP to tell it about the script using the local ath of the script in the Docker container. Thats detailed in this FAQ: https://www.zaproxy.org/faq/how-do-you-add-a-script-to-zap-from-the-command-line/

使用标准 Docker -v 参数挂载的目录中