forked from ise-uiuc/KernelGPT
-
Notifications
You must be signed in to change notification settings - Fork 0
/
syzkaller.sh
executable file
·54 lines (46 loc) · 1.18 KB
/
syzkaller.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
#!/usr/bin/bash
root=$(readlink -f $0 | xargs realpath | xargs dirname)
name=${1:-syz-manager}
corpus=${2:-corpus.db}
syz=${3:-"$root/syzkaller"}
linux=${4:-"$root/linux"}
image=${5:-"$root/image"}
config=${6:-"$root/template.cfg"}
port=${7:-$(python3 $root/get-port.py)}
fname="$name-$(date +%s)"
wkd="workdir-$fname"
mkdir -p $wkd
[[ -e $corpus ]] && cp $corpus $wkd/corpus.db
cat $config \
| sed "s|__LINUX__|$linux|g" \
| sed "s|__IMAGE__|$image|g" \
| sed "s|__PORT__|$port|g" \
| sed "s|__WKD__|$wkd|g" \
| sed "s|__SYZKALLER__|$syz|g" \
> $wkd/test.cfg
echo $port > $wkd/port.txt
echo $$ > $wkd/pid.txt
mkdir -p $wkd/cov
function get_cov() {
local wkd=$1
local port=$2
local counter=0
while true; do
fname="$wkd/cov/rawcover-$(date +%s)"
wget http://localhost:$port/rawcover -O $fname
if [ $? -ne 0 ]; then
((counter++))
rm -f $fname
else
counter=0
fi
if [ $counter -gt 8 ]; then
break
fi
sleep 60
done
}
get_cov $wkd $port &
PID=$!
echo $PID > $wkd/rawcover-pid.txt
"$syz/bin/syz-manager" -config=$wkd/test.cfg |& tee $wkd/$fname.log