-
Notifications
You must be signed in to change notification settings - Fork 23
/
fuzz-helper.sh
executable file
·56 lines (42 loc) · 1.57 KB
/
fuzz-helper.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
46
47
48
49
50
51
52
53
54
55
56
#!/bin/bash
#
# Quick 'n dirty Script to build and run FlashMQ with American Fuzzy Lop.
thisfile=$(readlink --canonicalize "$0")
thisdir=$(dirname "$thisfile")
if [[ -z "$AFL_ROOT" ]]; then
echo "ERROR: set AFL_ROOT environment variable"
exit 1
fi
if [[ -z "$FLASHMQ_SRC" ]]; then
echo "ERROR: set FLASHMQ_SRC environment variable"
exit 1
fi
set -u
if [[ ! -d "$FLASHMQ_SRC/fuzztests" ]]; then
echo "Folder 'fuzztests' not found in '$FLASHMQ_SRC'"
exit 1
fi
if [[ "$1" == "build" ]]; then
export CC="$AFL_ROOT/afl-gcc"
export CXX="$AFL_ROOT/afl-g++"
mkdir "fuzzbuild"
cd "fuzzbuild" || exit 1
"$thisdir/build.sh" Debug
if [[ -f "./FlashMQBuildDebug/flashmq" ]]; then
cp -v "./FlashMQBuildDebug/flashmq" ..
fi
fi
if [[ "$1" == "run" ]]; then
INPUTDIR="$FLASHMQ_SRC/fuzztests"
OUTPUTDIR="fuzzoutput"
BINARY="./flashmq"
if [[ ! -d "$OUTPUTDIR" ]]; then
mkdir "$OUTPUTDIR"
fi
tmux new-session -s flashmqfuzz -d "'$AFL_ROOT/afl-fuzz' -m 200 -M primary -i '$INPUTDIR' -o '$OUTPUTDIR' '$BINARY' --fuzz-file '@@'; sleep 5"
tmux split-window -t flashmqfuzz -v "'$AFL_ROOT/afl-fuzz' -m 200 -S secondary01 -i '$INPUTDIR' -o '$OUTPUTDIR' '$BINARY' --fuzz-file '@@'; sleep 5"
tmux split-window -t flashmqfuzz -h "'$AFL_ROOT/afl-fuzz' -m 200 -S secondary02 -i '$INPUTDIR' -o '$OUTPUTDIR' '$BINARY' --fuzz-file '@@'; sleep 5"
tmux select-pane -t flashmqfuzz -U
tmux split-window -t flashmqfuzz -h "'$AFL_ROOT/afl-fuzz' -m 200 -S secondary03 -i '$INPUTDIR' -o '$OUTPUTDIR' '$BINARY' --fuzz-file '@@'; sleep 5"
tmux attach-session -d -t flashmqfuzz
fi