REcollapseは、Webアプリケーションのバリデーションをバイパスし、正規化を発見するためのブラックボックス正規表現ファジングのヘルパーツールです。
また、WAFや脆弱な脆弱性緩和策をバイパスするのにも役立ちます。詳細については、REcollapseブログ記事をご覧ください。
このツールの目的は、テスト用のペイロードを生成することです。実際のファジングは、Burp (intruder)、Caido (automate)、ffuf などの他のツールを使用して行う必要があります。
必要条件: Python 3
pip3 install recollapse または python3 setup.py install または pip3 install .
Docker
docker build -t recollapse . または docker pull 0xacb/recollapse
$ recollapse -h
usage: recollapse [-h] [-m MODES] [-e {1,2,3,4}] [-r RANGE] [-s SIZE] [-f FILE] [-an] [-mn MAXNORM] [-mt MAXTRUNC] [-nt] [-tt] [-ct]
[--html] [--version]
[input]
REcollapse is a helper tool for black-box regex fuzzing to bypass validations and discover normalizations in web applications
positional arguments:
input original input
options:
-h, --help show this help message and exit
-m, --modes, -p, --positions MODES
variation modes. Example: 1,2,3,4,5,6,7 (default). 1: starting, 2: separator, 3: normalization, 4:
termination, 5: regex metacharacters, 6: case folding/upper/lower, 7: byte truncation
-e, --encoding {1,2,3,4}
1: URL-encoded format (default), 2: Unicode format, 3: Raw format, 4: Double URL-encoded format
-r, --range RANGE range of bytes for fuzzing. Example: 0,0xff (default)
-s, --size SIZE number of fuzzing bytes (default: 1)
-f, --file FILE read input from file
-an, --alphanum include alphanumeric bytes in fuzzing range
-mn, --maxnorm MAXNORM
maximum number of normalizations (default: 3)
-mt, --maxtrunc MAXTRUNC
maximum number of truncations (default: 3)
-nt, --normtable print normalization table
-tt, --trunctable print truncation table
-ct, --casetable print case table
--html output tables in HTML format
--version show recollapse version
入力として this_is.an_example を考えます。
モード
$this_is.an_examplethis$_$is$.$an$_$examplethis_is.an_example$.^$*+-?()[]{}\|エンコーディング
application/x-www-form-urlencoded またはクエリ/ボディパラメータで使用するURLエンコード形式: %22this_is.an_exampleapplication/json で使用するUnicode形式: \u0022this_is.an_examplemultipart/form-data で使用するRaw形式: "this_is.an_example範囲
ファジングのバイト範囲を指定: -r 1-127。-anオプションが指定されていない限り、英数字は除外されます。
サイズ
モード1、2、4のファジングサイズを指定します。デフォルトでは、1バイトのすべての可能な値をファジングします。サイズを増やすと、より多くのリソースを消費し、より多くの入力を生成しますが、新しいバイパスを見つける可能性があります。
ファイル
入力は位置引数、stdin、または-fオプションを介したファイルとして提供できます。
英数字
デフォルトでは、英数字は出力生成から除外されます。これは通常、レスポンスの観点からは興味深くありません。-anオプションで許可できます。
正規化の最大数
すべての正規化ライブラリが同じ動作をするわけではありません。デフォルトでは、各入力インデックスに対して3つの正規化の可能性が生成されますが、通常はこれで十分です。さらに進めるには-mnオプションを使用します。
テーブル
-ntオプションで正規化テーブルを表示し、-ctオプションで大文字小文字テーブルを表示し、-ttオプションで切り詰めテーブルを表示します。また、--htmlオプションを使用してテーブルをHTML形式で出力することもできます。
$ recollapse -nt --html > normalization_table.html
$ recollapse -tt --html > truncation_table.html
$ recollapse -ct --html > case_table.html
Recollapseをコマンドラインツールとして使用:
$ recollapse -e 1 -m 1,2,4 -r 10-11 https://legit.example.com
%0ahttps://legit.example.com
%0bhttps://legit.example.com
https%0a://legit.example.com
https%0b://legit.example.com
...
$ echo "[email protected]" | recollapse
%[email protected]
%[email protected]
...
$ echo "<svg/onload=alert(1)>" | recollapse | ffuf -w - -u "https://example.com/?param=FUZZ" -mc 200,403,500
Recollapseをライブラリとして使用:
from recollapse import Recollapse
recollapse = Recollapse(modes=Recollapse.DEFAULT_MODES,
encoding=Recollapse.ENCODING_RAW)
variants = recollapse.generate("<script")
for variant in variants:
print(variant)
この手法は元々BSidesLisbon 2022で発表されました。
ブログ記事: https://0xacb.com/2022/11/21/recollapse/
スライド:
動画:
テーブル:
謝辞
そして
このプロジェクトは教育および倫理的なテスト目的のみで作成されています。事前の相互同意なしにこのツールを使用してターゲットを攻撃することは違法です。開発者は一切の責任を負わず、このツールによって引き起こされた誤用や損害について責任を負いません。