| 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 |
# Author: Roy Hills |
| 21 |
# Date: 19 November 2004 |
| 22 |
# |
| 23 |
# This shell script checks that psk-crack works for MD5 and SHA1 based |
| 24 |
# hashes. |
| 25 |
# |
| 26 |
TMPFILE=/tmp/ike-scan-test.$$.tmp |
| 27 |
MD5PSK=/tmp/md5-psk.$$.tmp |
| 28 |
SHA1PSK=/tmp/sha1-psk.$$.tmp |
| 29 |
DICTFILE=/tmp/ike-dict-file.$$.tmp |
| 30 |
|
| 31 |
# Create PSK parameter files with known pre-shared keys. |
| 32 |
# These parameters were generated using ike-scan 1.6.4 and Checkpoint |
| 33 |
# Firewall-1 NG AI R54. In both cases, the pre-shared key is "abc123" |
| 34 |
echo "5c7916ddf8db4d233b3b36005bb3ccc115a73807e11a897be943fd4a2d0f942624cb00588d8b3a0a26502b73e639df217ef6c4cb90f96b0a3c3ef2f62ed025b4a705df9de65e33e380c1ba5fa23bf1f9911bbf388d0844256fa0131fc5cf8acb396936ba3295b4637b039d93f58db90a3a1cf1ef5051103bacf6e1a3334f9f89:fde8c68c5f324c7dbcbadde1d757af6962c63496c009f77cad647f2997fd4295e50821453a6dc2f6279fd7fef68768584d9cee0da6e68a534a097ce206bf77ecc798310206f3f82d92d02c885794e0a430ceb2d6b43c2aff45a6e14c6558382df0692ff65c2724eef750764ee456f31424a5ebd9e115d826bbb9722111aa4e01:b2a3c7aa4be95e85:756e3fa11c1b102c:00000001000000010000002c01010001000000240101000080010001800200018003000180040002800b0001000c000400007080:01000000ac100202:251d7ace920b17cb34f9d561bca46d037b337d19:e045819a64edbf022620bff3efdb935216584cc4:b9c594fa3fca6bb30a85c4208a8df348" > $MD5PSK |
| 35 |
echo "9bdee7aa341cf1a6c19bc0191106b5056537ce6b837cd70678ea5a3ccb606b56dee4548feb67f24fd6f4d5f58967a9ff3c674d9d79e4195b7def5aac147c9fe9abdc2f8ba2eca58f4c863fedc7a8c8e1ad6e1551b1e44bf9a0e258561a5db1c2ca1e8b5dfda1b012012b6fdf24ecd07da6b10d76ab3b58d07b30b4f9da26aee4:c9b7ef0610a22b3e1c88b1a01ce4d4110edf6baa122ed1285eb2184cd75d30a11520a725c2d263de5a157f77f953880732f3b14521836d7f3585cb0ce3fcadf81c541dde2680bd81953cf88e8f8096c173470694ca7414fff9df0cdcdbb9d4f70ef1d6347293b507cfad965e2d2c1fa07326353e9a493d93284970040344fb11:3506592130312567:6c362583ce7a2a26:00000001000000010000002c01010001000000240101000080010001800200028003000180040002800b0001000c000400007080:01000000ac100202:84943233f42a0b5a9b33c327162fe0efee2545e4:76f451dce3fea6402b67f3fddae561ebdb4a6efe:f63f237b3c0f1fe57a5b852203cfd27cbf0c78d4" > $SHA1PSK |
| 36 |
# |
| 37 |
# Create dictionary file |
| 38 |
echo "notthisone" > $DICTFILE |
| 39 |
echo "NotThisOne" >> $DICTFILE |
| 40 |
echo "NextOne" >> $DICTFILE |
| 41 |
echo "abc123" >> $DICTFILE |
| 42 |
echo "xyz123" >> $DICTFILE |
| 43 |
# |
| 44 |
echo "Checking psk-crack bruteforce with MD5 hash ..." |
| 45 |
$srcdir/psk-crack --bruteforce=6 --charset=abc123 $MD5PSK >$TMPFILE |
| 46 |
if test $? -ne 0; then |
| 47 |
rm -f $TMPFILE |
| 48 |
rm -f $DICTFILE |
| 49 |
rm -f $MD5PSK |
| 50 |
rm -f $SHA1PSK |
| 51 |
echo "FAILED" |
| 52 |
exit 1 |
| 53 |
fi |
| 54 |
grep '^key "abc123" matches MD5 hash ' $TMPFILE >/dev/null |
| 55 |
if test $? -ne 0; then |
| 56 |
rm -f $TMPFILE |
| 57 |
rm -f $DICTFILE |
| 58 |
rm -f $MD5PSK |
| 59 |
rm -f $SHA1PSK |
| 60 |
echo "FAILED" |
| 61 |
exit 1 |
| 62 |
fi |
| 63 |
echo "ok" |
| 64 |
# |
| 65 |
echo "Checking psk-crack bruteforce with SHA1 hash ..." |
| 66 |
$srcdir/psk-crack --bruteforce=6 --charset=abc123 $SHA1PSK > $TMPFILE |
| 67 |
if test $? -ne 0; then |
| 68 |
rm -f $TMPFILE |
| 69 |
rm -f $DICTFILE |
| 70 |
rm -f $MD5PSK |
| 71 |
rm -f $SHA1PSK |
| 72 |
echo "FAILED" |
| 73 |
exit 1 |
| 74 |
fi |
| 75 |
grep '^key "abc123" matches SHA1 hash ' $TMPFILE >/dev/null |
| 76 |
if test $? -ne 0; then |
| 77 |
rm -f $TMPFILE |
| 78 |
rm -f $DICTFILE |
| 79 |
rm -f $MD5PSK |
| 80 |
rm -f $SHA1PSK |
| 81 |
echo "FAILED" |
| 82 |
exit 1 |
| 83 |
fi |
| 84 |
echo "ok" |
| 85 |
# |
| 86 |
echo "Checking psk-crack dictionary with MD5 hash ..." |
| 87 |
$srcdir/psk-crack --dictionary=$DICTFILE $MD5PSK >$TMPFILE |
| 88 |
if test $? -ne 0; then |
| 89 |
rm -f $TMPFILE |
| 90 |
rm -f $DICTFILE |
| 91 |
rm -f $MD5PSK |
| 92 |
rm -f $SHA1PSK |
| 93 |
echo "FAILED" |
| 94 |
exit 1 |
| 95 |
fi |
| 96 |
grep '^key "abc123" matches MD5 hash ' $TMPFILE >/dev/null |
| 97 |
if test $? -ne 0; then |
| 98 |
rm -f $TMPFILE |
| 99 |
rm -f $DICTFILE |
| 100 |
rm -f $MD5PSK |
| 101 |
rm -f $SHA1PSK |
| 102 |
echo "FAILED" |
| 103 |
exit 1 |
| 104 |
fi |
| 105 |
echo "ok" |
| 106 |
# |
| 107 |
echo "Checking psk-crack dictionary with SHA1 hash ..." |
| 108 |
$srcdir/psk-crack --dictionary=$DICTFILE $SHA1PSK > $TMPFILE |
| 109 |
if test $? -ne 0; then |
| 110 |
rm -f $TMPFILE |
| 111 |
rm -f $DICTFILE |
| 112 |
rm -f $MD5PSK |
| 113 |
rm -f $SHA1PSK |
| 114 |
echo "FAILED" |
| 115 |
exit 1 |
| 116 |
fi |
| 117 |
grep '^key "abc123" matches SHA1 hash ' $TMPFILE >/dev/null |
| 118 |
if test $? -ne 0; then |
| 119 |
rm -f $TMPFILE |
| 120 |
rm -f $DICTFILE |
| 121 |
rm -f $MD5PSK |
| 122 |
rm -f $SHA1PSK |
| 123 |
echo "FAILED" |
| 124 |
exit 1 |
| 125 |
fi |
| 126 |
echo "ok" |
| 127 |
# |
| 128 |
rm -f $TMPFILE |
| 129 |
rm -f $DICTFILE |
| 130 |
rm -f $MD5PSK |
| 131 |
rm -f $SHA1PSK |