2020/04/03 update:
It is recommended that reader learn how to combine libprotobuf-mutator and AFL++ with 5_libprotobuf_aflpp_custom_mutator_input. It provides more details and informations about how to handle input in the custom mutator.
lpm_aflpp_custom_mutator.cc: Shared library for AFL++- Custom mutate
TESTprotobuf.- In fact it just randomly generate a brand new
TESTprotobuf message.
- In fact it just randomly generate a brand new
- Convert the protobuf to raw data and return the result to AFL++.
- Custom mutate
lpm_aflpp_custom_mutator.h: Declareafl_custom_fuzzas a friend function so it can use protobuf's mutators.- Since
MutateStringis a protected function inprotobuf_mutator::Mutator,afl_custom_fuzzhas to be a friend function so it can callmutator.MutateString().
- Since
vuln.c: Vulnerable C program.
- Modify
PROTOBUF_DIRto your own protobuf installation path. - Modify
LPM_DIRto the root direcotry of libprotobuf-mutator. - Modify
AFLCCto the path of an AFL++'s compiler.
!! Make sure you compile the protobuf in 1_simple_protobuf first ( goto 1_simple_protobuf and make proto) !!.
This example uses the shared library of libprotobuf-mutator. Make sure you have libprotobuf-mutator.so compiled. You can refer to the README in this repo to learn how to compile the shared library.
make- This will create
lpm_aflpp_custom_mutator.so, the shared library for AFL++ ( for custom mutator's usage ).
- This will create
make vulnto create the vulnerable binary.run_fuzz.sh- Modify the path of
afl-fuzzbefore you run the script. - To run the script, use the following command:
LD_LIBRARY_PATH=/usr/local/lib ./run_fuzz.sh- Make sure
LD_LIBRARY_PATHis set to the path that contains thelibprotobuf-mutator.so.0library. By default it's installed in/usr/local/libwhen installing libprotobuf-mutator viasudo ninja install. - Somehow we can't write this line in
run_fuzz.sh, have to specify it in the command line instead.
- Make sure
AFL_CUSTOM_MUTATOR_ONLY=1is optional. However this is recommended since we want to observe the mutation performance ( = how well it generate a sample that crashes the program ) of our custom mutator.
- Modify the path of
- It should generate the crash samples immediately
- Check
out/crashes/id:000xxxxx.......... - The first byte of the crash sample should be
0xe8or0x02.
- Check