diff --git a/core/main/client/net/connection.js b/core/main/client/net/connection.js new file mode 100644 index 000000000..1561a982f --- /dev/null +++ b/core/main/client/net/connection.js @@ -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'); + diff --git a/core/main/handlers/modules/beefjs.rb b/core/main/handlers/modules/beefjs.rb index f734751d3..ae82f2d10 100644 --- a/core/main/handlers/modules/beefjs.rb +++ b/core/main/handlers/modules/beefjs.rb @@ -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"