From 8132eb0e538bdc3d2d61bf87a77e4d6b79ddf8bd Mon Sep 17 00:00:00 2001 From: bcoles Date: Sat, 16 Mar 2013 20:12:27 +1030 Subject: [PATCH] Solution: Hide beef behind an apache webserver Manually merge code from @lalaglubsch Add support for BeEF through a proxy Fix issue #856 --- core/main/handlers/hookedbrowsers.rb | 13 ++++++++++--- core/main/handlers/modules/beefjs.rb | 6 ++++++ 2 files changed, 16 insertions(+), 3 deletions(-) diff --git a/core/main/handlers/hookedbrowsers.rb b/core/main/handlers/hookedbrowsers.rb index 1236decc2..91cb935f3 100644 --- a/core/main/handlers/hookedbrowsers.rb +++ b/core/main/handlers/hookedbrowsers.rb @@ -55,9 +55,16 @@ module Handlers hooked_browser.lastseen = Time.new.to_i # @note Check for a change in zombie IP and log an event - if hooked_browser.ip != request.ip - BeEF::Core::Logger.instance.register('Zombie',"IP address has changed from #{hooked_browser.ip} to #{request.ip}","#{hooked_browser.id}") - hooked_browser.ip = request.ip + if config.get('beef.http.use_x_forward_for') == true + if hooked_browser.ip != request.env["HTTP_X_FORWARDED_FOR"] + BeEF::Core::Logger.instance.register('Zombie',"IP address has changed from #{hooked_browser.ip} to #{request.env["HTTP_X_FORWARDED_FOR"]}","#{hook + hooked_browser.ip = request.env["HTTP_X_FORWARDED_FOR"] + end + else + if hooked_browser.ip != request.ip + BeEF::Core::Logger.instance.register('Zombie',"IP address has changed from #{hooked_browser.ip} to #{request.ip}","#{hooked_browser.id}") + hooked_browser.ip = request.ip + end end hooked_browser.count! diff --git a/core/main/handlers/modules/beefjs.rb b/core/main/handlers/modules/beefjs.rb index f120f7814..1f434189a 100644 --- a/core/main/handlers/modules/beefjs.rb +++ b/core/main/handlers/modules/beefjs.rb @@ -66,6 +66,12 @@ module BeEF hook_session_config = BeEF::Core::Server.instance.to_h # @note if http_host="0.0.0.0" in config ini, use the host requested by client + unless hook_session_config['beef_public'].nil? + if hook_session_config['beef_host'] != hook_session_config['beef_public'] + hook_session_config['beef_host'] = hook_session_config['beef_public'] + hook_session_config['beef_url'].sub!(/#{hook_session_config['beef_host']}/, hook_session_config['beef_public']) + end + end if hook_session_config['beef_host'].eql? "0.0.0.0" hook_session_config['beef_host'] = req_host hook_session_config['beef_url'].sub!(/0\.0\.0\.0/, req_host)