AFL++ supports fuzzing file inputs or standard input. The argv_fuzzing feature allows for the fuzzing of arguments passed to a program from the command line interface rather than from STDIN.
When the source code is available, a specific macro from the argv-fuzz-inl.h header file can be used to change the program's behavior to build argv from STDIN.
Conditions needed to use the argv_fuzzing feature:
argv-fuzz-inl.h header file (#include "argv-fuzz-inl.h")int main(int argc, char **argv))AFL_INIT_ARGV(); orAFL_INIT_SET0("prog_name"); to preserve argv[0] (the name of the program being executed)see: argv_fuzz_demo.c
Conditions needed to use the argv_fuzzing feature with persistent mode:
unsigned char *buf = __AFL_FUZZ_TESTCASE_BUF):AFL_INIT_ARGV_PERSISTENT(buf), if you want toAFL_INIT_SET0_PERSISTENT("name_of_binary", buf)see: argv_fuzz_persistent_demo.c
argvfuzz tries to provide the same functionality for binaries. When loaded using LD_PRELOAD, it will hook the call to __libc_start_main and replace argv using the same logic of argv-fuzz-inl.h.
A few conditions need to be fulfilled for this mechanism to work correctly:
_start implementation (crt1.o), the hook may not run..data of argvfuzz.so. Things may go wrong if the target binary expects argv to live on the stack.