Hi all,
I am new to fuzzing using AFL++.
My objective is to fuzz my firmware which runs on a separate HW. It can receive/send command from/to a host. My intention is to add instrumentation to my firmware and trigger the test from the host. Since there is no shared memory between HW and the host, therefore I will be using a host interface to send guidance data from HW to host. On the host side, I assume LibAFL can be used to get the guidance information and use that for doing the next iteration of fuzzing. Following are the steps I am doing:
1. I am compiling https://github.com/AFLplusplus/AFLplusplus/blob/stable/instrumentation/afl-gcc-pass.so.cc to generate a afl-gcc-pass plugin which can be used for adding instrumentation to my FW. The command used for generating the plugin is as below:
g++ -O3 -g -funroll-loops -D_FORTIFY_SOURCE=2 -Wall -std=c++11 -fPIC -fno-rtti \
-I$PATH_TO_GCC_PLUGIN_DIR/include -I$PATH_TO_GCC_PLUGIN_DIR -shared \
-o "$PATH_TO_GCC_PLUGIN_DIR/afl-gcc-pass.so" "PATH_TO_afl-gcc-pass.so.cc"
2. Added -fplugin=afl-gcc-pass -Wno-maybe-uninitialized in my makefile to use the afl-gcc-pass plugin for adding instrumentation to my FW binary.
3. Added the definition of _afl_area_ptr and __afl_prev_loc as below:
4. Added the instrumentation to a set of files only by setting
export AFL_GCC_ALLOWLIST=afl_allow_list.txt
5.
Printing the content of__afl_area_ptr
on the trigger of a command.
for (uint32_t ti = 0; ti < 16384; ti++)
printf("%x ",__afl_area_ptr[ti]);
6. Loaded the binary on the device and sent a test command. This test command is for the instrumented code
The printed output is showing all 0. Ideally it should show the guidance data. Can someone please help me to understand what the missing/incorrect things are.
Additionally, I observed a crash due to an out of range address returned by _emutls_get_address.
Note: My FW is multi-threaded system.
I have doubt on the autogenerated function __emutls_get_address. Function __gthread_active_p() which invoked by __emutls_get_address is also one of the autogenerated function always returns 0.
Kindly help.