Geolocating 802.11 access points by MAC address using Google Geolocation API
Support for the Google Geolocation API is now built in to most browsers. They do this, in part, by sending to Google the MAC address of nearby 802.11 access points (those whose beacons are captured by your computer.)
I have a large number of 802.11 packets captured from various locations. I'm looking to geolocate the 802.11 access points. Assume that we only have their mac addresses. This should be possible by using the Google Geolocation API.
Sources that I've found to date that might be helpful on this include:
- Geolocation source code from Mozilla 1.9.1 code base
- MDN article on Monitoring WiFi access points
- MDN article on using geolocation
- Mozilla WebDev article on using Geolocation in the Browser
The first is probably the best bet. Problem is, I'm not sure how to use the example there and actually create a program that lets me pipe in the MAC addresses and output lat/long pairs. I'm also not sure how to run JavaScript from a Unix/MacOS command line.
I know that this开发者_如何转开发 is a lot to ask, but does anybody have any clue where I should start?
<?php
$mac = $_SERVER['argv'][1];
$postData = '{
"version": "1.1.0",
"wifi_towers": [{
"mac_address": "' . $mac . '",
"ssid": "0",
"signal_strength":-72
}]
}';
$opts = array(
'http'=>array(
'method' => "POST",
'header' => 'Content-type: application/x-www-form-urlencoded',
'content' => $postData
)
);
$response = file_get_contents(
'http://www.google.com/loc/json',
false,
stream_context_create($opts)
);
$loc = json_decode($response, true);
echo $loc['location']['latitude'];
echo ',';
echo $loc['location']['longitude'];
Command line usage:
php geo.php "mac addy here"
精彩评论