forked from strongcourage/uafbench
-
Notifications
You must be signed in to change notification settings - Fork 0
/
CVE-2017-10686.sh
executable file
·50 lines (46 loc) · 2.52 KB
/
CVE-2017-10686.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
#!/bin/bash
PUT="CVE-2017-10686"
runmode=$1
timeout=$2
targets=$3
# Checkout source code
git clone git://repo.or.cz/nasm.git $PUT
cd $PUT; export SUBJECT=$PWD;
git checkout 7a81ead
# Compile source code
./autogen.sh; make distclean
rm -rf obj; mkdir obj; cd obj
CFLAGS="-g -m32" LDFLAGS="-m32" ../configure --prefix=`pwd`
make clean; make
cd $SUBJECT; rm -rf obj-asan; mkdir obj-asan; cd obj-asan
CFLAGS="-g -m32 -fsanitize=address" LDFLAGS="-g -m32 -fsanitize=address" ../configure --prefix=`pwd`
make clean; make
# 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/obj/nasm .
timeout -sHUP ${timeout}m $SCRIPTS/run_afl.py -f $FUZZ_DIR/nasm -Q -i $FUZZ_DIR/in -o run -r "$FUZZ_DIR/nasm -f bin @@ -o /dev/null" -to $timeout
elif [ $runmode = "aflgo" ]; then # Compilation error?
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 $'nasm.c:453\nnasm.c:1233\npreproc.c:5211\npreproc.c:4867\npreproc.c:1226\nmalloc.c:47\npreproc.c:5116\npreproc.c:1284\nmalloc.c:77\npreproc.c:1305' > $TMP_DIR/BBtargets.txt
CFLAGS="$ADDITIONAL" CXXFLAGS="$ADDITIONAL" ../configure --prefix=`pwd`
make clean; make
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
cd $FUZZ_DIR; $AFLGO/scripts/genDistance.sh $SUBJECT $TMP_DIR nasm
cd $FUZZ_DIR; CFLAGS="-distance=$TMP_DIR/distance.cfg.txt" CXXFLAGS="-distance=$TMP_DIR/distance.cfg.txt" ../configure --prefix=`pwd`
make clean; make
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/nasm -f bin @@ -o /dev/null
elif [ $1 = "aflgob" ] || [ $1 = "heb" ] || [ $1 = "uafuzz" ]; then
cp $SUBJECT/obj/nasm $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 -f bin @@ -o /dev/null" -I $runmode -T "$FUZZ_DIR/$PUT.tgt" -to $timeout
fi