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
56
relaymyhome
56
relaymyhome
|
@ -29,7 +29,8 @@
|
|||
|
||||
|
||||
### 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)')"
|
||||
wifi="$(networksetup -listallhardwareports | awk "/${wservice}/,/Ethernet/"' getline { print $2 }')"
|
||||
|
@ -37,18 +38,26 @@ wifi="$(networksetup -listallhardwareports | awk "/${wservice}/,/Ethernet/"' get
|
|||
WirelessMAC=$(networksetup -getmacaddress "${wifi}" | awk '{print $3}')
|
||||
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}
|
||||
networksetup -setairportpower ${wifi} off
|
||||
networksetup -setairportpower ${wifi} on
|
||||
|
||||
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
|
||||
# the MAC address by calling our cleanup function
|
||||
echo "*** Interrupted ***"
|
||||
|
@ -56,10 +65,34 @@ ctrl_c()
|
|||
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 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
|
||||
# Generate a full list of 160 MACs when "full" mode is specified
|
||||
# To use full mode: ./relaymyhome full
|
||||
|
@ -83,10 +116,11 @@ then
|
|||
done
|
||||
done
|
||||
|
||||
if [[ $1 == "full" ]]
|
||||
then
|
||||
if [[ $1 == "full" ]] ; then
|
||||
num=7
|
||||
echo "Full Mode enabled. Randomly seeding ${num} addresses from full list."
|
||||
elif [[ $1 == "fuller" ]] ; then
|
||||
num=99
|
||||
else
|
||||
num=2
|
||||
echo "Quick Mode enabled. Randomly seeding ${num} addresses from full list."
|
||||
|
@ -98,6 +132,7 @@ then
|
|||
echo "Cycling WiFi..."
|
||||
sudo ifconfig $wifi lladdr $selectedAddr
|
||||
networksetup -setairportpower $wifi off
|
||||
sleep ${sleep_time}
|
||||
networksetup -setairportpower $wifi on
|
||||
echo "Spoofing $wifi to $selectedAddr for ${relay_time} seconds ($a of $num)"
|
||||
sleep ${relay_time}
|
||||
|
@ -121,6 +156,7 @@ else
|
|||
echo "Cycling WiFi..."
|
||||
sudo ifconfig $wifi lladdr $a
|
||||
networksetup -setairportpower $wifi off
|
||||
sleep ${sleep_time}
|
||||
networksetup -setairportpower $wifi on
|
||||
echo "Spoofing $wifi to ${a} for ${relay_time} seconds (${n} of 5)"
|
||||
n=$((n+1))
|
||||
|
@ -131,5 +167,3 @@ fi
|
|||
# ... and we are done
|
||||
|
||||
cleanup
|
||||
|
||||
echo "Time to check your StreetPasses!"
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue