From e06198c320e3b94c4fa8cea9fafabb900c73ce65 Mon Sep 17 00:00:00 2001 From: Brendan Coles Date: Sun, 16 Aug 2015 11:29:30 +0000 Subject: [PATCH] Use ignore_headers in proxy --- extensions/proxy/proxy.rb | 38 +++++++++++++++++++------------------- 1 file changed, 19 insertions(+), 19 deletions(-) diff --git a/extensions/proxy/proxy.rb b/extensions/proxy/proxy.rb index d57753cbe..0db574a80 100644 --- a/extensions/proxy/proxy.rb +++ b/extensions/proxy/proxy.rb @@ -130,30 +130,30 @@ module BeEF # but the final content-length forwarded back by the proxy is clearly bigger. Date header follows the same way. response_headers = "" if (response_status != -1 && response_status != 0) + ignore_headers = [ + "Content-Encoding", + "Keep-Alive", + "Cache-Control", + "Vary", + "Pragma", + "Connection", + "Expires", + "Accept-Ranges", + "Date"] headers.each_line do |line| # stripping the Encoding, Cache and other headers header_key = line.split(': ')[0] header_value = line.split(': ')[1] - if !header_key.nil? && - header_key != "Content-Encoding" && - header_key != "Keep-Alive" && - header_key != "Cache-Control" && - header_key != "Vary" && - header_key != "Pragma" && - header_key != "Connection" && - header_key != "Expires" && - header_key != "Accept-Ranges" && - header_key != "Date" - if header_value.nil? - #headers_hash[header_key] = "" + next if header_key.nil? + next if ignore_headers.include?(header_key) + if header_value.nil? + #headers_hash[header_key] = "" + else + # update Content-Length with the valid one + if header_key == "Content-Length" + response_headers += "Content-Length: #{response_body.size}\r\n" else - # update Content-Length with the valid one - if header_key == "Content-Length" - header_value = response_body.size - response_headers += "Content-Length: #{header_value}\r\n" - else - response_headers += line - end + response_headers += line end end end