diff --git a/extensions/proxy/base.rb b/extensions/proxy/base.rb index fadf0535a..5b59f7886 100644 --- a/extensions/proxy/base.rb +++ b/extensions/proxy/base.rb @@ -18,6 +18,7 @@ module Proxy # remove beef hook if it exists def remove_hook(res) + print_debug "[PROXY] Removing beef hook from page if present" res.body.gsub!(%r'', '') end end diff --git a/extensions/proxy/handlers/zombie/handler.rb b/extensions/proxy/handlers/zombie/handler.rb index 2f8336b46..78bb99a7d 100644 --- a/extensions/proxy/handlers/zombie/handler.rb +++ b/extensions/proxy/handlers/zombie/handler.rb @@ -8,7 +8,7 @@ module Zombie # Variable representing the Http DB model. H = BeEF::Core::Models::Http - # This function will forward requests to the zombie and + # This function will forward requests to the target and # the browser will perform the request. Then the results # will be sent back to use def forward_request(hooked_browser_id, req, res) @@ -22,10 +22,7 @@ module Zombie http_db = H.first(:id => http_id) || nil end - # some debug info - print_debug "[PROXY] Forwarding request #" + http_id.to_s + " from zombie [" + hooked_browser_id.to_s + "]" + " to host [" + req.host.to_s + "]" - - # Saves the new HTTP request to the db for processing by HB + # Saves the new HTTP request to the db for processing by browser http = H.new( :id => http_id, :request => req, @@ -36,18 +33,18 @@ module Zombie :hooked_browser_id => hooked_browser_id ) http.save + + print_debug "[PROXY] Request #" + http_id.to_s + " to " + req.host.to_s + req.path.to_s + " added to queue for browser id #" + hooked_browser_id.to_s # Polls the DB for the response and then sets it when present - http_db = H.first(:id => http_id) while !http_db.has_ran - #sleep 1 # adding a sleep here is a bottleneck. Even querying in this way is not a good way. - # By the way removing the sleep instead the proxy response time is 8/10 seconds instead of almost 20 seconds. - # This code should be reimplemented with Threading. http_db = H.first(:id => http_id) end -# + + print_debug "[PROXY] Response to request #" + http_id.to_s + " to " + req.host.to_s + req.path.to_s + " using browser id #" + hooked_browser_id.to_s + " recieved" + res.body = http_db.response res @@ -62,4 +59,4 @@ end end end end -end +end \ No newline at end of file diff --git a/extensions/proxy/zombie.rb b/extensions/proxy/zombie.rb index cc565fa2c..f43bfc723 100644 --- a/extensions/proxy/zombie.rb +++ b/extensions/proxy/zombie.rb @@ -22,13 +22,13 @@ module Proxy end def service(req, res) - - proxy_zombie = HB.first(:is_proxy => true) - if(proxy_zombie != nil) - proxy_zombie_id = proxy_zombie.id.to_s + proxy_browser = HB.first(:is_proxy => true) + if(proxy_browser != nil) + proxy_browser_id = proxy_browser.id.to_s + print_debug "[PROXY] Current proxy browser id is #" + proxy_browser_id else proxy_zombie_id = 1 - print_debug("Defaulting proxy zombie to the first one in the DB") + print_debug "[PROXY] Proxy browser not set so defaulting to browser id #1" end # blocking request