From 7a4b07ef2e4081fc3861c015b91a230fead64ec2 Mon Sep 17 00:00:00 2001 From: "bcoles@gmail.com" Date: Fri, 26 Aug 2011 13:28:53 +0000 Subject: [PATCH] Added "Has WebSockets" to initialization / details tab git-svn-id: https://beef.googlecode.com/svn/trunk@1237 b87d56ec-f9c0-11de-8c8a-61c5e9addfc9 --- core/main/client/browser.js | 13 ++++++++++++- .../admin_ui/controllers/modules/modules.rb | 15 +++++++++++++++ extensions/console/lib/shellinterface.rb | 17 ++++++++++++++++- extensions/initialization/handler.rb | 11 +++++++++++ 4 files changed, 54 insertions(+), 2 deletions(-) diff --git a/core/main/client/browser.js b/core/main/client/browser.js index 8b65217c2..61d43dc0a 100644 --- a/core/main/client/browser.js +++ b/core/main/client/browser.js @@ -564,6 +564,7 @@ beef.browser = { var vbscript_enabled=(beef.browser.hasVBScript())? "Yes" : "No"; var has_flash = (beef.browser.hasFlash())? "Yes" : "No"; var has_googlegears=(beef.browser.hasGoogleGears())? "Yes":"No"; + var has_web_socket=(beef.browser.hasWebSocket())? "Yes":"No"; var has_session_cookies = (beef.browser.cookie.hasSessionCookies("cookie"))? "Yes":"No"; var has_persistent_cookies = (beef.browser.cookie.hasPersistentCookies("cookie"))? "Yes":"No"; @@ -583,6 +584,7 @@ beef.browser = { if(java_enabled) details['JavaEnabled'] = java_enabled if(vbscript_enabled) details['VBScriptEnabled'] = vbscript_enabled if(has_flash) details['HasFlash'] = has_flash + if(has_web_socket) details['HasWebSocket'] = has_web_socket if(has_googlegears) details['HasGoogleGears'] = has_googlegears if(has_session_cookies) details["hasSessionCookies"] = has_session_cookies; if(has_persistent_cookies) details["hasPersistentCookies"] = has_persistent_cookies; @@ -627,7 +629,16 @@ beef.browser = { } return results; }, - + + /** + * Checks if the zombie has Web Sockets enabled. + * @return: {Boolean} true or false. + * + * */ + hasWebSocket: function() { + if (!!window.WebSocket) return true; else return false; + }, + /** * Checks if the zombie has Google Gears installed. * @return: {Boolean} true or false. diff --git a/extensions/admin_ui/controllers/modules/modules.rb b/extensions/admin_ui/controllers/modules/modules.rb index 214455e0a..0acad450e 100644 --- a/extensions/admin_ui/controllers/modules/modules.rb +++ b/extensions/admin_ui/controllers/modules/modules.rb @@ -316,6 +316,21 @@ class Modules < BeEF::Extension::AdminUI::HttpController summary_grid_hash['results'].push(page_name_row) # add the row end + # set and add the yes|no value for HasWebSocket + has_web_socket = BD.get(zombie_session, 'HasWebSocket') + if not has_web_socket.nil? + encoded_has_web_socket = CGI.escapeHTML(has_web_socket) + encoded_has_web_socket_hash = { 'Has WebSockets' => encoded_has_web_socket } + + page_name_row = { + 'category' => 'Browser Hook Initialisation', + 'data' => encoded_has_web_socket_hash, + 'from' => 'Initialisation' + } + + summary_grid_hash['results'].push(page_name_row) # add the row + end + # set and add the return values for hasSessionCookies has_session_cookies = BD.get(zombie_session, 'hasSessionCookies') if not has_session_cookies.nil? diff --git a/extensions/console/lib/shellinterface.rb b/extensions/console/lib/shellinterface.rb index ae95cee00..20f7fc625 100644 --- a/extensions/console/lib/shellinterface.rb +++ b/extensions/console/lib/shellinterface.rb @@ -525,6 +525,21 @@ class ShellInterface summary_grid_hash['results'].push(page_name_row) # add the row end + # set and add the yes|no value for HasWebSocket + has_web_socket = BD.get(self.targetsession, 'HasWebSocket') + if not has_web_socket.nil? + encoded_has_web_socket = CGI.escapeHTML(has_web_socket) + encoded_has_web_socket_hash = { 'Has GoogleGears' => encoded_has_web_socket } + + page_name_row = { + 'category' => 'Browser Hook Initialisation', + 'data' => encoded_has_web_socket_hash, + 'from' => 'Initialisation' + } + + summary_grid_hash['results'].push(page_name_row) # add the row + end + # set and add the return values for hasSessionCookies has_session_cookies = BD.get(self.targetsession, 'hasSessionCookies') if not has_session_cookies.nil? @@ -573,4 +588,4 @@ class ShellInterface end -end end end \ No newline at end of file +end end end diff --git a/extensions/initialization/handler.rb b/extensions/initialization/handler.rb index bafe7a5c8..d48c18767 100644 --- a/extensions/initialization/handler.rb +++ b/extensions/initialization/handler.rb @@ -228,6 +228,17 @@ module Initialization print_error "Invalid value for HasGoogleGears returned from the hook browser's initial connection." end + # get and store the yes|no value for HasWebSocket + begin + has_web_socket = get_param(@data['results'], 'HasWebSocket') + if not has_web_socket.nil? + raise WEBrick::HTTPStatus::BadRequest, "Invalid value for HasWebSocket" if not BeEF::Filters.is_valid_yes_no?(has_web_socket) + BD.set(session_id, 'HasWebSocket', has_web_socket) + end + rescue + print_error "Invalid value for HasWebSocket returned from the hook browser's initial connection." + end + # get and store whether the browser has session cookies enabled begin has_session_cookies = get_param(@data['results'], 'hasSessionCookies')