Debian Codegraph @

check-error

raw
1 #!/bin/sh
2 # The IKE Scanner (ike-scan) is Copyright (C) 2003-2007 Roy Hills,
3 # NTA Monitor Ltd.
4 #
5 # This file is part of ike-scan.
6 #
7 # ike-scan is free software: you can redistribute it and/or modify
8 # it under the terms of the GNU General Public License as published by
9 # the Free Software Foundation, either version 3 of the License, or
10 # (at your option) any later version.
11 #
12 # ike-scan is distributed in the hope that it will be useful,
13 # but WITHOUT ANY WARRANTY; without even the implied warranty of
14 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 # GNU General Public License for more details.
16 #
17 # You should have received a copy of the GNU General Public License
18 # along with ike-scan. If not, see <http://www.gnu.org/licenses/>.
19 #
20 # check-error -- Shell script to test ike-scan response to errors
21 #
22 # Author: Roy Hills
23 # Date: 8 June 2007
24 #
25 # This script checks various ike-scan errors.
26 #
27 TMPFILE=/tmp/ike-scan-test.$$.tmp
28 #
29 echo "Checking ike-scan --vendor odd hex data ..."
30 IKEARGS="--sport=0 --retry=1 --nodns --vendor=deadbee"
31 $srcdir/ike-scan $IKEARGS 127.0.0.1 >$TMPFILE 2>&1
32 if test $? -eq 0; then
33 rm -f $TMPFILE
34 echo "FAILED"
35 exit 1
36 fi
37 grep '^ERROR: Length of --vendor argument must be even (multiple of 2)' $TMPFILE >/dev/null
38 if test $? -ne 0; then
39 rm -f $TMPFILE
40 echo "FAILED"
41 exit 1
42 fi
43 echo "ok"
44 rm -f $TMPFILE
45 #
46 echo "Checking ike-scan --gssid odd hex data ..."
47 IKEARGS="--sport=0 --retry=1 --nodns --gssid=deadbee"
48 $srcdir/ike-scan $IKEARGS 127.0.0.1 >$TMPFILE 2>&1
49 if test $? -eq 0; then
50 rm -f $TMPFILE
51 echo "FAILED"
52 exit 1
53 fi
54 grep '^ERROR: Length of --gssid argument must be even (multiple of 2)' $TMPFILE >/dev/null
55 if test $? -ne 0; then
56 rm -f $TMPFILE
57 echo "FAILED"
58 exit 1
59 fi
60 echo "ok"
61 rm -f $TMPFILE
62 #
63 echo "Checking ike-scan --certreq odd hex data ..."
64 IKEARGS="--sport=0 --retry=1 --nodns --certreq=deadbee"
65 $srcdir/ike-scan $IKEARGS 127.0.0.1 >$TMPFILE 2>&1
66 if test $? -eq 0; then
67 rm -f $TMPFILE
68 echo "FAILED"
69 exit 1
70 fi
71 grep '^ERROR: Length of --certreq argument must be even (multiple of 2)' $TMPFILE >/dev/null
72 if test $? -ne 0; then
73 rm -f $TMPFILE
74 echo "FAILED"
75 exit 1
76 fi
77 echo "ok"
78 rm -f $TMPFILE
79 #
80 echo "Checking ike-scan --cookie odd hex data ..."
81 IKEARGS="--sport=0 --retry=1 --nodns --cookie=deadbee"
82 $srcdir/ike-scan $IKEARGS 127.0.0.1 >$TMPFILE 2>&1
83 if test $? -eq 0; then
84 rm -f $TMPFILE
85 echo "FAILED"
86 exit 1
87 fi
88 grep '^ERROR: Length of --cookie argument must be even (multiple of 2)' $TMPFILE >/dev/null
89 if test $? -ne 0; then
90 rm -f $TMPFILE
91 echo "FAILED"
92 exit 1
93 fi
94 echo "ok"
95 rm -f $TMPFILE
96 #
97 echo "Checking ike-scan --rcookie odd hex data ..."
98 IKEARGS="--sport=0 --retry=1 --nodns --rcookie=deadbee"
99 $srcdir/ike-scan $IKEARGS 127.0.0.1 >$TMPFILE 2>&1
100 if test $? -eq 0; then
101 rm -f $TMPFILE
102 echo "FAILED"
103 exit 1
104 fi
105 grep '^ERROR: Length of --rcookie argument must be even (multiple of 2)' $TMPFILE >/dev/null
106 if test $? -ne 0; then
107 rm -f $TMPFILE
108 echo "FAILED"
109 exit 1
110 fi
111 echo "ok"
112 rm -f $TMPFILE
113 #
114 echo "Checking ike-scan invalid option ..."
115 IKEARGS="--sport=0 --retry=1 --nodns --invalidoption"
116 $srcdir/ike-scan $IKEARGS 127.0.0.1 >$TMPFILE 2>&1
117 if test $? -eq 0; then
118 rm -f $TMPFILE
119 echo "FAILED"
120 exit 1
121 fi
122 grep 'ike-scan: unrecognized option ' $TMPFILE >/dev/null
123 if test $? -ne 0; then
124 rm -f $TMPFILE
125 echo "FAILED"
126 exit 1
127 fi
128 echo "ok"
129 rm -f $TMPFILE
130 #
131 echo "Checking ike-scan invalid --sourceip value ..."
132 IKEARGS="--sport=0 --retry=1 --nodns --sourceip=invalidipaddress"
133 $srcdir/ike-scan $IKEARGS 127.0.0.1 >$TMPFILE 2>&1
134 if test $? -eq 0; then
135 rm -f $TMPFILE
136 echo "FAILED"
137 exit 1
138 fi
139 grep '^ERROR: invalidipaddress is not a valid IP address' $TMPFILE >/dev/null
140 if test $? -ne 0; then
141 rm -f $TMPFILE
142 echo "FAILED"
143 exit 1
144 fi
145 echo "ok"
146 rm -f $TMPFILE
147 #
148 echo "Checking ike-scan invalid target address ..."
149 IKEARGS="--sport=0 --retry=1 --nodns"
150 $srcdir/ike-scan $IKEARGS invalidipaddress >$TMPFILE 2>&1
151 if test $? -eq 0; then
152 rm -f $TMPFILE
153 echo "FAILED"
154 exit 1
155 fi
156 grep '^ERROR: No hosts to process' $TMPFILE >/dev/null
157 if test $? -ne 0; then
158 rm -f $TMPFILE
159 echo "FAILED"
160 exit 1
161 fi
162 echo "ok"
163 rm -f $TMPFILE
164 #
165 echo "Checking ike-scan non-existant target filename ..."
166 IKEARGS="--sport=0 --retry=1 --nodns"
167 $srcdir/ike-scan $IKEARGS --file=ike-scan-no-such-file >$TMPFILE 2>&1
168 if test $? -eq 0; then
169 rm -f $TMPFILE
170 echo "FAILED"
171 exit 1
172 fi
173 grep '^ERROR: fopen: No such file or directory' $TMPFILE >/dev/null
174 if test $? -ne 0; then
175 rm -f $TMPFILE
176 echo "FAILED"
177 exit 1
178 fi
179 echo "ok"
180 rm -f $TMPFILE
181