-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathtest-sws.sh
97 lines (85 loc) · 1.41 KB
/
test-sws.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
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
#! /bin/sh
#
# curl --http1.0
SERVER="${1:?"Usage: $0 server port"}"
PORT="${2:?"Usage: $0 server port"}"
URIS="/cgi-bin/env.cgi
/cgi-bin/env.cgi?q=foo&food=bacon
/cgi-bin/post.cgi
/dir/file
/dir
/dir/
/dir/.
/dir2/
/file
/file2
/file space
/file>path
/file%%20space%%20%%3C%%20path%%20%%3E%%20name
/ls
/notallowed
no-leading-slash
/../../../../../../../../../etc/passwd
/dir/file/../../dir/file
/dir/./file
/~jschauma/
/~jschauma/oink
/~jschauma/d/f
/~nobody
/nowhere
/passwd
"
PROTOCOLS="
HTTP/0.9
HTTP/1.0
HTTP/1.0000
HTTP/1.1
HTTP/2.0
HTTP
HTTP/10000000000000000000000000000000000000000000000000000
BACON
BACON/3.2
"
REQUESTS="
GET
HEAD
POST
DELETE
BACON
"
protocols() {
for P in ${PROTOCOLS}; do
echo "=> GET / ${P}"
printf "GET / ${P}\r\n\r\n" | nc ${SERVER} ${PORT}
done
echo "=> GET /"
printf "GET /\r\n\r\n" | nc ${SERVER} ${PORT}
}
requests() {
for R in ${REQUESTS}; do
echo "=> ${R} / HTTP/1.0"
printf "${R} / HTTP/1.0\r\n\r\n" | nc ${SERVER} ${PORT}
done
echo "=> / HTTP/1.0"
printf " / HTTP/1.0\r\n\r\n" | nc ${SERVER} ${PORT}
}
uris() {
IFS='
'
for U in ${URIS}; do
echo "=> GET '${U}' HTTP/1.0"
printf "GET ${U} HTTP/1.0\r\n\r\n" | nc ${SERVER} ${PORT}
done
echo "=> GET HTTP/1.0"
printf "GET HTTP/1.0\r\n\r\n" | nc ${SERVER} ${PORT}
}
cleanup() {
pkill telnet
}
trap 'cleanup' 0
protocols
requests
uris
pid=$$
( sleep 300; kill -s ALRM $pid ) &
telnet ${SERVER} ${PORT} >/dev/null