基于 Rust 的 XSS 扫描器,具备上下文感知的 payload 选择、WAF 检测与绕过、爬取、盲 XSS 回调以及静态 DOM 汇聚点分析功能。
用 Rust 编写的高级 XSS 检测工具,将上下文感知的 payload 智能与注入广度相结合。
该工具的灵感来自 XSStrike 和 XSSER。payload 收集自不同来源:
感谢各位,你们太棒了 ❤️
警告:仅可用于你拥有或已获得明确书面授权进行测试的系统。
<title>、<textarea> 等),并针对该上下文选择最合适的 payload,而不是盲目地全部发送Referer、User-Agent、X-Forwarded-For、X-Real-IP 及其他 header,以及 cookie 值innerHTML、eval、document.write、location.href、jQuery .html() 及其他危险汇聚点,并进行源检测git clone https://github.com/fabian-affolter/xssearch
cd xssearch
nix-shell --run "cargo build --release"
# binary: target/release/xssearch
带 LTO 和剥离符号的 release 构建:
nix-shell --argstr release true --run "$BUILD"
需要 Rust 1.75+。
cargo build --release
Nix 或 NixOS 用户可使用现成的包。请注意,最新版本可能仅存在于 unstable 频道中。
nix-env -iA nixos.xssearch
xssearch [OPTIONS] <--url <URL> | --file <URLS_FILE>>
| 标志 | 描述 |
|---|---|
-u, --url <URL> | 目标 URL。使用 FUZZ 标记自定义注入点 |
-f, --file <FILE> | 每行一个 URL 的文件 |
-d, --data <DATA> | POST 正文。使用 FUZZ 标记注入点 |
-H, --header <H> | 额外请求 header,可重复 |
--cookie <COOKIE> | Cookie 字符串 |
--proxy <URL> | HTTP/HTTPS 代理 |
--timeout <N> | 请求超时时间(秒,默认:10) |
--user-agent <UA> | 自定义 User-Agent |
--follow-redirects | 跟随 HTTP 重定向 |
--threads <N> | 并发请求数(默认:2) |
--delay <MS> | 请求之间的延迟(毫秒) |
--crawl | 爬取目标以获取链接和表单 |
--crawl-depth <N> | 爬取深度(默认:3) |
--headers-inject | 测试常见 HTTP header 作为注入点 |
--cookie-inject | 测试 cookie 值作为注入点 |
--blind <URL> | 盲注 XSS 回调 URL |
--dom | 静态 DOM XSS 汇聚点分析 |
--fuzz | 无论反射上下文如何,发送所有 payload |
--payload-set <SET> | all | html | js | attr | poly | dom | mxss | waf(默认:all) |
--payloads-file <FILE> | 自定义 payload 文件,每行一个 |
--encode <LIST> | 逗号分隔的编码:url,html,unicode,double,base64 |
--prefix <STR> | 为每个 payload 添加前缀字符串 |
--suffix <STR> | 为每个 payload 添加后缀字符串 |
--waf-detect | 扫描前对 WAF 进行指纹识别 |
--waf-bypass | 对 payload 应用 WAF 绕过变换 |
--output-json <FILE> | 将发现结果写入 JSON 文件 |
--output-md <FILE> | 将发现结果写入 Markdown 文件 |
-v, --verbose | 详细输出(显示上下文、所有探测) |
-V, --version | 打印版本并退出 |
xssearch -u "https://example.com/search?q=test"
xssearch -u "https://example.com/login" -d "user=admin&pass=FUZZ"
xssearch -u "https://example.com/" --crawl --waf-detect --headers-inject -v
xssearch -u "https://example.com/?q=FUZZ" --waf-detect --waf-bypass --encode url,html
xssearch -u "https://example.com/contact" -d "msg=FUZZ" \
--blind "https://abc123.oast.fun/xssearch"
xssearch -u "https://example.com/app" --dom --no-banner
xssearch -u "https://example.com/?q=test" --output-json results.json
xssearch -u "https://example.com/?q=test" --output-md report.md
xssearch -f targets.txt --crawl --waf-detect --output-json results.json --output-md report.md
xssearch -u "https://example.com/?q=test" --proxy http://127.0.0.1:8080 -v
验证该工具最快的方法是在本地启动一个故意存在漏洞的 Python 服务器:
python3 - <<'EOF'
import http.server, urllib.parse
class H(http.server.BaseHTTPRequestHandler):
def log_message(self, *a): pass
def do_GET(self):
p = urllib.parse.urlparse(self.path)
q = urllib.parse.parse_qs(p.query)
val = q.get('q', [''])[0]
body = f'<html><body><p>Search: {val}</p></body></html>'.encode()
self.send_response(200)
self.send_header('Content-Type', 'text/html')
self.end_headers()
self.wfile.write(body)
http.server.HTTPServer(('127.0.0.1', 9999), H).serve_forever()
EOF
然后扫描它:
xssearch -u "http://127.0.0.1:9999/?q=test" -v
预期输出:[Vuln] XSS in 'q',并带有一个 HTML 上下文 payload。
这些镜像专为安全工具测试而构建,不包含任何真实用户数据。
docker run -d -p 8080:80 vulnerables/web-dvwa
# Set security level to Low in the UI first
xssearch -u "http://localhost:8080/vulnerabilities/xss_r/?name=test" \
--cookie "PHPSESSID=<your-session>; security=low"
docker run -d -p 8081:8080 webgoat/goat-and-wolf
xssearch -u "http://localhost:8081/WebGoat/" --crawl --crawl-depth 2 -v
docker run -d -p 3000:3000 bkimminich/juice-shop
xssearch -u "http://localhost:3000/" --crawl --dom -v
docker run -d -p 8082:80 raesene/bwapp
# Activate bWAPP at http://localhost:8082/install.php first
xssearch -u "http://localhost:8082/xss_get.php?firstname=test&lastname=test" \
--cookie "PHPSESSID=<your-session>; security_level=0"
这些站点专为安全工具测试而提供。无需身份验证或设置。
| 目标 | URL | XSS 入口点 |
|---|---|---|
| Acunetix 测试站点 | http://testphp.vulnweb.com/ | search.php?test=、艺术家评论、搜索表单 |
| IBM Altoro Mutual | http://demo.testfire.net/ | 搜索参数、反馈表单 |
| HP WebInspect 演示 | http://zero.webappsecurity.com/ | 登录表单、搜索、账户字段 |
| Google Gruyere | https://google-gruyere.appspot.com/ | 代码片段、个人资料字段(需要实例 URL) |
搜索参数(反射型 XSS):
xssearch -u "http://testphp.vulnweb.com/search.php?test=query" \
--waf-detect -v
带 header 注入的完整爬取:
xssearch -u "http://testphp.vulnweb.com/" \
--crawl --crawl-depth 3 \
--headers-inject \
--dom \
--output-json testphp-findings.json
搜索表单:
xssearch -u "http://demo.testfire.net/search.aspx?txtSearch=test" \
--waf-detect --fuzz -v
从根路径爬取:
xssearch -u "http://zero.webappsecurity.com/" \
--crawl --crawl-depth 2 \
--waf-detect \
--output-json zero-findings.json
先启动一个个人实例,然后扫描它:
# The instance URL is displayed after clicking "Start" on the Gruyere homepage
xssearch -u "https://google-gruyere.appspot.com/<instance-id>/feed.gtl" \
--dom --crawl -v
公开目标可能会间歇性变慢或离线。如果请求超时,请使用 --timeout 30。
终端输出使用颜色编码的标签:
| 标签 | 含义 |
|---|---|
[Target] | 正在扫描的 URL |
[WAF] | WAF 检测结果 |
[Crawl] | 爬虫状态 |
[Param] | 正在测试的参数 |
[CTX] | 检测到的反射上下文 |
[Vuln] | 已确认的发现 |
[DOM] | 检测到的 DOM 汇聚点 |
[Blind] | 已注入的盲注 payload |
使用 --output-json 写入,每条发现一个对象:
{
"url": "https://example.com/search?q=%22+onmouseover%3Dalert%281%29+%22",
"param": "q",
"payload": "\" onmouseover=alert(1) \"",
"method": "GET",
"context": "Attribute",
"severity": "High",
"description": "attr breakout dquote onmouseover"
}
使用 --output-md 写入,报告包含三个部分:
汇总表 — 严重性计数一览:
| 严重性 | 数量 |
|---|---|
| 🔴 高 | 2 |
| 🟠 中 | 0 |
| 🟡 低 | 0 |
| 🔵 信息 | 0 |
| 总计 | 2 |
逐条发现部分 — 每条发现一个标题,包含详情表和放在围栏代码块中的 payload:
### 1. 🔴 [High] `q`