-
Notifications
You must be signed in to change notification settings - Fork 9
/
Copy pathshell_frontend.sh
executable file
·67 lines (56 loc) · 1.42 KB
/
shell_frontend.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
63
64
65
66
67
#!/bin/sh
# Minimal shell replacement for the Python front-end, for cases where
# Python or curses is not available.
#
# Usage:
# PROCS=n START=n END=n ./shell_frontend.sh <fuzzer_args>
#
# NB: Don't use the -s and -e options to set the search range.
quit() {
echo "Aborting"
killall -9 fuzzer
echo
exit 0
}
trap quit 2 # SIGINT
if [ ! -e "fuzzer" ]; then
echo "Could not find fuzzer binary. Has it been compiled?"
exit 1
fi
if [ "$PROCS" = "" ]; then
procs=$(nproc)
else
procs=$PROCS
fi
if [ "$START" = "" ]; then
range_start=0
else
range_start=$((0x$START))
fi
if [ "$END" = "" ]; then
range_end=$((0xffffffff))
else
range_end=$((0x$END))
fi
range_size=$(($(($range_end - $range_start + 1)) / $procs))
for i in $(seq 0 1 $(($procs-1))); do
s=$(printf '%08x' $(($range_start + $(($range_size * $i)))))
e=$(printf '%08x' $(($range_start + $(($range_size * $(($i+1)))) - 1)))
./fuzzer -l $i -s $s -e $e $* > "data/out$i" 2>&1 &
done
while [ $(pgrep fuzzer | wc -l) -gt 0 ]; do
out=""
for i in $(seq 0 1 $(($procs-1))); do
file="data/out$i"
status_line=$(cat "$file" | tr '\r' '\n' | tail -n1)
truncate -s 0 "$file"
echo "$status_line" > "$file"
out="${out}${status_line}\n"
done
# Output the whole buffer at once to avoid visible delay
# between updating lines
clear
/bin/echo -e "$out"
sleep 1
done
echo "Done"