blob: c3df08c97a2fca2afa11370a357a8e21f47be7d0 (
plain) (
blame)
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
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
|
#!/bin/bash
ipstr="$1"
SCRIPTPATH="$(dirname $(readlink -f "$0"))"
cd "$SCRIPTPATH"
export REVHASH_PATH="$SCRIPTPATH/src/revhash/revhash"
nop() { :; }
splitmsg() {
python3 -c "
import json,sys
try:
instr = sys.stdin.read().strip()
jres = json.loads(instr)
print(jres['result'])
print(jres['message'])
except:
print('INVALID')
print('INVALID')
print('FAIL:', instr, file=sys.stderr)
" || nop
}
try() {
cmd="$1"
pid=$BASHPID
tmpfile="/tmp/checker-log-$pid"
[ -e "$tmpfile" ] && rm "$tmpfile"
if [ $# -lt 2 ]; then
variant=0
else
variant=$2
fi
taskid=$pid
if [ ! -z "$REMOTE" ]; then
python3 enoreq.py -j True -A http://localhost:9091 -a $REMOTE \
--flag ENOTESTFLAG123= --flag_regex 'ENO.*=' -i $taskid \
-v "$variant" -x 4000 ${@:3} "$cmd" > "$tmpfile"
res="$(cat $tmpfile | splitmsg | head -n1)"
else
python3 src/checker.py -j run -v "$variant" -x 4000 \
--flag ENOTESTFLAG123= --flag_regex 'ENO.*=' -i $taskid \
${@:3} "$cmd" > "$tmpfile"
res="$(cat $tmpfile | grep -a Result: | tail -n1 | grep -a -o OK)"
fi
if [ "$res" != "OK" ]; then
newfile="fails/err-$pid"
(
echo "METHOD $@"
echo "RESULT $res"
echo "TASK $taskid"
cat "$tmpfile"
if [ ! -z "$REMOTE" -a -e "$ENOLOGMESSAGE_PARSER" ]; then
docker-compose logs --tail=2000 | grep '"taskId": '$taskid | $ENOLOGMESSAGE_PARSER
fi
) > "$newfile"
fi
echo -ne "Executing $cmd with variant $variant.. $res (TASK: $taskid)\n"
}
try-all() {
try putflag 0
try getflag 0
try putflag 1
try getflag 1
try putnoise 0
try getnoise 0
try putflag 1
try getflag 1
try havoc 0
try havoc 1
try havoc 2
try havoc 3
try exploit 0
try exploit 1
}
one-of() {
for arg in ${@:2}; do
[ "$1" == "$arg" ] && return 0
done
return 1
}
if one-of "$1" putflag getflag putnoise getnoise havoc exploit; then
try $@
elif [ "$1" == "test-exploits" ]; then
try exploit 0
try exploit 1
elif [ "$1" == "stress-test" ]; then
mkdir -p fails
count=${2:-100}
for i in $(seq $count); do
try ${3:-exploit} ${4:-0} &
done
else
try-all
fi
exit 0
|