-
Notifications
You must be signed in to change notification settings - Fork 0
/
wifi_hackmode.sh
81 lines (63 loc) · 2.23 KB
/
wifi_hackmode.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
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
#!/bin/bash
function wifi_hackmode_status() {
local interface=$1
local mode=$(iw $interface info | grep type | awk '{print $2}')
echo $mode
}
function wifi_hackmode_start() {
local interface=$1
shift
local command=$@
if [[ -z "$interface" || -z "$command" ]]; then
echo "Usage: wifi_hackmode_start <interface> <command> [options]"
return 1
fi
echo "Checking interface mode for $interface..."
mode=$(check_interface_mode $interface)
echo "$interface is currently in $mode mode."
if [[ $mode == "monitor" ]]; then
echo "$interface is already in monitor mode. Resetting it first..."
sudo ip link set $interface down
sudo iw dev $interface set type managed
sudo ip link set $interface up
sleep 2 # Adding a small delay to ensure changes take effect
fi
echo "Stopping conflicting processes..."
sudo systemctl stop NetworkManager
sudo airmon-ng check kill
echo "Resetting the interface $interface..."
sudo ip link set $interface down
sudo iw dev $interface set type managed
sudo ip link set $interface up
echo "Enabling monitor mode for $interface..."
sudo ip link set $interface down
sudo iw dev $interface set type monitor
sudo ip link set $interface up
echo "Verifying interface mode..."
mode=$(wifi_hackmode_status $interface)
echo "$interface is now in $mode mode."
echo "Running command: $command"
sudo bash -c "$command"
}
function wifi_hackmode_stop() {
local interface=$1
if [[ -z "$interface" ]]; then
echo "Usage: wifi_hackmode_stop <interface>"
return 1
fi
echo "Stopping any running processes..."
sudo pkill -f "$interface"
echo "Resetting the interface $interface to managed mode..."
sudo ip link set $interface down
sudo iw dev $interface set type managed
sudo ip link set $interface up
echo "Restarting NetworkManager and related services..."
sudo systemctl start NetworkManager
sudo airmon-ng check
echo "Verifying interface mode..."
iw $interface info
echo "$interface should now be back to managed mode."
}
# Example usage:
# wifi_hackmode_start wlan0 "bettercap -iface wlan0"
# wifi_hackmode_stop wlan0