-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathinstrfuzz.sh
executable file
·59 lines (44 loc) · 1.17 KB
/
instrfuzz.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
#!/bin/bash
echo "Assembling fuzzing core"
if ! command -v "nasm" &> /dev/null; then
echo "nasm is not in \$PATH"
exit 1
fi
nasm -f bin -o instrfuzz.img instrfuzz.asm
if [ ! -f instrfuzz.img ]; then
echo "instrfuzz.img does not exist"
exit 1
fi
echo "Assembled fuzzing core"
echo "Beginning test iterations"
if [ -z "${TIMEOUT}" ]; then
TIMEOUT=60
fi
echo "Iteration Execution time should be less than ${TIMEOUT} seconds"
QEMU="qemu-system-i386"
if ! command -v "${QEMU}" &> /dev/null; then
echo "${QEMU} is not in \$PATH"
exit 1
fi
if [ ! -z "$ACCELERATION" ]; then
echo "Using -ACCELERATION: ${ACCELERATION}"
else
ACCELERATION=""
fi
while :
do
OUTDATE=$(date +'%Y%m%d%H%M%S')
START=$(date +'%s')
OUTPUT=$(timeout --foreground ${TIMEOUT} "${QEMU}" -boot a -fda instrfuzz.img ${ACCELERATION} -nographic > "/tmp/${OUTDATE}.tmp" 2> /dev/null)
QEMU_SIG="$?"
END=$(date +'%s')
LEN=$((END-START))
if [ "$QEMU_SIG" -ne 124 ] || [ $TIMEOUT -gt "$LEN" ]; then
echo 'Abnormal Signal Detected!'
mv "/tmp/${OUTDATE}.tmp" "instrfuzz-${OUTDATE}.log"
else
echo "Ending Iteration: $(date)"
echo "Execution time in seconds: ${LEN}"
fi
rm "/tmp/${OUTDATE}.tmp"
done