forked from profuzzbench/profuzzbench
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathprofuzzbench_exec_common.sh
executable file
·49 lines (40 loc) · 1.67 KB
/
profuzzbench_exec_common.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
#!/bin/bash
DOCIMAGE=$1 #name of the docker image
RUNS=$2 #number of runs
SAVETO=$3 #path to folder keeping the results
FUZZER=$4 #fuzzer name (e.g., aflnet) -- this name must match the name of the fuzzer folder inside the Docker container
OUTDIR=$5 #name of the output folder created inside the docker container
OPTIONS=$6 #all configured options for fuzzing
TIMEOUT=$7 #time for fuzzing
SKIPCOUNT=$8 #used for calculating coverage over time. e.g., SKIPCOUNT=5 means we run gcovr after every 5 test cases
DELETE=$9
WORKDIR="/home/ubuntu/experiments"
#keep all container ids
cids=()
#create one container for each run
for i in $(seq 1 $RUNS); do
id=$(sudo docker run --cpus=1 -d -it $DOCIMAGE /bin/bash -c "cd ${WORKDIR} && run ${FUZZER} ${OUTDIR} '${OPTIONS}' ${TIMEOUT} ${SKIPCOUNT}")
cids+=(${id::12}) #store only the first 12 characters of a container ID
done
dlist="" #docker list
for id in ${cids[@]}; do
dlist+=" ${id}"
done
#wait until all these dockers are stopped
printf "\n${FUZZER^^}: Fuzzing in progress ..."
printf "\n${FUZZER^^}: Waiting for the following containers to stop: ${dlist}"
sudo docker wait ${dlist} > /dev/null
wait
#collect the fuzzing results from the containers
printf "\n${FUZZER^^}: Collecting results and save them to ${SAVETO}"
index=1
for id in ${cids[@]}; do
printf "\n${FUZZER^^}: Collecting results from container ${id}"
sudo docker cp ${id}:/home/ubuntu/experiments/${OUTDIR}.tar.gz ${SAVETO}/${OUTDIR}_${index}.tar.gz > /dev/null
if [ ! -z $DELETE ]; then
printf "\nDeleting ${id}"
sudo docker rm ${id} # Remove container now that we don't need it
fi
index=$((index+1))
done
printf "\n${FUZZER^^}: I am done!\n"