为什么 afl-g++ 无法编译 ImageMagick?
Why afl-g++ can't compile ImageMagick?
我正在尝试使用 afl 工具进行一些模糊测试(link). I downloaded the source code of ImageMagick as described in the docs,但是当我尝试使用 afl 编译器 运行 ./configure
时,出现错误:
$ CC=/usr/local/bin/afl-gcc CXX=/usr/local/bin/afl-g++ ./configure --disable-shared
[...]
checking whether we are using the GNU C++ compiler... no
checking whether /usr/local/bin/afl-g++ accepts -g... no
checking dependency style of /usr/local/bin/afl-g++... none
checking how to run the C++ preprocessor... /lib/cpp
configure: error: in `/home/ubuntu/ImageMagick-7.0.10':
configure: error: C++ preprocessor "/lib/cpp" fails sanity check
See `config.log' for more details
如果我尝试使用默认的 c++ 编译器,一切似乎都很好:
$ CC=/usr/local/bin/afl-gcc ./configure --disable-shared #this works
如何制作编译器运行?
更新
查看内部 config.log
,问题似乎与 ImageMagick 无法检查 afl-g++
版本有关:
configure:15015: checking for C++ compiler version
configure:15024: /usr/local/bin/afl-g++ --version >&5
)B[?25h[0m[1;91m
[-] PROGRAM ABORT : [1;97mOops, failed to execute 'g++' - check your PATH[1;91m
Location : [0mmain(), afl-gcc.c:334
configure:15035: $? = 1
无论如何,afl-g++
似乎有效:
$ afl-g++
afl-cc 2.52b by <lcamtuf@google.com>
This is a helper application for afl-fuzz. It serves as a drop-in replacement
for gcc or clang, letting you recompile third-party code with the required
runtime instrumentation. A common use pattern would be one of the following:
CC=/usr/local/bin/afl-gcc ./configure
CXX=/usr/local/bin/afl-g++ ./configure
You can specify custom next-stage toolchain via AFL_CC, AFL_CXX, and AFL_AS.
Setting AFL_HARDEN enables hardening optimizations in the compiled code.
但是afl-g++ -v
报错:
$ afl-g++ -v
afl-cc 2.52b by <lcamtuf@google.com>
[-] PROGRAM ABORT : Oops, failed to execute 'g++' - check your PATH
Location : main(), afl-gcc.c:334
您是否仅限于使用 afl 的 gcc?如果没有,请使用他们的 clang 包装器:
我可以这样开始 AFL:
git clone https://github.com/ImageMagick/ImageMagick.git ImageMagick-7.0.10
cd ImageMagick-7.0.10
CC=afl-clang CXX=afl-clang++ ./configure --disable-shared
make
#prepare AFL environment
AFL_SKIP_CPU_FREQ=1 AFL_I_DONT_CARE_ABOUT_MISSING_CRASHES=1 afl-fuzz -i ./in -o ./out -- ./utilities/magick @@ /dev/null
显然,像这样开始 AFL 很少有意义 - 我只是说我能够以这种方式快速开始它。
原来是我的系统没有g++
的问题。可能是因为我安装了 Ubuntu 20.04LTS 的最小版本。我用
安装了 g++
sudo apt install g++
现在一切似乎都正常了。
我正在尝试使用 afl 工具进行一些模糊测试(link). I downloaded the source code of ImageMagick as described in the docs,但是当我尝试使用 afl 编译器 运行 ./configure
时,出现错误:
$ CC=/usr/local/bin/afl-gcc CXX=/usr/local/bin/afl-g++ ./configure --disable-shared
[...]
checking whether we are using the GNU C++ compiler... no
checking whether /usr/local/bin/afl-g++ accepts -g... no
checking dependency style of /usr/local/bin/afl-g++... none
checking how to run the C++ preprocessor... /lib/cpp
configure: error: in `/home/ubuntu/ImageMagick-7.0.10':
configure: error: C++ preprocessor "/lib/cpp" fails sanity check
See `config.log' for more details
如果我尝试使用默认的 c++ 编译器,一切似乎都很好:
$ CC=/usr/local/bin/afl-gcc ./configure --disable-shared #this works
如何制作编译器运行?
更新
查看内部 config.log
,问题似乎与 ImageMagick 无法检查 afl-g++
版本有关:
configure:15015: checking for C++ compiler version
configure:15024: /usr/local/bin/afl-g++ --version >&5
)B[?25h[0m[1;91m
[-] PROGRAM ABORT : [1;97mOops, failed to execute 'g++' - check your PATH[1;91m
Location : [0mmain(), afl-gcc.c:334
configure:15035: $? = 1
无论如何,afl-g++
似乎有效:
$ afl-g++
afl-cc 2.52b by <lcamtuf@google.com>
This is a helper application for afl-fuzz. It serves as a drop-in replacement
for gcc or clang, letting you recompile third-party code with the required
runtime instrumentation. A common use pattern would be one of the following:
CC=/usr/local/bin/afl-gcc ./configure
CXX=/usr/local/bin/afl-g++ ./configure
You can specify custom next-stage toolchain via AFL_CC, AFL_CXX, and AFL_AS.
Setting AFL_HARDEN enables hardening optimizations in the compiled code.
但是afl-g++ -v
报错:
$ afl-g++ -v
afl-cc 2.52b by <lcamtuf@google.com>
[-] PROGRAM ABORT : Oops, failed to execute 'g++' - check your PATH
Location : main(), afl-gcc.c:334
您是否仅限于使用 afl 的 gcc?如果没有,请使用他们的 clang 包装器:
我可以这样开始 AFL:
git clone https://github.com/ImageMagick/ImageMagick.git ImageMagick-7.0.10
cd ImageMagick-7.0.10
CC=afl-clang CXX=afl-clang++ ./configure --disable-shared
make
#prepare AFL environment
AFL_SKIP_CPU_FREQ=1 AFL_I_DONT_CARE_ABOUT_MISSING_CRASHES=1 afl-fuzz -i ./in -o ./out -- ./utilities/magick @@ /dev/null
显然,像这样开始 AFL 很少有意义 - 我只是说我能够以这种方式快速开始它。
原来是我的系统没有g++
的问题。可能是因为我安装了 Ubuntu 20.04LTS 的最小版本。我用
g++
sudo apt install g++
现在一切似乎都正常了。