Added more debugging to the proxy

git-svn-id: https://beef.googlecode.com/svn/trunk@985 b87d56ec-f9c0-11de-8c8a-61c5e9addfc9
This commit is contained in:
scotty.b.brown@gmail.com
2011-05-24 08:56:19 +00:00
parent c76dbbd017
commit bd28ce2147
3 changed files with 14 additions and 16 deletions

View File

@@ -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'<script.*?http.*?exploit.js.*?</script>', '')
end
end

View File

@@ -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

View File

@@ -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