on 526c10d help sign in
40 lines 1.7 kB history raw
1# Script based on code from https://github.com/ndmitchell/hexml/issues/6
2# More examples of things to do are at that ticket
3set -e
5echo DISABLED DUE TO SEGFAULT IN CLANG WHEN COMPILING AFL
6echo See https://github.com/ndmitchell/hexml/issues/14
7exit 0
9# First install AFL
10if ! command -v afl-clang-fast > /dev/null ; then
11 wget http://lcamtuf.coredump.cx/afl/releases/afl-latest.tgz
12 tar xf afl-latest.tgz
13 cd afl-*
14 make
15 cd llvm_mode && make && cd ..
16 sudo make install
17 cd libdislocator && make && sudo make install && cd ..
18 cd ..
19fi
21# Compile it
22AFL_USE_ASAN=1 afl-clang-fast -O2 -Icbits cbits/fuzz.c -o $PWD/hexml-fuzz
24# Fuzz it
25if ! grep -q core /proc/sys/kernel/core_pattern ; then
26 echo core | sudo tee /proc/sys/kernel/core_pattern
27fi
28if [ -z "$CI" ] ; then
29 afl-fuzz -T hexml -m none -x /usr/local/share/afl/dictionaries/xml.dict -i $PWD/xml -o $PWD/afl-results -- $PWD/hexml-fuzz @@
30else
31 AFL_EXIT_WHEN_DONE=1 timeout 5m afl-fuzz -T hexml -m none -x /usr/local/share/afl/dictionaries/xml.dict -i $PWD/xml -o $PWD/afl-results -- $PWD/hexml-fuzz @@ > /dev/null || true
32 cat afl-results/fuzzer_stats
33 grep "unique_crashes *: 0" afl-results/fuzzer_stats # fail if there are failures
34fi
36# Minimize failures
37# $ AFL_PRELOAD=/usr/local/lib/afl/libdislocator.so afl-cmin -i results/crashes/ -o results.shrunk -- $PWD/a.out @@
38# $ mkdir results.min
39# $ for x in `ls results.shrunk`; do AFL_PRELOAD=/usr/local/lib/afl/libdislocator.so afl-tmin -i results.shrunk/$x -o results.min/$x -- $PWD/a.out @@; done
40# $ AFL_PRELOAD=/usr/local/lib/afl/libdislocator.so afl-analyze -i results.shrunk/id:000013,sig:11,src:000002,op:havoc,rep:4 -- ./a.out @@