Skip to content

Commit 2a2d8d9

Browse files
committed
Land rapid7#6054, HTTP Host header injection module
2 parents a4f0666 + c642057 commit 2a2d8d9

File tree

2 files changed

+72
-1
lines changed

2 files changed

+72
-1
lines changed

lib/msf/core/db_manager/vuln.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -230,4 +230,4 @@ def vulns(wspace=workspace)
230230
wspace.vulns
231231
}
232232
end
233-
end
233+
end
Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
##
2+
# This module requires Metasploit: http://metasploit.com/download
3+
# Current source: https://github.com/rapid7/metasploit-framework
4+
##
5+
6+
require 'msf/core'
7+
8+
class Metasploit4 < Msf::Auxiliary
9+
10+
include Msf::Exploit::Remote::HttpClient
11+
include Msf::Auxiliary::WmapScanServer
12+
include Msf::Auxiliary::Scanner
13+
14+
def initialize(info = {})
15+
super(update_info(info,
16+
'Name' => 'HTTP Host Header Injection Detection',
17+
'Description' => 'Checks if the host is vulnerable to Host header injection',
18+
'Author' =>
19+
[
20+
'Jay Turla', # @shipcod3
21+
'Medz Barao' # @godflux
22+
],
23+
'License' => MSF_LICENSE,
24+
'References' =>
25+
[
26+
['URL', 'http://www.skeletonscribe.net/2013/05/practical-http-host-header-attacks.html']
27+
]
28+
))
29+
30+
register_options(
31+
[
32+
OptString.new('TARGETHOST', [true, 'The redirector target', 'evil.com'])
33+
], self.class)
34+
end
35+
36+
def run_host(ip)
37+
begin
38+
target_host = "#{datastore['TARGETHOST']}"
39+
res = send_request_raw(
40+
'uri' => '/',
41+
'method' => 'GET',
42+
'headers' => {
43+
'Host' => target_host,
44+
'X-Forwarded-Host' => target_host
45+
}
46+
)
47+
48+
unless res
49+
vprint_error("#{peer} did not reply to our request")
50+
return
51+
end
52+
53+
if res.headers.include?(target_host) || res.body.include?(target_host)
54+
print_good("#{peer} is vulnerable to HTTP Host header injection")
55+
report_vuln(
56+
host: ip,
57+
port: rport,
58+
proto: 'tcp',
59+
sname: ssl ? 'https' : 'http',
60+
name: 'HTTP Host header injection',
61+
refs: self.references
62+
)
63+
else
64+
vprint_error("#{peer} returned #{res.code} #{res.message}")
65+
end
66+
rescue ::Rex::ConnectionRefused, ::Rex::HostUnreachable, ::Rex::ConnectionTimeout
67+
rescue ::Timeout::Error, ::Errno::EPIPE
68+
end
69+
end
70+
71+
end

0 commit comments

Comments
 (0)