SEARCH
TOOLBOX
LANGUAGES
modified on 6 October 2010 at 01:51 ••• 12,857 views

O2 Script/Tool - Find Physical Location via MAC Address (using Google's APIs).h2

From

Jump to: navigation, search

Contents

This O2 script (available on the v1.5 ClickOnce GUI) shows how to use the Google's GeoLocation APIs to find the current user's physical location using the user's router Mac Address (usually a Wireless network).

How it works

The core functionality required to make this happen is Google's Location Services which is already supported by Firefox (http://www.mozilla.com/en-US/firefox/geolocation/). Here is an example of how to use it from Firefox.

What doesn't seem to be common knowledge (as per google search) is how to get this information from a Wireless Router Mac address (this is Samy's big discovery and for more details on how this works see Samy's "How I meet your Girlfriend" BlackHat (& OWASP Tour) presentation or this page http://www.samy.pl/mapxss/)

Basically all that is needed to to is to send a well formed MAC address (xx-xx-xx-xx-xx-xx) inside a JSON object to a Google REST API.

Here is a simple code sample that shows this in action

Func<string,string> getLocationFromMac = 
	(macAddress)=>{
				var url = "http://www.google.com/loc/json";
				var postData = "{\"version\":\"1.1.0\",\"request_address\":true,\"wifi_towers\": [{\"mac_address\":\"" + 
				                macAddress + "\",\"ssid\":\"g\",\"signal_strength\":-72}]}";
				var response = new Web().getUrlContents_POST(url,postData);
				return response; 
		      };
 
return getLocationFromMac("0e-00-00-91-35-75");

which when executed (using O2's Simple Script Editor) will return a JSON object with the details of the current location

Image:10_5_2010_3_37_36_PM_tmp9BB6.jpg

which is about 10m from the restaurant I'm currently having lunch (the green arrow is where Google API's is mapping the MAC address to, and I'm currently inside the building with the red roof):

Image:10_5_2010_3_47_24_PM_tmp9505.jpg

Video

Screenshot: How it works

  • click on the script in the file system (Tool - Find Physical Location via MAC Address (using Google's APIs).h2)

Image:10_5_2010_4_00_49_PM_tmpDC38.jpg

  • or in link on the v1.5 API "Demos, Animations andVideos" section

Image:10_5_2010_3_50_44_PM_tmpA3AD.jpg

  • and the following GUI should apprear

Image:10_5_2010_4_02_45_PM_tmpA30E.jpg

  • by default it uses Samy's Mac address: 00-11-24-ec-72-cf (if you see the address "1140 N Formosa Ave" then all is ok)
  • on the left you should also see a list of IP and MAC addresses (retrived from the execution of "arp -a" on the local box)

Image:10_5_2010_4_04_44_PM_tmp7416.jpg

  • click on one of these addresses

Image:10_5_2010_4_04_57_PM_tmpA6DF.jpg

  • and a query to Google Location Services will be made for that MAC address

Image:10_5_2010_4_05_26_PM_tmp175D.jpg

  • and if sucessfull, the current location will be shown below

Image:10_5_2010_4_05_52_PM_tmp7DC9.jpg

  • if you submit a MAC address that is currently NOT in Google's Database, you will get the following message:

Image:10_5_2010_4_06_26_PM_tmp1A0.jpg


Source code

see Tool - Find Physical Location via MAC Address (using Google's APIs).h2 at O2 SVN repository

Image:10_5_2010_3_56_22_PM_tmpC8D1.jpg

MediaWiki Appliance - Powered by TurnKey Linux