Minor modifications for http_header

bug/bundler_fix
Spencer McIntyre 2014-04-04 10:46:03 -04:00
parent a4adfac312
commit 2b6ae68cbf
1 changed files with 45 additions and 41 deletions

View File

@ -14,11 +14,15 @@ class Metasploit3 < Msf::Auxiliary
super(update_info(info,
'Name' => 'HTTP Header Detection',
'Description' => %q{ This module shows HTTP Headers returned by the scanned systems. },
'Author' => ['Christian Mehlmauer <FireFart[at]gmail.com>'],
'Author' =>
[
'Christian Mehlmauer <FireFart[at]gmail.com>',
'rick2600'
],
'References' =>
[
['URL','http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html'],
['URL','http://en.wikipedia.org/wiki/List_of_HTTP_header_fields']
['URL', 'http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html'],
['URL', 'http://en.wikipedia.org/wiki/List_of_HTTP_header_fields']
],
'License' => MSF_LICENSE
))
@ -32,10 +36,9 @@ class Metasploit3 < Msf::Auxiliary
end
def run_host(ip)
ignored_headers = datastore['IGN_HEADER'].split(',')
uri = datastore['TARGETURI']
uri = normalize_uri(target_uri.path)
method = datastore['HTTP_METHOD']
vprint_status("#{peer}: requesting #{uri} via #{method}")
res = send_request_raw({
@ -43,47 +46,48 @@ class Metasploit3 < Msf::Auxiliary
'uri' => uri
})
if res
headers = res.headers
unless res
vprint_error("#{peer}: connection timed out")
return
end
if headers
# Header Names are case insensitve so convert them to upcase
headers_uppercase = headers.inject({}) do |hash, keys|
hash[keys[0].upcase] = keys[1]
hash
end
headers = res.headers
unless headers
vprint_status("#{peer}: no headers returned")
return
end
ignored_headers.each do |h|
if headers_uppercase.has_key?(h.upcase)
vprint_status("#{peer}: deleted header #{h}")
headers_uppercase.delete(h.upcase)
end
end
headers_uppercase.to_a.compact.sort
# Header Names are case insensitve so convert them to upcase
headers_uppercase = headers.inject({}) do |hash, keys|
hash[keys[0].upcase] = keys[1]
hash
end
counter = 0;
headers_uppercase.each do |h|
header_string = "#{h[0]}: #{h[1]}"
vprint_status("#{peer}: #{header_string}")
report_note({
:type => 'HTTP header',
:data => header_string,
:host => ip,
:port => rport
})
counter = counter + 1
end
if counter == 0
print_warning "#{peer}: all detected headers are defined in IGN_HEADER and were ignored "
else
print_good "#{peer}: detected #{counter} headers"
end
else
vprint_status("#{peer}: no headers returned")
ignored_headers.each do |h|
if headers_uppercase.has_key?(h.upcase)
vprint_status("#{peer}: deleted header #{h}")
headers_uppercase.delete(h.upcase)
end
end
headers_uppercase.to_a.compact.sort
counter = 0;
headers_uppercase.each do |h|
header_string = "#{h[0]}: #{h[1]}"
print_status "#{peer}: #{header_string}"
report_note({
:type => 'HTTP header',
:data => header_string,
:host => ip,
:port => rport
})
counter = counter + 1
end
if counter == 0
print_warning "#{peer}: all detected headers are defined in IGN_HEADER and were ignored "
else
vprint_error("#{peer}: no connection")
print_good "#{peer}: detected #{counter} headers"
end
end