File: check-packet

package info (click to toggle)
ike-scan 1.9.4-2
  • links: PTS
  • area: main
  • in suites: buster
  • size: 5,104 kB
  • sloc: ansic: 10,991; sh: 884; perl: 148; makefile: 22
file content (143 lines) | stat: -rwxr-xr-x 4,705 bytes parent folder | download | duplicates (3)
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
#!/bin/sh
# The IKE Scanner (ike-scan) is Copyright (C) 2003-2007 Roy Hills,
# NTA Monitor Ltd.
#
# This program 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 2
# of the License, or (at your option) any later version.
#
# This program 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 this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
#
# $Id$
#
# check-packet -- Shell script to test ike-scan packet data
#
# Author: Roy Hills
# Date: 25 November 2005
#
# This script checks that ike-scan builds the correct ISAKMP packets.
# It uses the undocumented ike-scan option --writepkttofile to write the
# packet to a file rather than sending it via the network.
#
# It tries to use as many options as possible, in order to gain the maximum
# code coverage.  For this reason, some of the option combinations may appear
# strange.
#
TMPFILE=/tmp/ike-scan-test.$$.tmp
#
SAMPLE01="$srcdir/pkt-default-proposal.dat"
SAMPLE02="$srcdir/pkt-custom-proposal.dat"
SAMPLE03="$srcdir/pkt-aggressive.dat"
SAMPLE04="$srcdir/pkt-malformed.dat"
SAMPLE05="$srcdir/pkt-ikev2.dat"
SAMPLE06="$srcdir/pkt-single-trans.dat"
#
echo "Checking ike-scan default packet against $SAMPLE01 ..."
IKEARGS="--sport=0 --retry=1 --nodns --cookie=deadbeefdeadbeef --file=- --timeout=100 --interval=50 --quiet --timestamp --shownum --backoff=2.0"
echo "127.0.0.1" | $srcdir/ike-scan $IKEARGS --writepkttofile=$TMPFILE >/dev/null 2>&1
if test $? -ne 0; then
   rm -f $TMPFILE
   echo "FAILED"
   exit 1
fi
cmp -s $TMPFILE $SAMPLE01
if test $? -ne 0; then
   rm -f $TMPFILE
   echo "FAILED"
   exit 1
fi
echo "ok"
rm -f $TMPFILE
#
echo "Checking ike-scan custom packet (adv trans) against $SAMPLE02 ..."
IKEARGS="--sport=0 --retry=1 --nodns --cookie=deadbeefdeadbeef --mbz=255 --trans=(1=1,2=1,3=1,4=1) --trans=(1=7,14=128,2=1,3=3,4=5) --trans=(1=5,2=2,3=3,4=2,11=1,12=0x00007080,11=2,12=0x00100000) --vendor=deadbeef --vendor=00010203 --bandwidth=64K"
$srcdir/ike-scan $IKEARGS --writepkttofile=$TMPFILE 127.0.0.1 >/dev/null 2>&1
if test $? -ne 0; then
   rm -f $TMPFILE
   echo "FAILED"
   exit 1
fi
cmp -s $TMPFILE $SAMPLE02
if test $? -ne 0; then
   rm -f $TMPFILE
   echo "FAILED"
   exit 1
fi
echo "ok"
rm -f $TMPFILE
#
echo "Checking ike-scan aggressive mode packet against $SAMPLE03 ..."
IKEARGS="--sport=0 --retry=1 --nodns --cookie=deadbeefdeadbeef --randomseed=1234 --aggressive --id=royhills@hotmail.com --idtype=3 --dhgroup=2 --noncelen=20"
$srcdir/ike-scan $IKEARGS --writepkttofile=$TMPFILE 127.0.0.1 >/dev/null 2>&1
if test $? -ne 0; then
   rm -f $TMPFILE
   echo "FAILED"
   exit 1
fi
cmp -s $TMPFILE $SAMPLE03
if test $? -ne 0; then
   rm -f $TMPFILE
   echo "FAILED"
   exit 1
fi
echo "ok"
rm -f $TMPFILE
#
echo "Checking ike-scan malformed packet against $SAMPLE04 ..."
IKEARGS="--sport=0 --retry=1 --nodns --cookie=deadbeefdeadbeef --randomseed=1234 --multiline --lifetime=32 --lifesize=64 --auth=3 --gssid=deadbeef --headerlen=+10 --headerver=0x32  --certreq=203040 --doi=2 --situation=3 --protocol=4 --transid=5 --spisize=4 --hdrflags=127 --hdrmsgid=1234 --exchange=6 --nextpayload=57 --rcookie=deadbeefdeadbeef"
$srcdir/ike-scan $IKEARGS --writepkttofile=$TMPFILE 127.0.0.1 >/dev/null 2>&1
if test $? -ne 0; then
   rm -f $TMPFILE
   echo "FAILED"
   exit 1
fi
cmp -s $TMPFILE $SAMPLE04
if test $? -ne 0; then
   rm -f $TMPFILE
   echo "FAILED"
   exit 1
fi
echo "ok"
rm -f $TMPFILE
#
echo "Checking ike-scan IKEv2 packet against $SAMPLE05 ..."
IKEARGS="--sport=0 --retry=1 --nodns --cookie=deadbeefdeadbeef --randomseed=1234 --ikev2"
$srcdir/ike-scan $IKEARGS --writepkttofile=$TMPFILE 127.0.0.1 >/dev/null 2>&1
if test $? -ne 0; then
   rm -f $TMPFILE
   echo "FAILED"
   exit 1
fi
cmp -s $TMPFILE $SAMPLE05
if test $? -ne 0; then
   rm -f $TMPFILE
   echo "FAILED"
   exit 1
fi
echo "ok"
rm -f $TMPFILE
#
echo "Checking ike-scan single trans packet against $SAMPLE06 ..."
IKEARGS="--sport=0 --retry=1 --nodns --cookie=deadbeefdeadbeef --lifetime=none --lifesize=none --trans=5,2,3,2"
$srcdir/ike-scan $IKEARGS --writepkttofile=$TMPFILE 127.0.0.1 >/dev/null 2>&1
if test $? -ne 0; then
   rm -f $TMPFILE
   echo "FAILED"
   exit 1
fi
cmp -s $TMPFILE $SAMPLE06
if test $? -ne 0; then
   rm -f $TMPFILE
   echo "FAILED"
   exit 1
fi
echo "ok"
rm -f $TMPFILE