Learn how to combine libprotobuf-mutator with libfuzzer & AFL++
- Ubuntu Linux 20.04 64 bit
- Clang 11.0.1
- Follow the step in this article and add the toolchain's apt repository in Ubuntu.
sudo apt-get install clang-11 libfuzzer-11-dev
Follow the step in libprotobuf-mutator's readme
sudo apt-get update
sudo apt-get install protobuf-compiler libprotobuf-dev binutils cmake \
ninja-build liblzma-dev libz-dev pkg-config autoconf libtool
cd libprotobuf-mutator
mkdir build
cd build
( A cmake command, check the below section )
ninja check # test, might took very long time
ninja # just build, use this if you don't want to wait too long
sudo ninja install # install
Notice
Use the following cmake command to buildlibprotobuf-mutator-libfuzzer.so.0
andlibprotobuf-mutator.so.0
shared library
cmake .. -GNinja -DCMAKE_C_COMPILER=clang-11 \
-DCMAKE_CXX_COMPILER=clang++-11 \
-DCMAKE_BUILD_TYPE=Debug \
-DLIB_PROTO_MUTATOR_DOWNLOAD_PROTOBUF=ON \
-DBUILD_SHARED_LIBS=ON
To build static libraries, use the following
cmake
command:
( This will generate libraries that can be linked into shared libraries / normal program )
cmake .. -GNinja -DCMAKE_C_COMPILER=clang-11 \
-DCMAKE_CXX_COMPILER=clang++-11 \
-DCMAKE_BUILD_TYPE=Debug \
-DLIB_PROTO_MUTATOR_DOWNLOAD_PROTOBUF=ON \
-DCMAKE_C_FLAGS="-fPIC" -DCMAKE_CXX_FLAGS="-fPIC"
- Upgrade Clang/LLVM & libfuzzer ( install a new version )
- Upgrade AFL++ ( git pull & rebuild )
- Upgrade libprotobuf-mutator ( git pull & rebuild )
- Rebuild and re-install
libprotobuf-mutator-libfuzzer.so.0
andlibprotobuf-mutator.so.0
. - Rebuild
libprotobuf-mutator-libfuzzer.a
andlibprotobuf-mutator.a
.
- Rebuild and re-install
- Re-compile the protobuf with newer
protoc
and replace those*.cc
&*.h
with new ones.
Q : I ran into this error message while building the binary : This file was generated by an old version of protoc.
A : The test.pb.cc
and test.pb.h
in this repo is generated with protoc v3.13.0.0
, so if your protoc's version is newer, make sure to re-generate those two files with the original protobuf source code test.proto
( source code and steps to generate *.cc
& *.h
are all in 1_simple_protobuf ).
- Simple protobuf example
- libprotobuf + libfuzzer
- libprotobuf + libfuzzer ( custom mutator )
- How to combine libprotobuf-mutator and AFL++
- Handling input samples from AFL++ in custom mutator