-
Notifications
You must be signed in to change notification settings - Fork 59
/
check-error
executable file
·181 lines (180 loc) · 4.44 KB
/
check-error
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
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
#!/bin/sh
# The IKE Scanner (ike-scan) is Copyright (C) 2003-2007 Roy Hills,
# NTA Monitor Ltd.
#
# This file is part of ike-scan.
#
# ike-scan is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# ike-scan is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with ike-scan. If not, see <http://www.gnu.org/licenses/>.
#
# check-error -- Shell script to test ike-scan response to errors
#
# Author: Roy Hills
# Date: 8 June 2007
#
# This script checks various ike-scan errors.
#
TMPFILE=/tmp/ike-scan-test.$$.tmp
#
echo "Checking ike-scan --vendor odd hex data ..."
IKEARGS="--sport=0 --retry=1 --nodns --vendor=deadbee"
./ike-scan $IKEARGS 127.0.0.1 >$TMPFILE 2>&1
if test $? -eq 0; then
rm -f $TMPFILE
echo "FAILED"
exit 1
fi
grep '^ERROR: Length of --vendor argument must be even (multiple of 2)' $TMPFILE >/dev/null
if test $? -ne 0; then
rm -f $TMPFILE
echo "FAILED"
exit 1
fi
echo "ok"
rm -f $TMPFILE
#
echo "Checking ike-scan --gssid odd hex data ..."
IKEARGS="--sport=0 --retry=1 --nodns --gssid=deadbee"
./ike-scan $IKEARGS 127.0.0.1 >$TMPFILE 2>&1
if test $? -eq 0; then
rm -f $TMPFILE
echo "FAILED"
exit 1
fi
grep '^ERROR: Length of --gssid argument must be even (multiple of 2)' $TMPFILE >/dev/null
if test $? -ne 0; then
rm -f $TMPFILE
echo "FAILED"
exit 1
fi
echo "ok"
rm -f $TMPFILE
#
echo "Checking ike-scan --certreq odd hex data ..."
IKEARGS="--sport=0 --retry=1 --nodns --certreq=deadbee"
./ike-scan $IKEARGS 127.0.0.1 >$TMPFILE 2>&1
if test $? -eq 0; then
rm -f $TMPFILE
echo "FAILED"
exit 1
fi
grep '^ERROR: Length of --certreq argument must be even (multiple of 2)' $TMPFILE >/dev/null
if test $? -ne 0; then
rm -f $TMPFILE
echo "FAILED"
exit 1
fi
echo "ok"
rm -f $TMPFILE
#
echo "Checking ike-scan --cookie odd hex data ..."
IKEARGS="--sport=0 --retry=1 --nodns --cookie=deadbee"
./ike-scan $IKEARGS 127.0.0.1 >$TMPFILE 2>&1
if test $? -eq 0; then
rm -f $TMPFILE
echo "FAILED"
exit 1
fi
grep '^ERROR: Length of --cookie argument must be even (multiple of 2)' $TMPFILE >/dev/null
if test $? -ne 0; then
rm -f $TMPFILE
echo "FAILED"
exit 1
fi
echo "ok"
rm -f $TMPFILE
#
echo "Checking ike-scan --rcookie odd hex data ..."
IKEARGS="--sport=0 --retry=1 --nodns --rcookie=deadbee"
./ike-scan $IKEARGS 127.0.0.1 >$TMPFILE 2>&1
if test $? -eq 0; then
rm -f $TMPFILE
echo "FAILED"
exit 1
fi
grep '^ERROR: Length of --rcookie argument must be even (multiple of 2)' $TMPFILE >/dev/null
if test $? -ne 0; then
rm -f $TMPFILE
echo "FAILED"
exit 1
fi
echo "ok"
rm -f $TMPFILE
#
echo "Checking ike-scan invalid option ..."
IKEARGS="--sport=0 --retry=1 --nodns --invalidoption"
./ike-scan $IKEARGS 127.0.0.1 >$TMPFILE 2>&1
if test $? -eq 0; then
rm -f $TMPFILE
echo "FAILED"
exit 1
fi
grep '^Usage: ike-scan ' $TMPFILE >/dev/null
if test $? -ne 0; then
rm -f $TMPFILE
echo "FAILED"
exit 1
fi
echo "ok"
rm -f $TMPFILE
#
echo "Checking ike-scan invalid --sourceip value ..."
IKEARGS="--sport=0 --retry=1 --nodns --sourceip=invalidipaddress"
./ike-scan $IKEARGS 127.0.0.1 >$TMPFILE 2>&1
if test $? -eq 0; then
rm -f $TMPFILE
echo "FAILED"
exit 1
fi
grep '^ERROR: invalidipaddress is not a valid IP address' $TMPFILE >/dev/null
if test $? -ne 0; then
rm -f $TMPFILE
echo "FAILED"
exit 1
fi
echo "ok"
rm -f $TMPFILE
#
echo "Checking ike-scan invalid target address ..."
IKEARGS="--sport=0 --retry=1 --nodns"
./ike-scan $IKEARGS invalidipaddress >$TMPFILE 2>&1
if test $? -eq 0; then
rm -f $TMPFILE
echo "FAILED"
exit 1
fi
grep '^ERROR: No hosts to process' $TMPFILE >/dev/null
if test $? -ne 0; then
rm -f $TMPFILE
echo "FAILED"
exit 1
fi
echo "ok"
rm -f $TMPFILE
#
echo "Checking ike-scan non-existant target filename ..."
IKEARGS="--sport=0 --retry=1 --nodns"
./ike-scan $IKEARGS --file=ike-scan-no-such-file >$TMPFILE 2>&1
if test $? -eq 0; then
rm -f $TMPFILE
echo "FAILED"
exit 1
fi
grep '^ERROR: fopen: No such file or directory' $TMPFILE >/dev/null
if test $? -ne 0; then
rm -f $TMPFILE
echo "FAILED"
exit 1
fi
echo "ok"
rm -f $TMPFILE