Adding some functions, changing some functions. No real functionality difference. May not work, I haven't tested it.
This commit is contained in:
parent
77cc0a5750
commit
3846dee222
1 changed files with 50 additions and 16 deletions
66
relaymyhome
66
relaymyhome
|
@ -29,7 +29,8 @@
|
||||||
|
|
||||||
|
|
||||||
### The time we will pause on each MAC address
|
### The time we will pause on each MAC address
|
||||||
relay_time="75"
|
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 }')"
|
||||||
|
@ -37,29 +38,61 @@ wifi="$(networksetup -listallhardwareports | awk "/${wservice}/,/Ethernet/"' get
|
||||||
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"
|
||||||
|
|
||||||
cleanup()
|
function notify {
|
||||||
{
|
if [ -z ${speak} ] ; then
|
||||||
|
echo "${@}" ;
|
||||||
|
else
|
||||||
|
say --interactive=green "${@}" ;
|
||||||
|
fi
|
||||||
|
return 0
|
||||||
|
}
|
||||||
|
|
||||||
|
function cleanup {
|
||||||
sudo ifconfig ${wifi} lladdr ${WirelessMAC}
|
sudo ifconfig ${wifi} lladdr ${WirelessMAC}
|
||||||
networksetup -setairportpower ${wifi} off
|
networksetup -setairportpower ${wifi} off
|
||||||
networksetup -setairportpower ${wifi} on
|
networksetup -setairportpower ${wifi} on
|
||||||
|
|
||||||
echo "Cycling of Relays has completed, MAC address reverted."
|
echo "Cycling of Relays has completed, MAC address reverted."
|
||||||
say "Time to check your street passes!"
|
notify "Time to check your street passes!"
|
||||||
|
return 0
|
||||||
}
|
}
|
||||||
|
|
||||||
ctrl_c()
|
function ctrl_c {
|
||||||
{
|
# user quit midway through, so we should revert
|
||||||
# user quit midway through, so we should revert
|
# the MAC address by calling our cleanup function
|
||||||
# the MAC address by calling our cleanup function
|
echo "*** Interrupted ***"
|
||||||
echo "*** Interrupted ***"
|
cleanup
|
||||||
cleanup
|
exit $?
|
||||||
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
|
||||||
|
|
||||||
if [[ $1 == "full" || $1 == "quick" ]]
|
while getopts hsc: option
|
||||||
|
do
|
||||||
|
case "${option}" in
|
||||||
|
h) usage ; exit ;;
|
||||||
|
s) speak=1 ;;
|
||||||
|
s) 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
|
||||||
|
@ -83,10 +116,11 @@ then
|
||||||
done
|
done
|
||||||
done
|
done
|
||||||
|
|
||||||
if [[ $1 == "full" ]]
|
if [[ $1 == "full" ]] ; then
|
||||||
then
|
|
||||||
num=7
|
num=7
|
||||||
echo "Full Mode enabled. Randomly seeding ${num} addresses from full list."
|
echo "Full Mode enabled. Randomly seeding ${num} addresses from full list."
|
||||||
|
elif [[ $1 == "fuller" ]] ; then
|
||||||
|
num=99
|
||||||
else
|
else
|
||||||
num=2
|
num=2
|
||||||
echo "Quick Mode enabled. Randomly seeding ${num} addresses from full list."
|
echo "Quick Mode enabled. Randomly seeding ${num} addresses from full list."
|
||||||
|
@ -98,6 +132,7 @@ then
|
||||||
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 ${relay_time} seconds ($a of $num)"
|
||||||
sleep ${relay_time}
|
sleep ${relay_time}
|
||||||
|
@ -121,6 +156,7 @@ 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 ${relay_time} seconds (${n} of 5)"
|
echo "Spoofing $wifi to ${a} for ${relay_time} seconds (${n} of 5)"
|
||||||
n=$((n+1))
|
n=$((n+1))
|
||||||
|
@ -131,5 +167,3 @@ 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