Add beef.net.connection client methods
This commit is contained in:
47
core/main/client/net/connection.js
Normal file
47
core/main/client/net/connection.js
Normal file
@@ -0,0 +1,47 @@
|
||||
//
|
||||
// Copyright (c) 2006-2015 Wade Alcorn - wade@bindshell.net
|
||||
// Browser Exploitation Framework (BeEF) - http://beefproject.com
|
||||
// See the file 'doc/COPYING' for copying permission
|
||||
//
|
||||
|
||||
// beef.net.connection - wraps Mozilla's Network Information API
|
||||
// https://developer.mozilla.org/en-US/docs/Web/API/NetworkInformation
|
||||
// https://developer.mozilla.org/en-US/docs/Web/API/Navigator/connection
|
||||
beef.net.connection = {
|
||||
|
||||
/* Returns the connection type
|
||||
* @example: beef.net.connection.type()
|
||||
* @note: https://developer.mozilla.org/en-US/docs/Web/API/NetworkInformation/type
|
||||
* @return: {String} connection type or 'unknown'.
|
||||
**/
|
||||
type: function () {
|
||||
try {
|
||||
var connection = navigator.connection || navigator.mozConnection || navigator.webkitConnection;
|
||||
var type = connection.type;
|
||||
if (type) return type; else return 'unknown';
|
||||
} catch(e) {
|
||||
beef.debug("Error retrieving connection type: " + e.message);
|
||||
return 'unknown';
|
||||
}
|
||||
},
|
||||
|
||||
/* Returns the maximum downlink speed of the connection
|
||||
* @example: beef.net.connection.downlinkMax()
|
||||
* @note: https://developer.mozilla.org/en-US/docs/Web/API/NetworkInformation/downlinkMax
|
||||
* @return: {String} downlink max or 'unknown'.
|
||||
**/
|
||||
downlinkMax: function () {
|
||||
try {
|
||||
var connection = navigator.connection || navigator.mozConnection || navigator.webkitConnection;
|
||||
var max = connection.downlinkMax;
|
||||
if (max) return max; else return 'unknown';
|
||||
} catch(e) {
|
||||
beef.debug("Error retrieving connection downlink max: " + e.message);
|
||||
return 'unknown';
|
||||
}
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
beef.regCmp('beef.net.connection');
|
||||
|
||||
@@ -24,7 +24,7 @@ module BeEF
|
||||
ext_js_sub_files = %w(lib/jquery-1.10.2.min.js lib/jquery-migrate-1.2.1.min.js lib/evercookie.js lib/json2.js lib/mdetect.js lib/jquery.blockUI.js)
|
||||
|
||||
# @note BeEF libraries: need Eruby evaluation and obfuscation
|
||||
beef_js_sub_files = %w(beef.js browser.js browser/cookie.js browser/popup.js session.js os.js hardware.js dom.js logger.js net.js updater.js encode/base64.js encode/json.js net/local.js init.js mitb.js net/dns.js net/cors.js are.js)
|
||||
beef_js_sub_files = %w(beef.js browser.js browser/cookie.js browser/popup.js session.js os.js hardware.js dom.js logger.js net.js updater.js encode/base64.js encode/json.js net/local.js init.js mitb.js net/dns.js net/connection.js net/cors.js are.js)
|
||||
# @note Load websocket library only if WS server is enabled in config.yaml
|
||||
if config.get("beef.http.websocket.enable") == true
|
||||
beef_js_sub_files << "websocket.js"
|
||||
|
||||
Reference in New Issue
Block a user