forked from strongcourage/uafbench
-
Notifications
You must be signed in to change notification settings - Fork 0
/
CVE-2016-3189.sh
executable file
·46 lines (42 loc) · 2.3 KB
/
CVE-2016-3189.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
#!/bin/bash
PUT="CVE-2016-3189"
runmode=$1
timeout=$2
targets=$3
# Checkout source code
git clone git://sourceware.org/git/bzip2.git $PUT
cd $PUT; export SUBJECT=$PWD;
git checkout 962d606
# Compile source code
make clean; CFLAGS="-g -m32 -fsanitize=address" make -e
rm -rf obj-asan; mkdir obj-asan; cd obj-asan; mv ../bzip2recover .
cd $SUBJECT; make clean; CC=gcc CFLAGS="-g -m32" make -e
rm -rf obj; mkdir obj; cd obj; cp ../bzip2recover .
# Prepare working directories
cd $SUBJECT; rm -rf obj-$runmode; mkdir obj-$runmode; export FUZZ_DIR=$SUBJECT/obj-$runmode; cd $FUZZ_DIR
mkdir in; cp $UAFBENCH_PATH/seeds/$PUT/* in
# Fuzzing
if [ $runmode = "aflqemu" ]; then
cp $SUBJECT/bzip2recover .
timeout -sHUP ${timeout}m $SCRIPTS/run_afl.py -f $FUZZ_DIR/bzip2recover -Q -i $FUZZ_DIR/in -o run -r "$FUZZ_DIR/bzip2recover @@" -to $timeout
elif [ $runmode = "aflgo" ]; then
SECONDS=0
export AFL_PATH=$HOME/aflgo; export AFLGO=$AFL_PATH
mkdir temp; export TMP_DIR=$FUZZ_DIR/temp
export CC=$AFLGO/afl-clang-fast; export CXX=$AFLGO/afl-clang-fast++
export LDFLAGS=-lpthread
export ADDITIONAL="-targets=$TMP_DIR/BBtargets.txt -outdir=$TMP_DIR -flto -fuse-ld=gold -Wl,-plugin-opt=save-temps"
echo $'bzip2recover.c:495\nbzip2recover.c:169\nbzip2recover.c:237\nbzip2recover.c:455\nbzip2recover.c:246\nbzip2recover.c:182' > $TMP_DIR/BBtargets.txt
make clean;
CFLAGS="$ADDITIONAL" CXXFLAGS="$ADDITIONAL" make -e
cat $TMP_DIR/BBnames.txt | rev | cut -d: -f2- | rev | sort | uniq > $TMP_DIR/BBnames2.txt && mv $TMP_DIR/BBnames2.txt $TMP_DIR/BBnames.txt
cat $TMP_DIR/BBcalls.txt | sort | uniq > $TMP_DIR/BBcalls2.txt && mv $TMP_DIR/BBcalls2.txt $TMP_DIR/BBcalls.txt
$AFLGO/scripts/genDistance.sh $SUBJECT $TMP_DIR bzip2recover
make clean; CFLAGS="-distance=$TMP_DIR/distance.cfg.txt" CXXFLAGS="-distance=$TMP_DIR/distance.cfg.txt" make -e
pp_aflgo_time=$SECONDS; echo "pp_aflgo_time: $pp_aflgo_time (s)."
timeout -sHUP "${timeout}m" $AFLGO/afl-fuzz -m none -z exp -c 45m -i in -o out $FUZZ_DIR/bzip2recover @@
elif [ $1 = "aflgob" ] || [ $1 = "heb" ] || [ $1 = "uafuzz" ]; then
cp $SUBJECT/bzip2recover $PUT; cp $targets .
$UAFUZZ_PATH/scripts/preprocess.py -f $PUT -v $targets -o $FUZZ_DIR
$UAFUZZ_PATH/scripts/run_uafuzz.py -f $FUZZ_DIR/$PUT -M fuzz -i $FUZZ_DIR/in -o run -r "$FUZZ_DIR/$PUT @@" -I $runmode -T "$FUZZ_DIR/$PUT.tgt" -to $timeout
fi