Hi *
A small sad story about me trying to fuzz a closed source binary...
I wanted to fuzz a closed source binary on a network device (which was
x86, I was surprised by that). So I guess I had the following options
(let me know if I miss one):
a) compile AFL/qemu on network device
b) compile AFL/qemu on another box and copy to network device
c) use dyninst and copy AFL from another box (although stripped target
binary...)
d) copy the target binary to another box and run it there
I started with a) and I wasn't able to get a compile environment on the
network device (custom cli, not enough disc space, qemu complaining
about glibc version, etc. one big nightmare)
So I went for option b).
Small hint here: to compile qemu on Ubuntu 14.04 you need to change the
following line in qemu_mode/qemu-2.2.0/linux-user/syscall.c:
#include <linux/soundcard.h>
to
#include <linux/soundcard.h.oss3>
After compiling and copying AFL/qemu to the target box, dumb fuzzing
(afl-fuzz -n) works fine. When using -Q I get the "Fork server handshake
failed". The reason is probably that my other machine is not similar
enough (other libc):
$./afl-qemu-trace
./afl-qemu-trace: /lib/libc.so.6: version 'GLIBC_2.15' not found
(required by ./afl-qemu-trace)
./afl-qemu-trace: /lib/libc.so.6: version 'GLIBC_2.14' not found
(required by ./afl-qemu-trace)
./afl-qemu-trace: /lib/libc.so.6: version 'GLIBC_2.16' not found
(required by ./afl-qemu-trace)
I went back and tried to compile qemu statically, by adding --static to
the configure command for qemu in the build_qemu_support.sh script. Of
course, I got warnings such as:
warning: Using 'getaddrinfo' in statically linked applications requires
at runtime the shared libraries from the glibc version used for linking
Same for getpwuid, getpwnam_r, getpwuid_r. And of course the build fails:
/usr/lib/gcc/i686-linux-gnu/4.8/../../../i386-linux-gnu/libgcrypt.a(libgcrypt_la-misc.o):
In function `_gcry_fatal_error':
(.text+0x2df): undefined reference to `gpg_strerror'
[...]
So I got fed up and I went for option c). Which was another nightmare.
Getting dyninst installed is hard, it wouldn't compile because the new
cmake approach of the project throws one error after another. The
dyninst-dev.deb package they offer have dependency on (guess what) the
dyninst package, which you can't download. Using an old dyninst.deb
package works, but it won't install the header files, which afl-dyninst
needs, so afl-dyninst didn't compile...
So option d). Although the target binary works kind of when copied to
another box, it looks for daemons and other programs on the system that
it won't be able to connect to. So we are not fuzzing properly with this
approach. However, after compiling AFL with Qemu support I get:
$ ./afl-fuzz -i /opt/xxx-fuzzing/input/ -o /opt/xxx-fuzzing/output -Q
/opt/xxx-fuzzing/xxx -f @@
afl-fuzz 1.71b by <
lca...@google.com>
[+] You have 1 CPU cores and 4 runnable tasks (utilization: 400%).
[*] Checking core_pattern...
[*] Setting up output directories...
[+] Output directory exists but deemed OK to reuse.
[*] Deleting old session data...
[+] Output dir cleanup successful.
[*] Scanning '/opt/xxx-fuzzing/input/'...
[+] No auto-generated dictionary tokens to reuse.
[*] Creating hard links for all input files...
[*] Validating target binary...
[*] Attempting dry run with 'id:000000,orig:test.txt'...
[*] Spinning up the fork server...
[+] All right - fork server is up.
[-] PROGRAM ABORT : Unable to communicate with fork server
Location : run_target(), afl-fuzz.c:2069
But for me it looks like qemu works fine:
$ ./afl-qemu-trace
usage: qemu-i386 [options] program [arguments...]
Linux CPU emulator (compiled for i386 emulation)
Options and associated environment variables:
Argument Env-variable Description
-h print this help
[...]
So, any hints/help on one of the cases, especially d)? Also if somebody
could elaborate on which version is necessary and what build environment
works for afl-dyninst would be helpful.
It would be so much fun to see the AFL results, because even python -c
"print 'A'*1000" as input results in a crash.
cheers,
floyd