-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwlan
executable file
·65 lines (39 loc) · 1.42 KB
/
wlan
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
#!/bin/sh
#######################################################
# https://cschad.tech #
# github:https://github.com/AnasBoubechra/Auto-monitor#
#######################################################
set -eu
if [ "$(id -u)" -ne 0 ]; then
echo "This script must be run as root"
exit 1
fi
MAC_FORMAT="52:54:%02x:%02x:%02x:%02x"
INTERFACE="wlan0"
wifi_card_down() {
ifconfig "$INTERFACE" >/dev/null 2>&1 && ifconfig "$INTERFACE" down
}
wifi_card_up() {
ifconfig "$INTERFACE" >/dev/null 2>&1 && ifconfig "$INTERFACE" up
}
if iwconfig $INTERFACE | grep -q "Mode:Monitor"; then
# Set INTERFACE to managed mode
wifi_card_down
iw dev "$INTERFACE" set type managed
ip link set dev "$INTERFACE" address "$(printf $MAC_FORMAT $((RANDOM%256)) $((RANDOM%256)) $((RANDOM%256)) $((RANDOM%256)))"
systemctl start NetworkManager
wifi_card_up
iw dev "$INTERFACE" info
# Print success message
echo "Wireless INTERFACE $INTERFACE set to managed mode with the original MAC address"
else
# Set INTERFACE to monitor mode
wifi_card_down
systemctl stop NetworkManager
iw dev "$INTERFACE" set type monitor
ip link set dev "$INTERFACE" address "$(printf $MAC_FORMAT $((RANDOM%256)) $((RANDOM%256)) $((RANDOM%256)) $((RANDOM%256)))"
wifi_card_up
iw dev "$INTERFACE" info
# Print success message
echo "Wireless INTERFACE $INTERFACE set to monitor mode with a random MAC address"
fi