REcollapse 是一个辅助工具,用于黑盒正则表达式模糊测试,以绕过验证并发现 Web 应用程序中的标准化行为。
它也可以帮助绕过 WAF 和弱漏洞缓解措施。更多信息,请查看 REcollapse 博客文章。
此工具的目标是生成用于测试的 payload。实际的模糊测试应使用其他工具进行,如 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 或查询/正文参数:%22this_is.an_exampleapplication/json:\u0022this_is.an_examplemultipart/form-data:"this_is.an_example范围
指定用于模糊测试的字节范围:-r 1-127。除非提供了 -an 选项,否则这将排除字母数字字符。
大小
为模式 1、2 和 4 指定模糊测试的大小。默认方法是对一个字节的所有可能值进行模糊测试。增加大小将消耗更多资源并生成更多输入,但可能导致发现新的绕过方法。
文件
输入可以作为位置参数、标准输入或通过 -f 选项从文件提供。
字母数字
默认情况下,字母数字字符将从输出中排除,这在响应方面通常不感兴趣。你可以使用 -an 选项允许它们。
最大标准化次数
并非所有标准化库都具有相同的行为。默认情况下,为每个输入索引生成三种标准化可能性,这通常足够。使用 -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/
幻灯片:
视频:
表:
致谢
以及
本项目仅供教育和道德测试目的。未经事先相互同意,使用此工具攻击目标是非法的。开发人员不承担任何责任,也不对因使用此工具造成的任何滥用或损害负责。