From 5de66f95d8fcd203eeae30b897aaa4db1e9709c4 Mon Sep 17 00:00:00 2001 From: Daniel Hoherd Date: Sun, 12 Jan 2014 13:23:07 -0800 Subject: [PATCH 1/4] Merging in my chnages to forked repo. --- relaymyhome | 33 +++++++++++++++++++-------------- 1 file changed, 19 insertions(+), 14 deletions(-) diff --git a/relaymyhome b/relaymyhome index 6cb8f25..78f1385 100755 --- a/relaymyhome +++ b/relaymyhome @@ -1,3 +1,5 @@ +#!/bin/bash + # The MIT License (MIT) # # Copyright (c) 2013 Rob Zimmerman @@ -25,21 +27,24 @@ # 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 -#! /bin/bash -wservice=`/usr/sbin/networksetup -listallnetworkservices | grep -Ei '(wi-fi|airport)'` -wifi=$(networksetup -listallhardwareports | awk "/$wservice/,/Ethernet/"' getline { print $2 }') +### The time we will pause on each MAC address +relay_time="75" -WirelessMAC=$(networksetup -getmacaddress $wifi | awk '{print $3}') +wservice="$(/usr/sbin/networksetup -listallnetworkservices | grep -Ei '(wi-fi|airport)')" +wifi="$(networksetup -listallhardwareports | awk "/${wservice}/,/Ethernet/"' getline { print $2 }')" + +WirelessMAC=$(networksetup -getmacaddress "${wifi}" | awk '{print $3}') echo "Original MAC address is: $WirelessMAC" cleanup() { - sudo ifconfig $wifi lladdr $WirelessMAC - networksetup -setairportpower $wifi off - networksetup -setairportpower $wifi on + 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!" } ctrl_c() @@ -80,11 +85,11 @@ then if [[ $1 == "full" ]] then - num=5 - echo "Full Mode enabled. Randomly seeding five addresses from full list." + num=7 + echo "Full Mode enabled. Randomly seeding ${num} addresses from full list." else num=2 - echo "Quick Mode enabled. Randomly seeding two addresses from full list." + echo "Quick Mode enabled. Randomly seeding ${num} addresses from full list." fi for a in $(seq 1 $num) @@ -94,8 +99,8 @@ then sudo ifconfig $wifi lladdr $selectedAddr networksetup -setairportpower $wifi off networksetup -setairportpower $wifi on - echo "Spoofing $wifi to $selectedAddr for 90 seconds ($a of $num)" - sleep 90 + echo "Spoofing $wifi to $selectedAddr for ${relay_time} seconds ($a of $num)" + sleep ${relay_time} done @@ -117,9 +122,9 @@ else sudo ifconfig $wifi lladdr $a networksetup -setairportpower $wifi off networksetup -setairportpower $wifi on - echo "Spoofing $wifi to $a for 90 seconds ($n of 5)" + echo "Spoofing $wifi to ${a} for ${relay_time} seconds (${n} of 5)" n=$((n+1)) - sleep 90 + sleep ${relay_time} done fi From 77cc0a5750a636b99efe13565760e7a6c7875441 Mon Sep 17 00:00:00 2001 From: Daniel Hoherd Date: Sun, 12 Jan 2014 14:06:20 -0800 Subject: [PATCH 2/4] Cleaned up the README with some forked project info. --- README.md | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 1c303f6..ae3df6c 100644 --- a/README.md +++ b/README.md @@ -1,3 +1,20 @@ +This is a forked version of relaymyhome: +======================================== + +* Some variables have been added in place of static numbers. +* shebang line is put on #1 so it can function correctly +* general code clean up +* Audibly speaks to you when it's done relaying + +Future improvements: +==================== + +* Better handling of switches +* Support shirt colors +* Perhaps make a sqlite3 db of mac addresses to pull from in order to support grabbing least-recently used, and other limiting factors like gender, shirt color, etc.. +* If we're doing db stuff, make it more modular to support different sources. eg: fallback on default generated list if db is absent + + relaymyhome =========== OSX Bash Script for automating the process of getting Nintendo 3DS StreetPass hits via Internet Connection Sharing. Gathers the maximum of ten (10) StreetPass hits within about 3-5 minutes. @@ -12,7 +29,7 @@ Script has been updated for the new "six at a time" feature of StreetPass Relay. * Each address in the cycle will now connect for 90 seconds in order to provide more time for the additional data to be sent for all six potential streetpasses. This additional time is more than offset by checking far fewer addresses (see next three points below). * Running the script in standard mode ( **./relaymyhome** ) will now only hit the five main Nintendo World addresses. You should be able to run this mode 2-3 times before you run out of streetpasses. This mode also provides the opportunity to get any "special" Miis that are generally only available via these addresses. * Running the script in full mode ( **./relaymyhome full** ) will now connect to five random addresses (down from 20), taking a total of 7.5 minutes. This provides 30 potential streetpasses, and should fill your 10 slots reliably. -* **New mode**: Running the script in quick mode ( **./relaymyhome quick** ) will connect to two random addresses, taking a total of three (3) minutes. This should quickyl fill your 10 streetpasses (out of the 12 potential ones), but will sometimes return fewer than 10. +* **New mode**: Running the script in quick mode ( **./relaymyhome quick** ) will connect to two random addresses, taking a total of three (3) minutes. This should quickly fill your 10 streetpasses, but will sometimes return fewer than 10. What It Does ============ From 3846dee222e1f45906aaf86c28673c40b6a37f12 Mon Sep 17 00:00:00 2001 From: Daniel Hoherd Date: Sat, 22 Mar 2014 20:51:34 -0700 Subject: [PATCH 3/4] Adding some functions, changing some functions. No real functionality difference. May not work, I haven't tested it. --- relaymyhome | 66 ++++++++++++++++++++++++++++++++++++++++------------- 1 file changed, 50 insertions(+), 16 deletions(-) diff --git a/relaymyhome b/relaymyhome index 78f1385..a01fcea 100755 --- a/relaymyhome +++ b/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,29 +38,61 @@ 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() -{ - # user quit midway through, so we should revert - # the MAC address by calling our cleanup function - echo "*** Interrupted ***" - cleanup - exit $? +function ctrl_c { + # user quit midway through, so we should revert + # the MAC address by calling our cleanup function + echo "*** Interrupted ***" + 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 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!" From 1ece4f8f52308d083761b8694951971939b27613 Mon Sep 17 00:00:00 2001 From: Daniel Hoherd Date: Wed, 2 Apr 2014 09:01:46 -0700 Subject: [PATCH 4/4] Shrinking the hex generation code. Fixing a typo. --- relaymyhome | 18 +++--------------- 1 file changed, 3 insertions(+), 15 deletions(-) diff --git a/relaymyhome b/relaymyhome index a01fcea..1d37d8e 100755 --- a/relaymyhome +++ b/relaymyhome @@ -79,7 +79,7 @@ do case "${option}" in h) usage ; exit ;; s) speak=1 ;; - s) count=${OPTARG} ;; + c) count=${OPTARG} ;; *) usage ; exit 1 ; esac done @@ -101,20 +101,8 @@ then # Set the base MAC address baseAddr="4E:53:50:4F:4F:" - # Legal characters for MAC (Limited range for first digit) - 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 + # Create an array for the last octet of the mac address, limited range. + Addr=($(for X in {0..159} ; do echo ${X} | awk '{printf "%02X ", $1}'; done ;)) if [[ $1 == "full" ]] ; then num=7