-
Notifications
You must be signed in to change notification settings - Fork 9
/
Copy pathrestoreClientWifi.sh
executable file
·46 lines (35 loc) · 1.26 KB
/
restoreClientWifi.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
#!/bin/bash
##
# restoreClientWifi.sh will (aggressively) restore wifi to wireless interfaces after either scan or attack runs.
##
sudo airmon-ng check kill &>/dev/null
############# Restore intefaces by default names ################
if (ifconfig -a | sed 's/[ \t].*//;/^$/d' | awk "FNR==3" | tr -d ':' | grep --quiet wlan0)
then
ifconfig wlan0 down &>/dev/null
iwconfig wlan0 mode managed &>/dev/null
ifconfig wlan0 up &>/dev/null
fi
if (ifconfig | sed 's/[ \t].*//;/^$/d' | awk "FNR==3" | tr -d ':' | grep --quiet wlan0mon)
then
ifconfig wlan0mon down &>/dev/null
fi
if (ifconfig | sed 's/[ \t].*//;/^$/d' | awk "FNR==5" | tr -d ':' | grep --quiet wlan0sta1)
then
ifconfig wlan0sta1 down &>/dev/null
fi
if (ifconfig | sed 's/[ \t].*//;/^$/d' | awk "FNR==4" | tr -d ':' | grep --quiet wlan1sta1)
then
ifconfig wlan1sta1 down &>/dev/null
fi
if (ifconfig -a | sed 's/[ \t].*//;/^$/d' | awk "FNR==4" | tr -d ':' | grep --quiet wlan1)
then
ifconfig wlan1 down &>/dev/null
iwconfig wlan1 mode managed &>/dev/null
ifconfig wlan1 up &>/dev/null
fi
############# Attempt to restore connection ################
sudo service NetworkManager restart &>/dev/null
sudo service networking restart &>/dev/null
nmcli radio wifi off &>/dev/null
nmcli radio wifi on &>/dev/null