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