139 lines
4.6 KiB
HTML
139 lines
4.6 KiB
HTML
<!DOCTYPE html>
|
|
<html lang="en">
|
|
<head>
|
|
<meta charset="utf-8">
|
|
<title>JSDoc: Source: net/local.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: net/local.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 networking functions for the local/internal network of the zombie.
|
|
* @namespace beef.net.local
|
|
*/
|
|
beef.net.local = {
|
|
|
|
sock: false,
|
|
checkJava: false,
|
|
hasJava: false,
|
|
|
|
/**
|
|
* Initializes the java socket. We have to use this method because
|
|
* some browsers do not have java installed or it is not accessible.
|
|
* in which case creating a socket directly generates an error. So this code
|
|
* is invalid:
|
|
* sock: new java.net.Socket();
|
|
*/
|
|
initializeSocket: function() {
|
|
if(this.checkJava){
|
|
if(!beef.browser.hasJava()) {
|
|
this.checkJava=True;
|
|
this.hasJava=False;
|
|
return -1;
|
|
}else{
|
|
this.checkJava=True;
|
|
this.hasJava=True;
|
|
return 1;
|
|
}
|
|
}
|
|
else{
|
|
if(!this.hasJava) return -1;
|
|
else{
|
|
try {
|
|
this.sock = new java.net.Socket();
|
|
} catch(e) {
|
|
return -1;
|
|
}
|
|
return 1;
|
|
}
|
|
}
|
|
},
|
|
|
|
/**
|
|
* Returns the internal IP address of the zombie.
|
|
* @return {String} the internal ip of the zombie.
|
|
* @error return -1 if the internal ip cannot be retrieved.
|
|
*/
|
|
getLocalAddress: function() {
|
|
if(!this.hasJava) return false;
|
|
|
|
this.initializeSocket();
|
|
|
|
try {
|
|
this.sock.bind(new java.net.InetSocketAddress('0.0.0.0', 0));
|
|
this.sock.connect(new java.net.InetSocketAddress(document.domain, (!document.location.port)?80:document.location.port));
|
|
|
|
return this.sock.getLocalAddress().getHostAddress();
|
|
} catch(e) { return false; }
|
|
},
|
|
|
|
/**
|
|
* Returns the internal hostname of the zombie.
|
|
* @return {String} the internal hostname of the zombie.
|
|
* @error return -1 if the hostname cannot be retrieved.
|
|
*/
|
|
getLocalHostname: function() {
|
|
if(!this.hasJava) return false;
|
|
|
|
this.initializeSocket();
|
|
|
|
try {
|
|
this.sock.bind(new java.net.InetSocketAddress('0.0.0.0', 0));
|
|
this.sock.connect(new java.net.InetSocketAddress(document.domain, (!document.location.port)?80:document.location.port));
|
|
|
|
return this.sock.getLocalAddress().getHostName();
|
|
} catch(e) { return false; }
|
|
}
|
|
|
|
};
|
|
|
|
beef.regCmp('beef.net.local');
|
|
</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>
|