|
1 | | -#! /bin/sh |
| 1 | +#!/bin/sh |
| 2 | + |
| 3 | +COMMON_CMAKE_OPTIONS="-DCMAKE_C_COMPILER=afl-clang-lto -DCMAKE_CXX_COMPILER=afl-clang-lto++ -DBUILD_TOXAV=OFF -DENABLE_SHARED=NO -DBUILD_FUZZ_TESTS=ON -DDHT_BOOTSTRAP=OFF -DBOOTSTRAP_DAEMON=OFF" |
2 | 4 |
|
3 | 5 | # move to repo root |
4 | 6 | cd ../ |
5 | | -rm -R _afl_build |
6 | | -mkdir _afl_build |
| 7 | + |
| 8 | +# build fuzzer target UBSAN |
| 9 | +mkdir -p _afl_build_ubsan |
| 10 | +cd _afl_build_ubsan |
| 11 | + |
| 12 | +export AFL_USE_UBSAN=1 |
| 13 | + |
| 14 | +# build c-toxcore using afl instrumentation |
| 15 | +cmake -DCMAKE_BUILD_TYPE=Debug "$COMMON_CMAKE_OPTIONS" .. |
| 16 | + |
| 17 | +# build fuzzer target |
| 18 | +cmake --build ./ --target bootstrap_fuzzer |
| 19 | + |
| 20 | +unset AFL_USE_UBSAN |
| 21 | + |
| 22 | +cd .. |
| 23 | + |
| 24 | +# build fuzzer target MSAN |
| 25 | +mkdir -p _afl_build_msan |
| 26 | +cd _afl_build_msan |
| 27 | + |
| 28 | +export AFL_USE_MSAN=1 |
| 29 | + |
| 30 | +# build c-toxcore using afl instrumentation |
| 31 | +cmake -DCMAKE_BUILD_TYPE=Debug "$COMMON_CMAKE_OPTIONS" .. |
| 32 | + |
| 33 | +# build fuzzer target |
| 34 | +cmake --build ./ --target bootstrap_fuzzer |
| 35 | + |
| 36 | +unset AFL_USE_MSAN |
| 37 | + |
| 38 | +cd .. |
| 39 | + |
| 40 | +# build fuzzer target ASAN |
| 41 | +mkdir -p _afl_build_asan |
| 42 | +cd _afl_build_asan |
| 43 | + |
| 44 | +export AFL_USE_ASAN=1 |
| 45 | + |
| 46 | +# build c-toxcore using afl instrumentation |
| 47 | +cmake -DCMAKE_BUILD_TYPE=Debug "$COMMON_CMAKE_OPTIONS" .. |
| 48 | + |
| 49 | +# build fuzzer target |
| 50 | +cmake --build ./ --target bootstrap_fuzzer |
| 51 | + |
| 52 | +unset AFL_USE_ASAN |
| 53 | + |
| 54 | +cd .. |
| 55 | + |
| 56 | +# build fuzzer target without sanitizers for afl-tmin |
| 57 | +mkdir -p _afl_build |
7 | 58 | cd _afl_build |
8 | 59 |
|
9 | 60 | # build c-toxcore using afl instrumentation |
10 | | -cmake -DCMAKE_C_COMPILER=afl-clang -DBUILD_MISC_TESTS=ON .. |
11 | | -make |
| 61 | +cmake -DCMAKE_BUILD_TYPE=Debug "$COMMON_CMAKE_OPTIONS" .. |
| 62 | + |
| 63 | +# build fuzzer target |
| 64 | +cmake --build ./ --target bootstrap_fuzzer |
| 65 | + |
| 66 | +cd .. |
| 67 | + |
| 68 | +# build fuzzer target with CmpLog |
| 69 | +mkdir -p _afl_build_cmplog |
| 70 | +cd _afl_build_cmplog |
| 71 | + |
| 72 | +export AFL_LLVM_CMPLOG=1 |
| 73 | + |
| 74 | +# build c-toxcore using afl instrumentation |
| 75 | +cmake -DCMAKE_BUILD_TYPE=Debug "$COMMON_CMAKE_OPTIONS" .. |
| 76 | + |
| 77 | +# build fuzzer target |
| 78 | +cmake --build ./ --target bootstrap_fuzzer |
| 79 | + |
| 80 | +unset AFL_LLVM_CMPLOG |
| 81 | + |
| 82 | +cd .. |
| 83 | + |
| 84 | +# build fuzzer target for code coverage |
| 85 | +mkdir -p _cov_build |
| 86 | +cd _cov_build |
| 87 | + |
| 88 | +# build c-toxcore using afl instrumentation |
| 89 | +cmake -DCMAKE_BUILD_TYPE=Debug -DCMAKE_CXX_FLAGS="-fprofile-arcs -ftest-coverage" -DCMAKE_C_FLAGS="-fprofile-arcs -ftest-coverage" -DCMAKE_VERBOSE_MAKEFILE=ON "$COMMON_CMAKE_OPTIONS" .. |
| 90 | + |
| 91 | +# build fuzzer target |
| 92 | +cmake --build ./ --target bootstrap_fuzzer |
| 93 | + |
| 94 | +# back to repo root |
| 95 | +cd ../ |
| 96 | + |
| 97 | +# Create fuzzer working directory |
| 98 | + |
| 99 | +mkdir -p _afl_out |
| 100 | + |
| 101 | +AFL_ARGS='-i testing/afl_testdata/tox_bootstraps/ -o _afl_out' |
| 102 | + |
| 103 | +export AFL_IMPORT_FIRST=1 |
| 104 | +export AFL_AUTORESUME=1 |
| 105 | + |
| 106 | +# faster startup |
| 107 | +export AFL_FAST_CAL=1 |
| 108 | + |
| 109 | +echo "connect to the fuzzers using: screen -x fuzz" |
| 110 | +echo "if fuzzing doesn't start execute the following as root:" |
| 111 | +echo "" |
| 112 | +echo "echo core >/proc/sys/kernel/core_pattern" |
| 113 | +echo "echo performance | tee /sys/devices/system/cpu/cpu*/cpufreq/scaling_governor" |
| 114 | + |
| 115 | +# Main fuzzer, keeps complete corpus |
| 116 | +screen -dmS fuzz afl-fuzz -M fuzz0 "$AFL_ARGS" -c ./_afl_build_cmplog/bootstrap_fuzzer ./_afl_build/bootstrap_fuzzer |
| 117 | +sleep 10s |
| 118 | + |
| 119 | +# Secondary fuzzers |
| 120 | +screen -S fuzz -X screen afl-fuzz -S fuzz1 "$AFL_ARGS" -- ./_afl_build_msan/bootstrap_fuzzer |
| 121 | +sleep 1s |
| 122 | + |
| 123 | +screen -S fuzz -X screen afl-fuzz -S fuzz2 "$AFL_ARGS" ./_afl_build_ubsan/bootstrap_fuzzer |
| 124 | +sleep 1s |
12 | 125 |
|
13 | | -# start fuzzing |
14 | | -afl-fuzz -i ../testing/afl_testdata/tox_saves/ -o afl_out/ ./afl_toxsave @@ |
| 126 | +screen -S fuzz -X screen afl-fuzz -S fuzz3 "$AFL_ARGS" ./_afl_build_asan/bootstrap_fuzzer |
0 commit comments