DDIF Day2 RunBook 22 April
DDIF Day2 RunBook 22 April
Note: The above server will be valid till 30th April only.
1. DynamoRIO:
https://github.com/DynamoRIO/dynamorio/wiki/Downloads
2. Git Client: https://git-scm.com/download/win
3. WinAFL Git: https://github.com/googleprojectzero/winafl
4. Visual Studio 2019: https://visualstudio.microsoft.com/downloads/
5. WinDbg: https://developer.microsoft.com/en-
us/windows/downloads/windows-10-sdk/
6. x64dbg http://snapshots.x64dbg.com/
7. Ghidra https://ghidra-sre.org/ghidra_9.1.2_PUBLIC_20200212.zip
8. IDA https://www.hex-
rays.com/products/ida/support/download_freeware/
9. Dragondance Plugin for Ghidra
https://github.com/0ffffffffh/dragondance/
10. Java JRE https://www.oracle.com/java/technologies/javase-
jre8-downloads.html
11. Java JDK https://www.oracle.com/java/technologies/javase-
jdk15-downloads.html
12. Firefox https://www.mozilla.org/en-US/firefox/new/
13. Sublime Text Editor https://www.sublimetext.com/3
14. WinRAR https://www.win-rar.com/download.html?L=5
Installing WinAFL
$ cd qemu_mode
$ ./build_qemu_support.sh
Network Fuzzing
cd ~/persis/
cat bof.c
while (__AFL_LOOP(10000)) {
….
printf("You entered: %s\n", buffer);
}
}
NOTE: To make this work, the library and this shim need to be compiled in
LLVMmode using afl-clang-fast or afl-clang (other compiler wrappers will
*not* work).
cd ~/persis/
cat poc.c
while (__AFL_LOOP(10000)) {
….
}
Compile both above programs with afl-clang or afl-clang-fast and fuzz, you
would be able to see the difference in execution speed.
cd ~/persis/
cat poc.c
#ifdef __AFL_HAVE_MANUAL_CONTROL
__AFL_INIT();
#endif
Fuzzing OpenSSL
AFL QEMU
Fuzzing readelf
$ cd ~/qemu
$ mkdir in; mkdir out
$ ./readelf
(to verify)
$ cp ~/corpus/ps in/
$ afl-fuzz -i in/ -o out/ -Q -m none ./readelf -h @@
$ cd ~/qemu
$ wget https://busybox.net/downloads/busybox-1.32.0.tar.bz2
$ tar xvf busybox-1.32.0.tar.bz2
$ cd busybox-1.32.0
$ make menuconfig
(select save to a alternative configuration file, save
configuration)
$ make -j4
$ mkdir in; mkdir out
(Create test.zip by compressing test.txt containing AAAA)
$ ./busybox unzip -q -n in/test.zip
(to verify usage)
$ afl-fuzz -i in -o out -Q -D -c 0 -m none -x ~/AFLplusplus-
3.12c/dictionaries/zip.dict ./busybox unzip -n -q @@
(add with specific corpus – if required)
AFL QEMU Persistent
Fuzzing a binary
$ cd ~/qemu
$ ./sof
$ sudo apt install devscripts
$ hardening-check ./sof
(PIE detected)
$ AFL_QEMU_DEBUG_MAPS=1 afl-qemu-trace ./sof
$ nm sof | grep "main"
$ export AFL_QEMU_PERSISTENT_ADDR=0x4000001189
$ mkdir in1; mkdir out1
$ echo "AAAAA" > in1/test
$ printenv | grep "AFL"
Fuzzing a binary
$ cd ~/arm
$ mkdir in; mkdir out
(Create test.zip by compressing test.txt containing AAAA in the in/
folder)
$ chmod +x busybox-armv7l unzip
$ afl-fuzz -i in/ -o out/ -Q -m none -D -- ./busybox-armv7l unzip -q
-n @@
Network Fuzzing
Fuzzing wget
$ wget https://ftp.gnu.org/gnu/wget/wget-1.19.1.tar.gz
$ tar zxvf wget-1.19.1.tar.gz
$ cd wget-1.19.1
$ sudo apt-get update && sudo apt install libgnutls28-dev
libseccomp-dev libini-config-dev
$ CC=afl-cc CXX=afl-c++ ./configure --prefix=/home/zubin/
$ AFL_USE_ASAN=1 make
$ cd src
$ (echo "It Works!") | LD_PRELOAD="/home/fuzzing/preeny/x86_64-
linux-gnu/desock.so" ./wget localhost:6666 -q -O result
$ mkdir in; mkdir out
$ cd in;
$ echo "AAAAABB1234" > test
$ cd ..
$ AFL_PRELOAD="/home/fuzzing/preeny/x86_64-linux-gnu/desock.so" afl-
fuzz -i in/ -o out/ -D -m none ./wget localhost:6666 -q -O result
Or
$ AFL_PRELOAD="/home/fuzzing/preeny/x86_64-linux-gnu/desock.so" afl-
fuzz -i in/ -o out/ -D -m none ./wget localhost:6666 -t 1 -q -O
/dev/null
WinAFL Fuzzing Example (test)
Debug Mode
Using symbols
Debug Mode
Miscellaneous
Parallel fuzzing
Fuzzing on RAMDISK