Debian Codegraph @

check-psk-crack-3

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-psk-crack-3 -- Shell script to test psk-crack for Nortel style hashes
21 #
22 # Author: Roy Hills
23 # Date: 19 November 2004
24 #
25 # This shell script checks that psk-crack works for Nortel Contivity MD5 and
26 # SHA1 based hashes. The Nortel contivity VPN client uses a proprietary
27 # authentication mechanism, based on Mamro's Pre-Shared Key Extensions for
28 # ISAKMP/Oakley.
29 #
30 TMPFILE=/tmp/ike-scan-test.$$.tmp
31 MD5PSK=/tmp/nortel-md5-psk.$$.tmp
32 SHA1PSK=/tmp/nortel-sha1-psk.$$.tmp
33 DICTFILE=/tmp/ike-dict-file.$$.tmp
34
35 # Create PSK parameter files with known pre-shared keys.
36 # These parameters were generated using ike-scan 1.8.4 and Nortel Contivity
37 # server software v6.00.310. In both cases, the username is "test", and the
38 # pre-shared key is "abc123"
39 echo "d629dabe8c05c518767cc19826f27f30769dee778143e0f7625647058f9e9788c67f32fc8fcdb40b1dc59c91b8001554bcf795b6e69562f7dfd1c16760a13e7abe22e9af399c4500e66f72287f0b943dcf20d2d7f0edd5dc7a7d8d94928b46e9:fc831092e3b20a9f9213dbed92adb7f52b6527b94ea563a25659f610b70d1a2e2c196d5c288ed235ab155e5ba5355d65d64ea3e56b98ee117d73c47d3648085a93a8331be5579df466a6b67a005fae9bdd38c090791df9b6ef6314bb9efdf13e:5bb290ba45868004:bcc589f4ac89e296:000000010000000100000024010100010000001c0101000080010001800200018003000180040001ffff001a:01000000c0a87c98:044010b3e3f3231853c86b242bd64a12e9d8449e:852dea148d592231ed90b386c8dabe7f97fd270b:1774127c7adf7bf24ce777a632d21679" > $MD5PSK
40 echo "5f05e0324d421068c9d4a451ca6a6857762414dbdba9a15dab352f15aba604ced62cf32e87e36353f040691ef9b9fcd1b16379b1644489bd7dc3ecd1f7cb7c419795e9fd92f20392ef11e844e8b55261a7e272b2bd18dd3cdf9975f19ffdc47d:5dc25f869238b9b74c9fdec9447a16d1fb782be82c170587a02e303d37a848819488868a0795094532123446450a61b761ee24e783e799a66322e7e9337c8630a10621e5beb5d780fac715931a933d548e1c3f0c1ccf2bbe1bbd040c17fb03c2:945420d37bbe1d5b:4c101f369a221302:000000010000000100000024010100010000001c0101000080010001800200028003000180040001ffff001a:01000000c0a87c98:92a836a290f70df19959f6ab9e50a3e52b40ba88:dc17a196d52d3ce0527dd53eb534951dc48de290:3a60067bfb3db5118702dde8f2eb7c3860ff6f75" > $SHA1PSK
41 #
42 # Create dictionary file
43 echo "notthisone" > $DICTFILE
44 echo "NotThisOne" >> $DICTFILE
45 echo "NextOne" >> $DICTFILE
46 echo "abc123" >> $DICTFILE
47 echo "xyz123" >> $DICTFILE
48 #
49 echo "Checking psk-crack bruteforce with Nortel Contivity MD5 hash ..."
50 $srcdir/psk-crack --norteluser=test --bruteforce=6 --charset=abc123 $MD5PSK >$TMPFILE
51 if test $? -ne 0; then
52 rm -f $TMPFILE
53 rm -f $DICTFILE
54 rm -f $MD5PSK
55 rm -f $SHA1PSK
56 echo "FAILED"
57 exit 1
58 fi
59 grep '^key "abc123" matches MD5 hash ' $TMPFILE >/dev/null
60 if test $? -ne 0; then
61 rm -f $TMPFILE
62 rm -f $DICTFILE
63 rm -f $MD5PSK
64 rm -f $SHA1PSK
65 echo "FAILED"
66 exit 1
67 fi
68 echo "ok"
69 #
70 echo "Checking psk-crack bruteforce with Nortel Contivity SHA1 hash ..."
71 $srcdir/psk-crack --norteluser=test --bruteforce=6 --charset=abc123 $SHA1PSK > $TMPFILE
72 if test $? -ne 0; then
73 rm -f $TMPFILE
74 rm -f $DICTFILE
75 rm -f $MD5PSK
76 rm -f $SHA1PSK
77 echo "FAILED"
78 exit 1
79 fi
80 grep '^key "abc123" matches SHA1 hash ' $TMPFILE >/dev/null
81 if test $? -ne 0; then
82 rm -f $TMPFILE
83 rm -f $DICTFILE
84 rm -f $MD5PSK
85 rm -f $SHA1PSK
86 echo "FAILED"
87 exit 1
88 fi
89 echo "ok"
90 #
91 echo "Checking psk-crack dictionary with Nortel Contivity MD5 hash ..."
92 $srcdir/psk-crack --norteluser=test --dictionary=$DICTFILE $MD5PSK >$TMPFILE
93 if test $? -ne 0; then
94 rm -f $TMPFILE
95 rm -f $DICTFILE
96 rm -f $MD5PSK
97 rm -f $SHA1PSK
98 echo "FAILED"
99 exit 1
100 fi
101 grep '^key "abc123" matches MD5 hash ' $TMPFILE >/dev/null
102 if test $? -ne 0; then
103 rm -f $TMPFILE
104 rm -f $DICTFILE
105 rm -f $MD5PSK
106 rm -f $SHA1PSK
107 echo "FAILED"
108 exit 1
109 fi
110 echo "ok"
111 #
112 echo "Checking psk-crack dictionary with Nortel Contivity SHA1 hash ..."
113 $srcdir/psk-crack --norteluser=test --dictionary=$DICTFILE $SHA1PSK > $TMPFILE
114 if test $? -ne 0; then
115 rm -f $TMPFILE
116 rm -f $DICTFILE
117 rm -f $MD5PSK
118 rm -f $SHA1PSK
119 echo "FAILED"
120 exit 1
121 fi
122 grep '^key "abc123" matches SHA1 hash ' $TMPFILE >/dev/null
123 if test $? -ne 0; then
124 rm -f $TMPFILE
125 rm -f $DICTFILE
126 rm -f $MD5PSK
127 rm -f $SHA1PSK
128 echo "FAILED"
129 exit 1
130 fi
131 echo "ok"
132 #
133 rm -f $TMPFILE
134 rm -f $DICTFILE
135 rm -f $MD5PSK
136 rm -f $SHA1PSK