README.md 1.8 KB
Newer Older
B
Ben Laurie 已提交
1 2
# I Can Haz Fuzz?

K
Kurt Roeckx 已提交
3 4 5
LibFuzzer
=========

S
Sergey Bronnikov 已提交
6
Or, how to fuzz OpenSSL with [libfuzzer](http://llvm.org/docs/LibFuzzer.html).
B
Ben Laurie 已提交
7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37

Starting from a vanilla+OpenSSH server Ubuntu install.

Use Chrome's handy recent build of clang. Older versions may also work.

    $ sudo apt-get install git
    $ mkdir git-work
    $ git clone https://chromium.googlesource.com/chromium/src/tools/clang
    $ clang/scripts/update.py

You may want to git pull and re-run the update from time to time.

Update your path:

    $ PATH=~/third_party/llvm-build/Release+Asserts/bin/:$PATH

Get and build libFuzzer (there is a git mirror at
https://github.com/llvm-mirror/llvm/tree/master/lib/Fuzzer if you prefer):

    $ cd
    $ sudo apt-get install subversion
    $ mkdir svn-work
    $ cd svn-work
    $ svn co http://llvm.org/svn/llvm-project/llvm/trunk/lib/Fuzzer
    $ cd Fuzzer
    $ clang++ -c -g -O2 -std=c++11 *.cpp
    $ ar r libFuzzer.a *.o
    $ ranlib libFuzzer.a

Configure for fuzzing:

K
Kurt Roeckx 已提交
38 39 40
    $ CC=clang ./config enable-fuzz-libfuzzer \
            --with-fuzzer-include=../../svn-work/Fuzzer \
            --with-fuzzer-lib=../../svn-work/Fuzzer/libFuzzer \
41
            -DPEDANTIC enable-asan enable-ubsan no-shared
B
Ben Laurie 已提交
42 43
    $ sudo apt-get install make
    $ LDCMD=clang++ make -j
R
Rich Salz 已提交
44
    $ fuzz/helper.py $FUZZER
B
Ben Laurie 已提交
45

R
Rich Salz 已提交
46
Where $FUZZER is one of the executables in `fuzz/`.
B
Ben Laurie 已提交
47 48

If you get a crash, you should find a corresponding input file in
R
Rich Salz 已提交
49
`fuzz/corpora/$FUZZER-crash/`. You can reproduce the crash with
B
Ben Laurie 已提交
50

R
Rich Salz 已提交
51
    $ fuzz/$FUZZER <crashfile>
K
Kurt Roeckx 已提交
52 53 54 55 56 57 58 59 60 61 62 63

AFL
===

Configure for fuzzing:

    $ sudo apt-get install afl-clang
    $ CC=afl-clang-fast ./config enable-fuzz-afl no-shared
    $ make

Run one of the fuzzers:

R
Rich Salz 已提交
64
    $ afl-fuzz -i fuzz/corpora/$FUZZER -o fuzz/corpora/$FUZZER/out fuzz/$FUZZER
K
Kurt Roeckx 已提交
65

R
Rich Salz 已提交
66
Where $FUZZER is one of the executables in `fuzz/`.