Updated main script
Have had better luck with @alexisph's script, updated the script to mirror their version.
This commit is contained in:
parent
6d82ae4a8a
commit
103f5b7ba4
1 changed files with 36 additions and 62 deletions
98
relaymyhome
Executable file → Normal file
98
relaymyhome
Executable file → Normal file
|
@ -1,8 +1,7 @@
|
||||||
#!/usr/bin/env bash
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
# The MIT License (MIT)
|
# The MIT License (MIT)
|
||||||
#
|
#
|
||||||
# Copyright (c) 2013-2014 Rob Zimmerman
|
# Copyright (c) 2013 Rob Zimmerman
|
||||||
#
|
#
|
||||||
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
# of this software and associated documentation files (the "Software"), to deal
|
# of this software and associated documentation files (the "Software"), to deal
|
||||||
|
@ -27,71 +26,34 @@
|
||||||
# See other generous contributors, plus view the source, readme, and license at https://github.com/taintedzodiac/relaymyhome
|
# See other generous contributors, plus view the source, readme, and license at https://github.com/taintedzodiac/relaymyhome
|
||||||
# Tested in OS X 10.8 (Mountain Lion) and Mavericks
|
# Tested in OS X 10.8 (Mountain Lion) and Mavericks
|
||||||
|
|
||||||
### The time we will pause on each MAC address
|
|
||||||
relay_time="90"
|
|
||||||
sleep_time="10"
|
|
||||||
|
|
||||||
wservice=`/usr/sbin/networksetup -listallnetworkservices | grep -Ei '(wi-fi|airport)'`
|
wservice=`/usr/sbin/networksetup -listallnetworkservices | grep -Ei '(wi-fi|airport)'`
|
||||||
wifi=$(networksetup -listallhardwareports | awk "/$wservice/,/Ethernet/"' getline { print $2 }')
|
wifi=$(networksetup -listallhardwareports | awk "/$wservice/,/Ethernet/"' getline { print $2 }')
|
||||||
|
|
||||||
WirelessMAC=$(networksetup -getmacaddress "${wifi}" | awk '{print $3}')
|
WirelessMAC=$(networksetup -getmacaddress $wifi | awk '{print $3}')
|
||||||
echo "Original MAC address is: $WirelessMAC"
|
echo "Original MAC address is: $WirelessMAC"
|
||||||
|
|
||||||
function notify {
|
cleanup()
|
||||||
if [ -z ${speak} ] ; then
|
{
|
||||||
echo "${@}" ;
|
sudo ifconfig $wifi lladdr $WirelessMAC
|
||||||
else
|
networksetup -setairportpower $wifi off
|
||||||
say --interactive=green "${@}" ;
|
networksetup -setairportpower $wifi on
|
||||||
fi
|
|
||||||
return 0
|
|
||||||
}
|
|
||||||
|
|
||||||
function cleanup {
|
|
||||||
sudo ifconfig ${wifi} lladdr ${WirelessMAC}
|
|
||||||
networksetup -setairportpower ${wifi} off
|
|
||||||
networksetup -setairportpower ${wifi} on
|
|
||||||
|
|
||||||
echo "Cycling of Relays has completed, MAC address reverted."
|
echo "Cycling of Relays has completed, MAC address reverted."
|
||||||
notify "Time to check your street passes!"
|
|
||||||
return 0
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function ctrl_c {
|
ctrl_c()
|
||||||
# user quit midway through, so we should revert
|
{
|
||||||
# the MAC address by calling our cleanup function
|
# user quit midway through, so we should revert
|
||||||
echo "*** Interrupted ***"
|
# the MAC address by calling our cleanup function
|
||||||
cleanup
|
echo "*** Interrupted ***"
|
||||||
exit $?
|
cleanup
|
||||||
}
|
exit $?
|
||||||
|
|
||||||
function usage {
|
|
||||||
echo "$0 [-c count] [-s]"
|
|
||||||
echo "c: the number of MAC addresses to cycle through."
|
|
||||||
echo "s: audibly speak when the script is done"
|
|
||||||
}
|
}
|
||||||
|
|
||||||
# trap keyboard interrupt (control-c) or unexpected quit
|
# trap keyboard interrupt (control-c) or unexpected quit
|
||||||
trap ctrl_c SIGINT SIGTERM
|
trap ctrl_c SIGINT SIGTERM
|
||||||
|
|
||||||
while getopts hsc: option
|
if [[ $1 == "full" || $1 == "quick" ]]
|
||||||
do
|
|
||||||
case "${option}" in
|
|
||||||
h) usage ; exit ;;
|
|
||||||
s) speak=1 ;;
|
|
||||||
c) count=${OPTARG} ;;
|
|
||||||
*) usage ; exit 1 ;
|
|
||||||
esac
|
|
||||||
done
|
|
||||||
|
|
||||||
shift $((OPTIND - 1))
|
|
||||||
|
|
||||||
### TODO:
|
|
||||||
### * change this to a case statement
|
|
||||||
### * Make most of this into functions
|
|
||||||
### * Parse other cli options for verbosity and say vs silent
|
|
||||||
### * Put the list of MACs into a sqlite3 db and query only oldest visited ones?
|
|
||||||
|
|
||||||
if [[ $1 == "full" || $1 == "fuller" || $1 == "quick" ]]
|
|
||||||
then
|
then
|
||||||
# Generate a full list of 160 MACs when "full" mode is specified
|
# Generate a full list of 160 MACs when "full" mode is specified
|
||||||
# To use full mode: ./relaymyhome full
|
# To use full mode: ./relaymyhome full
|
||||||
|
@ -100,8 +62,20 @@ then
|
||||||
# Set the base MAC address
|
# Set the base MAC address
|
||||||
baseAddr="4E:53:50:4F:4F:"
|
baseAddr="4E:53:50:4F:4F:"
|
||||||
|
|
||||||
# Create an array for the last octet of the mac address, limited range.
|
# Legal characters for MAC (Limited range for first digit)
|
||||||
Addr=($(for X in {0..159} ; do echo ${X} | awk '{printf "%s%02X ", "4E:53:50:4F:4F:", $1}'; done ;))
|
CharsA=("0" "1" "2" "3" "4" "5" "6" "7" "8" "9")
|
||||||
|
CharsB=("0" "1" "2" "3" "4" "5" "6" "7" "8" "9" "A" "B" "C" "D" "E" "F")
|
||||||
|
|
||||||
|
# Create the addresses programmatically
|
||||||
|
count=0
|
||||||
|
for i in "${CharsA[@]}"
|
||||||
|
do
|
||||||
|
for j in "${CharsB[@]}"
|
||||||
|
do
|
||||||
|
mac=$baseAddr$i$j
|
||||||
|
Addr+=($mac)
|
||||||
|
done
|
||||||
|
done
|
||||||
|
|
||||||
if [[ $1 == "full" ]]
|
if [[ $1 == "full" ]]
|
||||||
then
|
then
|
||||||
|
@ -109,19 +83,18 @@ then
|
||||||
echo "Full Mode enabled. Randomly seeding five addresses from full list."
|
echo "Full Mode enabled. Randomly seeding five addresses from full list."
|
||||||
else
|
else
|
||||||
num=2
|
num=2
|
||||||
echo "Quick Mode enabled. Randomly seeding ${num} addresses from full list."
|
echo "Quick Mode enabled. Randomly seeding two addresses from full list."
|
||||||
fi
|
fi
|
||||||
|
|
||||||
for ((a=1; a<=$num; a++));
|
for a in $(seq 1 $num)
|
||||||
do
|
do
|
||||||
selectedAddr=${Addr[$RANDOM % ${#Addr[@]} ]}
|
selectedAddr=${Addr[$RANDOM % ${#Addr[@]} ]}
|
||||||
echo "Cycling WiFi..."
|
echo "Cycling WiFi..."
|
||||||
sudo ifconfig $wifi lladdr $selectedAddr
|
sudo ifconfig $wifi lladdr $selectedAddr
|
||||||
networksetup -setairportpower $wifi off
|
networksetup -setairportpower $wifi off
|
||||||
sleep ${sleep_time}
|
|
||||||
networksetup -setairportpower $wifi on
|
networksetup -setairportpower $wifi on
|
||||||
echo "Spoofing $wifi to $selectedAddr for ${relay_time} seconds ($a of $num)"
|
echo "Spoofing $wifi to $selectedAddr for 90 seconds ($a of $num)"
|
||||||
sleep ${relay_time}
|
sleep 90
|
||||||
done
|
done
|
||||||
|
|
||||||
|
|
||||||
|
@ -159,14 +132,15 @@ else
|
||||||
echo "Cycling WiFi..."
|
echo "Cycling WiFi..."
|
||||||
sudo ifconfig $wifi lladdr $a
|
sudo ifconfig $wifi lladdr $a
|
||||||
networksetup -setairportpower $wifi off
|
networksetup -setairportpower $wifi off
|
||||||
sleep ${sleep_time}
|
|
||||||
networksetup -setairportpower $wifi on
|
networksetup -setairportpower $wifi on
|
||||||
echo "Spoofing $wifi to $a for 90 seconds ($n of 21)"
|
echo "Spoofing $wifi to $a for 90 seconds ($n of 21)"
|
||||||
n=$((n+1))
|
n=$((n+1))
|
||||||
sleep ${relay_time}
|
sleep 90
|
||||||
done
|
done
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# ... and we are done
|
# ... and we are done
|
||||||
|
|
||||||
cleanup
|
cleanup
|
||||||
|
|
||||||
|
echo "Time to check your StreetPasses!"
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue