-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathSpoofMAC.sh
executable file
·52 lines (47 loc) · 1.53 KB
/
SpoofMAC.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
#!/bin/sh -
. /etc/rc.common
StartService ()
{
ConsoleMessage "Running SpoofMAC script."
ConsoleMessage "Path is $PATH"
if [ "$SIMPLE_SPOOF_MAC_AND_NAME" -eq 1 ]; then
local new_name=""
if [ -z "$SIMPLE_SPOOF_MAC_NAMES_FILE" ]; then
new_name=`openssl rand -hex 3`
else
new_name="$(tail -n $(jot -r 1 1 $(echo $(wc -l < "$SIMPLE_SPOOF_MAC_NAMES_FILE"))) "$SIMPLE_SPOOF_MAC_NAMES_FILE" | head -n 1 | tr -d "\n\r")"
fi
networksetup -setcomputername "$new_name"
scutil --set LocalHostName "$new_name"
scutil --set HostName "$new_name"
fi
local WIFI_HW_PORT=`networksetup -listallhardwareports \
| grep -A 2 'Wi-Fi' | grep -E '^Device' | cut -d ' ' -f 2`
if [ x`getAirportPowerState "$WIFI_HW_PORT"` == x"Off" ]; then
networksetup -setairportpower "$WIFI_HW_PORT" on
sleep 2 # wait for power-on
fi
# Manually disassociate from networks
/System/Library/PrivateFrameworks/Apple80211.framework/Versions/A/Resources/airport -z
sleep 2 # wait for dissociation
ifconfig "$WIFI_HW_PORT" ether 00:`openssl rand -hex 5 | sed 's/\(..\)/\1:/g; s/.$//'`
networksetup -detectnewhardware
# Show me the changes.
ifconfig "$WIFI_HW_PORT" | grep ether
}
StopService ()
{
return 0
}
RestartService ()
{
return 0
}
# Helper functions
getAirportPowerState ()
{
echo `networksetup -getairportpower "$1" \
| cut -d ':' -f 2 \
| sed -e 's/^[[:space:]]*//' -e 's/[[:space:]]*$//'`
}
RunService "$1"