forked from abonander/multipart-async
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrun-fuzzer.sh
executable file
·45 lines (40 loc) · 956 Bytes
/
run-fuzzer.sh
1
2
3
4
5
6
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
38
39
40
41
42
43
44
45
#!/usr/bin/env bash
set -m
case "$1" in
*boundary*)
DICT=dict/boundary
;;
*header*)
DICT=dict/headers
;;
*whole*)
DICT=dict/whole
;;
*string*)
DICT=dict/read-to-string
;;
*)
echo unknown fuzzing target $1
exit 1
;;
esac
cd fuzz
env RUSTFLAGS='-C opt-level=0' cargo afl build || exit 1
OUTPUT="output-$1"
rm -rf $OUTPUT
mkdir $OUTPUT
if [[ -n "$PARALLEL_FUZZ" ]]; then
# trap Ctrl-C and others and pass to all child jobs
trap "trap - SIGTERM && kill -- -$$" SIGINT SIGTERM EXIT
# 4 comment lines preceed the output minus one extra for the master
NUM_CPUS=`expr $(lscpu -p | wc -l) - 4`
echo detected num cpus: $NUM_CPUS
cargo afl fuzz -i $DICT -o $OUTPUT -M "$1_master" target/debug/$1 &
for ((i=0;i<$NUM_CPUS-1;i++)); do
NAME="$1_slave_$i"
cargo afl fuzz -i $DICT -o $OUTPUT -S "$1_slave_$i" target/debug/$1 > "$OUTPUT/slave-$i" &
done
fg %1
else
cargo afl fuzz -i $DICT -o $OUTPUT target/debug/$1
fi