O2 Script/Tool - Find Physical Location via MAC Address (using Google's APIs).h2
From
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
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):
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)
- or in link on the v1.5 API "Demos, Animations andVideos" section
- and the following GUI should apprear
- 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)
- click on one of these addresses
- and a query to Google Location Services will be made for that MAC address
- and if sucessfull, the current location will be shown below
- if you submit a MAC address that is currently NOT in Google's Database, you will get the following message:
Source code
see Tool - Find Physical Location via MAC Address (using Google's APIs).h2 at O2 SVN repository











