AFL++实战其九

练习9 - 7-Zip

版本:7-Zip 15.05

漏洞编号:CVE-2016-2334

CVE-2016-2334 是一种基于堆的缓冲区溢出,可以通过精心设计的 HFS+ 镜像触发。

基于堆的缓冲区溢出是一种发生在堆数据区域的缓冲区溢出类型,通常与显式动态内存管理(通过 malloc()和 free()函数进行分配/释放)有关。

因此,远程攻击者可以利用此问题在使用受影响库的应用程序上下文中执行任意代码。


准备环境

准备 C++ 开发包使用 Visual Studio 2022:

下载DynamoRIO 11.91.20552:

1
https://github.com/DynamoRIO/dynamorio/releases/download/cronbuild-11.91.20552/DynamoRIO-Windows-11.91.20552.zip

下载并构建 WinAFL:

1
2
3
git clone https://github.com/googleprojectzero/winafl.git
mkdir build32
cd build32

编译他们:

1
2
3
4
cmake -G "Visual Studio 17 2022" -A Win32 .. -DDynamoRIO_DIR="J:\fuzz\DynamoRIO-Windows-11.91.20552\cmake"
& "C:\Program Files\Microsoft Visual Studio\2022\Community\MSBuild\Current\Bin\MSBuild.exe" `
"J:\fuzz\winafl\build32_dr11\winafl.sln" `
/p:Configuration=Release /p:Platform=Win32

如果不出意外,他们应该在\build32\bin\Release下面。

下载 7-Zip

1
wget blob:https://github.com/93347326-bc90-43fb-aeb0-dfa1b8d4f683

自己安装?

种子语料库创建:

1
wget https://github.com/antonio-morales/Fuzzing101/blob/main/Exercise%209/Resources/example.img

模糊时间!

WinAFL 命令行和 AFL++ 有些不同。让我们简要介绍一下这些新选项:

  • -coverage_module:用于录制报道的模块。支持多个模块标志
  • -target_module :包含待模糊目标函数的模块
  • -target_offset :从模块起始处的模糊方法偏移量

正如练习8一样,我们也需要设置持久化来提升模糊速度。

0x02F3B3是作者给我们的测试持久化点,通过函数地址减去偏移获得,我们需要寻找自己的持久化点。

1
J:\fuzz\DynamoRIO-Windows-11.91.20552\bin32\drrun.exe -c J:\fuzz\winafl\build32_dr11\bin\Release\winafl.dll -debug -target_module 7z.exe -target_offset 0x02F3B3 -fuzz_iterations 10 -nargs 2 -- "J:\fuzz\7-Zip\7z.exe" l J:\fuzz\fuzz\seeds\example.img

经过这次输入你应该看到对应函数的输出被运行10次

1
J:\fuzz\winafl\build32_dr11\bin\Release\afl-fuzz.exe -i .\seeds -o .\out -t 2000 -D J:\fuzz\DynamoRIO-Windows-11.91.20552\bin32 -w J:\fuzz\winafl\build32_dr11\bin\Release\winafl.dll -- -coverage_module 7z.exe -coverage_module 7z.dll -target_module 7z.exe -target_offset 0x02F3B3 -nargs 2 -- "J:\fuzz\7-Zip\7z.exe" e -y '@@'

这是最终能跑起来的代码。

经过简单的逆向,最终我的指令是:

1
J:\fuzz\winafl\build32_dr11\bin\Release\afl-fuzz.exe -i .\seeds -o .\out -t 2000 -D J:\fuzz\DynamoRIO-Windows-11.91.20552\bin32 -w J:\fuzz\winafl\build32_dr11\bin\Release\winafl.dll -- -coverage_module 7z.exe -coverage_module 7z.dll -target_module 7z.exe -target_offset 0x02C675 -nargs 2 -- "J:\fuzz\7-Zip\7z.exe" e -y '@@'

AFL++实战其九
https://zlsf-zl.github.io/2026/04/17/AFL-实战其九/
作者
ZLSF
发布于
2026年4月17日
许可协议