-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathrun.sh
executable file
·62 lines (55 loc) · 2.61 KB
/
run.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
57
58
59
60
61
62
#!/bin/bash
FUZZER=$1 #fuzzer name (e.g., aflnet) -- this name must match the name of the fuzzer folder inside the Docker container
OUTDIR=$2 #name of the output folder
OPTIONS=$3 #all configured options -- to make it flexible, we only fix some options (e.g., -i, -o, -N) in this script
TIMEOUT=$4 #time for fuzzing
SKIPCOUNT=$5 #used for calculating cov over time. e.g., SKIPCOUNT=5 means we run gcovr after every 5 test cases
NO_SEEDS=$6
strstr() {
[ "${1#*$2*}" = "$1" ] && return 1
return 0
}
#Commands for afl-based fuzzers (e.g., aflnet, aflnwe)
if $(strstr $FUZZER "afl"); then
#Step-1. Do Fuzzing
#Move to fuzzing folder
cd $WORKDIR/LightFTP/Source/Release
if [ "$NO_SEEDS" = 1 ]; then
INPUTS="$WORKDIR/in-ftp-empty"
else
INPUTS="$WORKDIR/in-ftp"
fi
if [ "$FUZZER" = "aflpp" ]; then
AFL_PRELOAD="/home/ubuntu/preeny/src/desock.so" \
timeout -k 0 $TIMEOUT /home/ubuntu/${FUZZER}/afl-fuzz \
-d -i "$INPUTS" -x ${WORKDIR}/ftp.dict -o $OUTDIR \
$OPTIONS ./fftp fftp.conf 2200
else
timeout -k 0 $TIMEOUT /home/ubuntu/${FUZZER}/afl-fuzz \
-d -i "$INPUTS" -x ${WORKDIR}/ftp.dict -o $OUTDIR \
-N tcp://127.0.0.1/2200 $OPTIONS ./fftp fftp.conf 2200
fi
#Wait for the fuzzing process
wait
#Step-2. Collect code coverage over time
#Move to gcov folder
cd $WORKDIR/LightFTP-gcov/Source/Release
#The last argument passed to cov_script should be 0 if the fuzzer is afl/nwe and it should be 1 if the fuzzer is based on aflnet
#0: the test case is a concatenated message sequence -- there is no message boundary
#1: the test case is a structured file keeping several request messages
if [ $FUZZER = "aflnwe" ]; then
cov_script ${WORKDIR}/LightFTP/Source/Release/${OUTDIR}/ 2200 ${SKIPCOUNT} ${WORKDIR}/LightFTP/Source/Release/${OUTDIR}/cov_over_time.csv 0
elif [ "$FUZZER" = "aflpp" ]; then
cov_script ${WORKDIR}/LightFTP/Source/Release/${OUTDIR}/default 2200 ${SKIPCOUNT} ${WORKDIR}/LightFTP/Source/Release/${OUTDIR}/cov_over_time.csv 0
else
cov_script ${WORKDIR}/LightFTP/Source/Release/${OUTDIR}/ 2200 ${SKIPCOUNT} ${WORKDIR}/LightFTP/Source/Release/${OUTDIR}/cov_over_time.csv 1
fi
gcovr -r .. --html --html-details -o index.html
mkdir ${WORKDIR}/LightFTP/Source/Release/${OUTDIR}/cov_html/
cp *.html ${WORKDIR}/LightFTP/Source/Release/${OUTDIR}/cov_html/
# genhtml -o "${WORKDIR}/LightFTP/Source/Release/${OUTDIR}/cov_html/" --branch-coverage "$WORKDIR/coverage.info"
#Step-3. Save the result to the ${WORKDIR} folder
#Tar all results to a file
cd ${WORKDIR}/LightFTP/Source/Release
tar -zcvf ${WORKDIR}/${OUTDIR}.tar.gz ${OUTDIR}
fi