Skip to content

Commit 7fc9be8

Browse files
committed
bcoles suggestions
1 parent 6cc5324 commit 7fc9be8

File tree

1 file changed

+24
-33
lines changed

1 file changed

+24
-33
lines changed

modules/auxiliary/scanner/http/apache_optionsbleed.rb

Lines changed: 24 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -44,15 +44,10 @@ def get_allow_header(ip)
4444
'method' => 'OPTIONS',
4545
'uri' => datastore['TARGETURI']
4646
}, 10)
47-
if res
48-
if res.headers['Allow']
49-
return res.headers['Allow']
50-
else
51-
fail_with(Failure::UnexpectedReply, "#{peer} - No Allow header identified")
52-
end
53-
else
54-
fail_with(Failure::Unreachable, "#{peer} - Failed to respond")
55-
end
47+
48+
fail_with(Failure::Unreachable, "#{peer} - Failed to respond") unless res
49+
fail_with(Failure::UnexpectedReply, "#{peer} - No Allow header identified") unless res.headers['Allow']
50+
res.headers['Allow']
5651
end
5752

5853
def run_host(ip)
@@ -65,33 +60,29 @@ def run_host(ip)
6560

6661
for counter in 1..datastore['REPEAT']
6762
allows = get_allow_header(ip)
68-
unless uniques.include?(allows) # no need to re-process non-new items
69-
uniques << allows
70-
if allows =~ bug_61207
71-
if allows.split(',').length > allows.split(',').uniq.length # check for repeat items
72-
if datastore['BUGS']
73-
print_status('Some methods were sent multiple times in the list. ' +
74-
'This is a bug, but harmless. It may be Apache bug #61207.')
75-
end
76-
else
77-
vprint_status("Request #{counter}: [Standard Response] -> #{allows}")
78-
end
79-
elsif allows =~ bug_1717682 && datastore['BUGS']
80-
print_status('The list of methods was space-separated instead of comma-separated. ' +
81-
'This is a bug, but harmless. It may be Launchpad bug #1717682.')
63+
next if uniques.include?(allows) # no need to re-process non-new items
64+
uniques << allows
65+
if allows =~ bug_61207
66+
if allows.split(',').length > allows.split(',').uniq.length # check for repeat items
67+
print_status('Some methods were sent multiple times in the list. ' +
68+
'This is a bug, but harmless. It may be Apache bug #61207.') if datastore['BUGS']
8269
else
83-
print_good("Request #{counter}: [OptionsBleed Response] -> #{allows}")
84-
unless already_reported
85-
report_vuln(
86-
:host => ip,
87-
:port => rport,
88-
:name => self.name,
89-
:refs => self.references
90-
)
91-
already_reported = true
92-
end
70+
vprint_status("Request #{counter}: [Standard Response] -> #{allows}")
9371
end
72+
elsif allows =~ bug_1717682 && datastore['BUGS']
73+
print_status('The list of methods was space-separated instead of comma-separated. ' +
74+
'This is a bug, but harmless. It may be Launchpad bug #1717682.')
75+
else
76+
print_good("Request #{counter}: [OptionsBleed Response] -> #{allows}")
9477
end
78+
next unless already_reported
79+
report_vuln(
80+
:host => ip,
81+
:port => rport,
82+
:name => self.name,
83+
:refs => self.references
84+
)
85+
already_reported = true
9586
end
9687
end
9788
end

0 commit comments

Comments
 (0)