-
Notifications
You must be signed in to change notification settings - Fork 19
/
Copy pathwash
executable file
·96 lines (85 loc) · 3.43 KB
/
wash
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
#!/bin/bash
# Here we have a Perl script that invokes grep in a background,
# Program checks every outputted mac - if it's inside excluded list ./myExcludedList.txt
# wash output is previously splitted to fragments by Perl split funtion (using space as a separator),
# first part of splitted string is a MAC address of every AP,
# grep command invoked by Perl that uses backticks looks like: grep "00:11:22:33:44:55" ./myExcludedList.txt 2>/dev/null
# tries to extract monitor name from the ifconfig output
WIRELESS_INTERFACE="wlan0";
getMonitorName(){
ifconfig | perl -lane '{ if(/^[^\s]*mon/){ $_ =~ s/\s+.*//; print $_; } }'
}
startMonitor(){
echoGreen "airmon-ng start $WIRELESS_INTERFACE" && airmon-ng start $WIRELESS_INTERFACE
}
stopMonitor() {
echoGreen "killall airodump-ng" && killall airodump-ng &>/dev/null;
echoGreen "killall aireplay-ng" && killall aireplay-ng &>/dev/null;
# if monitor was empty tries to get it
if [[ -z "$MONITOR_NAME" ]]; then
MONITOR_NAME=$(getMonitorName);
fi
# if monitor is still empty there's no need to stop it
if [[ ! -z "$MONITOR_NAME" ]]; then
echoGreen "airmon-ng stop $MONITOR_NAME" && airmon-ng stop $MONITOR_NAME;
echoGreen "airmon-ng stop $WIRELESS_INTERFACE" && airmon-ng stop $WIRELESS_INTERFACE;
echoGreen "airmon-ng check" && airmon-ng check;
fi
}
restartMonitor() {
stopMonitor;
startMonitor;
}
# echo green text
echoGreen(){
echo "$(tput setaf 2)>>>>>> ${1}$(tput sgr0)";
}
# echo blue text
echoBlue(){
echo "$(tput setaf 6)>>>>>> ${1}$(tput sgr0)";
}
getWifiCardDriver(){
lshw -c network | gawk '!/wireless/ || !/driver/{ next; } { while(++i<=NF){ if($i ~ /driver\=/){ sub("driver=","",$i); print $i; } } }';
}
resetWifiCard(){
local WIFI_DRIVER=$(getWifiCardDriver);
local RESET_CARD_DRIVER_CMD="";
if [[ -z "$WIFI_DRIVER" ]]; then
echoBlue "Sorry couldn't get your WifiDriver";
echoBlue "Check if any wifi card is connected and try again";
echoBlue "You may try to reconnect your wifi card to USB port, and try again.";
echoBlue "If above solutions doesn't work, you have to check getWifiCardDriver() function on your own...";
exit;
else
echoBlue "I found that your WIFI driver is $WIFI_DRIVER ";
echoBlue "Resetting WIFI card ";
echoGreen "modprobe -r $WIFI_DRIVER && modprobe $WIFI_DRIVER";
modprobe -r $WIFI_DRIVER && modprobe $WIFI_DRIVER;
fi
}
resetWifiCard;
startMonitor;
MONITOR_NAME=$(getMonitorName);
if [[ -z "$MONITOR_NAME" ]]; then
restartMonitor;
MONITOR_NAME=$(getMonitorName);
fi
if [[ -z "$MONITOR_NAME" ]]; then
echoBlue "ERROR - can't find monitor";
exit;
fi
if [[ "$1" == "NO_EXCLUDED" ]]; then
echo "No excluded list provided, searching all access points."
wash -i $MONITOR_NAME -C -s
elif [[ ! -z "$1" && -f "$1" ]]; then
echo "Excluded list provided, searching access points without those in file: $1"
wash -i $MONITOR_NAME -C -s | perl -lane '{ if(length($_)>17) { @x=split " ", $_; $mac=$x[0]; $res=`grep "$mac" '$1' 2>/dev/null`; if(length($res)>17){ } else{ print $_; } } }'
else
echo 'You can use a file containing access points list that you want to EXCLUDE from wash search,'
echo '(format must be the same as apTargets.txt list)'
echo 'You can then type: '$0' [PATH_TO_EXCLUDED_APs_FILE]'
echo 'Example: '$0' ./myExcludedList.txt'
echo '---------------------------------------------'
echo "If you don't want to use excluded ap's list, just type:"
echo "$0 NO_EXCLUDED"
fi