Skip to content

Commit 4577a3d

Browse files
authored
Update redoc_exposed.rb
1 parent 33825d0 commit 4577a3d

File tree

1 file changed

+14
-15
lines changed

1 file changed

+14
-15
lines changed

modules/auxiliary/scanner/http/redoc_exposed.rb

Lines changed: 14 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -25,14 +25,17 @@ def initialize(info = {})
2525
'Stability' => [CRASH_SAFE], # GET requests only; should not crash or disrupt the target service
2626
'Reliability' => [], # Does not establish sessions; leaving this empty is acceptable
2727
'SideEffects' => [] # Add IOC_IN_LOGS if server logs may record these requests
28+
},
29+
'DefaultOptions' => {
30+
'RPORT' => 80
31+
# SSL is registered by default; set here only if you want a non-default value
32+
# 'SSL' => false
2833
}
2934
)
3035
)
3136

3237
register_options(
3338
[
34-
Opt::RPORT(80),
35-
OptBool.new('SSL', [true, 'Negotiate SSL/TLS for outgoing connections', false]),
3639
OptString.new('REDOC_PATHS', [
3740
false,
3841
'Comma-separated list of paths to probe (overrides defaults)',
@@ -48,36 +51,32 @@ def redoc_like?(res)
4851

4952
# Prefer DOM checks
5053
doc = res.get_html_document
51-
if doc
52-
return true if doc.at_css('redoc, redoc-, #redoc')
53-
return true if doc.css('script[src*="redoc"]').any?
54-
return true if doc.css('script[src*="redoc.standalone"]').any?
54+
if doc && (doc.at_css('redoc, redoc-, #redoc') ||
55+
doc.css('script[src*="redoc"]').any? ||
56+
doc.css('script[src*="redoc.standalone"]').any?)
57+
return true
5558
end
5659

5760
# Fallback to body/title heuristics
5861
title = res.get_html_title.to_s
5962
body = res.body.to_s
60-
61-
return true if title =~ /redoc/i
62-
return true if body =~ /<redoc-?/i
63-
return true if body =~ /redoc(\.standalone)?\.js/i
63+
return true if title =~ /redoc/i || body =~ /<redoc-?/i || body =~ /redoc(\.standalone)?\.js/i
6464

6565
false
6666
end
6767

6868
def check_path(path)
69-
res = send_request_cgi({ 'method' => 'GET', 'uri' => normalize_uri(path) })
70-
redoc_like?(res)
69+
redoc_like?(send_request_cgi({ 'method' => 'GET', 'uri' => normalize_uri(path) }))
7170
end
7271

7372
def run_host(ip)
7473
vprint_status("#{ip} - scanning for ReDoc")
7574

7675
paths =
77-
if (ds = datastore['REDOC_PATHS']) && !ds.empty?
78-
ds.split(',').map(&:strip)
79-
else
76+
if datastore['REDOC_PATHS'].to_s.empty?
8077
['/redoc', '/redoc/', '/docs', '/api/docs', '/openapi']
78+
else
79+
datastore['REDOC_PATHS'].split(',').map(&:strip)
8180
end
8281

8382
hit = paths.find { |p| check_path(p) }

0 commit comments

Comments
 (0)