WAF检测率及误报测试工具Gotestwaf

1. 关于Gotestwaf

Gotestwaf,全称为Go Test WAF,是一种用于 API 和 OWASP 攻击模拟的工具,可以用于检测率测试(Negative Tests)和误报率(Positive Tests)测试支持广泛的 API 协议,包括 REST、GraphQL、gRPC、WebSockets、SOAP、XMLRPC 等。
用于评估 Web 应用程序安全解决方案,例如 API 安全代理、Web 应用程序防火墙、IPS、API 网关等。
项目地址:https://github.com/wallarm/gotestwaf

2.配置文件说明:

GoTestWAF 使用放置在 HTTP 请求不同部分的编码负载生成恶意请求:其正文、标头、URL 参数等。生成的请求被发送到 被测设备。
默认配置文件放在testcases文件夹里的YAML文件
在这里插入图片描述
yml文件示例:

payload:
  - "<body οnlοad=alert('test1')>"
  - "<b οnmοuseοver=alert('Wufff!')>click me!</b>"
encoder:
  - Base64Flat
  - URL
placeholder:
  - URLPath
  - URLParam
  - HTMLForm
  - HTMLMultipartForm
type: "XSS"
...

payload:攻击的恶意样本
encoder:攻击样本编码方式
支持编码
Base64
Base64Flat(不进行等号补位)
JSUnicode
URL
Plain (保持攻击样本原样)
XML Entity
gRPC
placeholder:请求位置
Header
RequestBody
JSONRequest
JSONBody
HTMLForm
HTMLMultipartForm
SOAPBody
XMLBody(只是Content-Type: text/xml,请求body不是xml格式,需要在payload里定义xml攻击样本,encode用Plain )
URLParam
URLPath

请求生成是一个三步过程,涉及将payload个数乘以encoder和placeholder数量。假设定义了 2 个payload、3 个encoder(Base64、JSUnicode 和 URL)和 1 个placeholder(URLParameter - HTTP GET 参数)。在这种情况下,GoTestWAF 将在测试用例中发送 2x3x1 = 6 个请求

3.运行:

系统要求:
GoTestWAF支持所有流行的操作系统(Linux、Windows、macOS),如果系统中安装了Go,则可以进行本地开发。
如果将工具作为Docker容器运行,请确保您已经安装并配置了Docker,并且GoTestWAF和评估的应用程序安全解决方案连接到同一个Docker网络。
为了成功启动GoTestWAF,请确保运行GoTestWAF的机器的IP地址在运行应用安全解决方案的机器上被列入白名单。
通过docker运行
我们可以直使用下列命令将项目库拉取到本地:

docker pull wallarm/gotestwaf

本地Docker构建

docker build . --force-rm -t gotestwaf
docker run -v ${PWD}/reports:/app/reports --network=“host” gotestwaf --url=<EVALUATED_SECURITY_SOLUTION_URL>

运行命令之后,你将会在reports文件夹下查看到waf-test-report-.pdf报告文件,可以替换${PWD}/reports为用于放置评估报告的另一个文件夹的路径

go环境运行
安装go环境
https://golang.google.cn/dl/ 下载对应系统包。
下载gowaftest项目

git clone https://github.com/wallarm/gotestwaf.git
cd gotestwaf
go run ./cmd --url=<EVALUATED_SECURITY_SOLUTION_URL> --verbose

4.配置选项

–addHeader string An HTTP header to add to requests
–blockConnReset If true, connection resets will be considered as block 有些防护设备通过rest报文重置攻击,通过这个命令
–blockRegex string Regex to detect a blocking page with the same HTTP response status code as a not blocked request 根据定义正则匹配返回内容判断是否拦截
–blockStatusCode int HTTP status code that WAF uses while blocking requests (default 403) 根据返回码判断是否拦截
–configPath string Path to the config file (default “config.yaml”)
–followCookies If true, use cookies sent by the server. May work only with --maxIdleConns=1
–idleConnTimeout int The maximum amount of time a keep-alive connection will live (default 2)
–ignoreUnresolved If true, unresolved test cases will be considered as bypassed (affect score and results)
–maxIdleConns int The maximum number of keep-alive connections (default 2)
–maxRedirects int The maximum number of handling redirects (default 50)
–nonBlockedAsPassed If true, count requests that weren’t blocked as passed. If false, requests that don’t satisfy to PassStatuscode/PassRegExp as blocked
–passRegex string Regex to a detect normal (not blocked) web page with the same HTTP status code as a blocked request
–passStatusCode int HTTP response status code that WAF uses while passing requests (default 200)
–proxy string Proxy URL to use
–randomDelay int Random delay in ms in addition to the delay between requests (default 400)
–renderToHTML Save report as HTML page instead of PDF
–reportPath string A directory to store reports (default “reports”)
–sendDelay int Delay in ms between requests (default 400)
–skipWAFBlockCheck If true, WAF detection tests will be skipped
–testCase string If set then only this test case will be run 指定测试的单个yaml文件
–testCasesPath string Path to a folder with test cases (default “testcases”) 指定测试的yaml文件夹
–testSet string If set then only this test set’s cases will be run
–tlsVerify If true, the received TLS certificate will be verified
–url string URL to check
–verbose If true, enable verbose logging显示详细的运行过程,有些错误信息可以带着这个开关查看
–version Show GoTestWAF version and exit
–wafName string Name of the WAF product (default “generic”)
–workers int The number of workers to scan (default 5)
–wsURL string WebSocket URL在这里插入代码片 to check

5.报告查看

在这里插入图片报告文件waf-evaluation-report-.pdf位于reports用户目录的文件夹中描述
报告文件waf-evaluation-report-.pdf位于reports用户目录的文件夹中
在这里插入图片描述

6.常见问题

1 main error: WAF was not detected. Please use the ‘–blockStatusCode’ or ‘–blockRegex’ flags. Use ‘–help’ for additional info.
gotestwaf测试之前会发一个 及包括sql注入又包含xss攻击的恶意样本 ,如果这个没有拦截或者返回的错误码不是默认的403会出现这个报错。可以根据被测设备定义状态码,如果是通过rest断链接的加上
也可以通过–skipWAFBlockCheck跳过这个检查。

本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
THE END
分享
二维码
< <上一篇

)">
下一篇>>