Skip to content

Commit c25a5d3

Browse files
committed
Fixed a bunch of rubocop errors
1 parent 34cf90a commit c25a5d3

File tree

1 file changed

+22
-30
lines changed

1 file changed

+22
-30
lines changed

modules/auxiliary/scanner/http/title.rb

Lines changed: 22 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77
require 'cgi'
88

99
class Metasploit3 < Msf::Auxiliary
10-
1110
# Exploit mixins should be called first
1211
include Msf::Exploit::Remote::HttpClient
1312
# Scanner mixin should be near last
@@ -25,53 +24,46 @@ def initialize
2524
[
2625
OptBool.new('STORE_NOTES', [ true, 'Store the captured information in notes. Use "notes -t http.title" to view', true ]),
2726
OptBool.new('SHOW_ERRORS', [ true, 'Show error messages relating to grabbing titles on the console', true ]),
28-
OptBool.new('SHOW_TITLES', [ true, 'Show the titles on the console as they are grabbed', true ]),
29-
], self.class)
27+
OptBool.new('SHOW_TITLES', [ true, 'Show the titles on the console as they are grabbed', true ])
28+
], self.class)
3029

3130
deregister_options('VHOST')
3231
end
3332

3433
def run_host(target_host)
3534
begin
36-
res = send_request_cgi({
37-
'uri' => '/',
38-
'method' => 'GET',
39-
})
35+
res = send_request_cgi('uri' => '/',
36+
'method' => 'GET')
4037

4138
if res.nil?
4239
print_error("No response from #{target_host}:#{rport}") if datastore['SHOW_ERRORS'] == true
43-
else
40+
else
4441
server_header = nil
4542
location_header = nil
46-
if not res.headers.nil?
47-
res.headers.each do |key,val|
48-
location_header = val if key.downcase == 'location'
49-
server_header = val if key.downcase == 'server'
43+
if !res.headers.nil?
44+
res.headers.each do |key, val|
45+
location_header = val if key.downcase == 'location'
46+
server_header = val if key.downcase == 'server'
5047
end
5148
else
5249
print_error("No headers from #{target_host}:#{rport}") if datastore['SHOW_ERRORS'] == true
5350
end
5451

55-
if not res.body.nil?
56-
# Very basic, just match the first title tag we come to.
57-
rx = /<title>[\n\t\s]*(?<title>.+?)[\s\n\t]*<\/title>/im.match(res.body.to_s)
58-
if rx
59-
rx[:title].strip!
60-
if not rx[:title] == ''
61-
rx_title = CGI.unescapeHTML(rx[:title])
62-
print_status("[#{target_host}:#{rport}] [C:#{res.code}] [R:#{location_header}] [S:#{server_header}] #{rx_title}") if datastore['SHOW_TITLES'] == true
63-
if datastore['STORE_NOTES'] == true then
64-
notedata = { code: res.code, port: rport, server: server_header, title: rx_title, redirect: location_header}
65-
report_note(:host => target_host, :type => "http.title", :data => notedata)
66-
end
67-
else
68-
print_error("No webpage title from #{target_host}:#{rport}") if datastore['SHOW_ERRORS'] == true
69-
end
70-
else
71-
print_error("No webpage title from #{target_host}:#{rport}") if datastore['SHOW_ERRORS'] == true
52+
if !res.body.nil?
53+
# Very basic, just match the first title tag we come to.
54+
rx = %r{<title>[\n\t\s]*(?<title>.+?)[\s\n\t]*</title>}im.match(res.body.to_s.strip)
55+
if rx && rx[:title] != ''
56+
rx_title = CGI.unescapeHTML(rx[:title])
57+
print_status("[#{target_host}:#{rport}] [C:#{res.code}] [R:#{location_header}] [S:#{server_header}] #{rx_title}") if datastore['SHOW_TITLES'] == true
58+
if datastore['STORE_NOTES'] == true
59+
notedata = { code: res.code, port: rport, server: server_header, title: rx_title, redirect: location_header }
60+
report_note(host: target_host, type: "http.title", data: notedata)
7261
end
62+
else
63+
print_error("No webpage title from #{target_host}:#{rport}") if datastore['SHOW_ERRORS'] == true
64+
end
7365
else
74-
print_error("No webpage body from #{target_host}:#{rport}") if datastore['SHOW_ERRORS'] == true
66+
print_error("No webpage body from #{target_host}:#{rport}") if datastore['SHOW_ERRORS'] == true
7567
end
7668
end
7769

0 commit comments

Comments
 (0)