Skip to content

Commit 2c00a91

Browse files
Land #20107, modules/post/multi/gather: Resolve RuboCop violations
2 parents a0f200d + fab5a3b commit 2c00a91

39 files changed

+527
-315
lines changed

modules/post/multi/gather/apple_ios_backup.rb

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,11 @@ def initialize(info = {})
3232
stdapi_sys_config_getuid
3333
]
3434
}
35+
},
36+
'Notes' => {
37+
'Stability' => [CRASH_SAFE],
38+
'SideEffects' => [],
39+
'Reliability' => []
3540
}
3641
)
3742
)
@@ -241,7 +246,7 @@ def process_backup(path)
241246
store_loot('ios.backup.data', ctype, session, fdata, rname, "iOS Backup: #{rname}")
242247
rescue ::Interrupt
243248
raise $ERROR_INFO
244-
rescue ::Exception => e
249+
rescue StandardError => e
245250
print_error("Failed to download #{fname}: #{e.class} #{e}")
246251
end
247252

modules/post/multi/gather/aws_ec2_instance_metadata.rb

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,12 @@ def initialize(info = {})
2222
'SessionTypes' => %w[shell meterpreter],
2323
'References' => [
2424
[ 'URL', 'http://docs.aws.amazon.com/AWSEC2/latest/UserGuide/ec2-instance-metadata.html' ]
25-
]
25+
],
26+
'Notes' => {
27+
'Stability' => [CRASH_SAFE],
28+
'SideEffects' => [],
29+
'Reliability' => []
30+
}
2631
)
2732
)
2833

modules/post/multi/gather/aws_keys.rb

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,12 @@ def initialize(info = {})
2929
'References' => [
3030
[ 'URL', 'http://s3tools.org/kb/item14.htm' ],
3131
[ 'URL', 'http://docs.aws.amazon.com/cli/latest/userguide/cli-chap-getting-started.html#cli-config-files' ]
32-
]
32+
],
33+
'Notes' => {
34+
'Stability' => [CRASH_SAFE],
35+
'SideEffects' => [],
36+
'Reliability' => []
37+
}
3338
)
3439
)
3540
end

modules/post/multi/gather/check_malware.rb

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,15 +20,19 @@ def initialize(info = {})
2020
'License' => MSF_LICENSE,
2121
'Author' => [ 'sinn3r'],
2222
'Platform' => [ 'osx', 'win', 'linux' ],
23-
'SessionTypes' => [ 'shell', 'meterpreter' ]
23+
'SessionTypes' => [ 'shell', 'meterpreter' ],
24+
'Notes' => {
25+
'Stability' => [CRASH_SAFE],
26+
'SideEffects' => [],
27+
'Reliability' => []
28+
}
2429
)
2530
)
2631

2732
register_options(
2833
[
2934
OptString.new('APIKEY', [true, 'VirusTotal API key', '501caf66349cc7357eb4398ac3298fdd03dec01a3e2f3ad576525aa7b57a1987']),
3035
OptString.new('REMOTEFILE', [true, 'A file to check from the remote machine'])
31-
3236
]
3337
)
3438
end
@@ -43,11 +47,11 @@ def get_report(api_key, checksum)
4347
# The supplied module name is ambiguous: undefined method `register_autofilter_ports'
4448
#
4549
url = URI.parse('https://www.virustotal.com/vtapi/v2/file/report')
46-
req = Net::HTTP::Post.new(url.path, initheader = { 'Host' => 'www.virustotal.com' })
50+
req = Net::HTTP::Post.new(url.path, { 'Host' => 'www.virustotal.com' })
4751
req.set_form_data({ 'apikey' => api_key, 'resource' => checksum })
4852
http = Net::HTTP.new(url.host, url.port)
4953
http.use_ssl = true
50-
res = http.start { |http| http.request(req) }
54+
res = http.start { |h| h.request(req) }
5155

5256
unless res
5357
print_error("#{rhost} - Connection timed out")

modules/post/multi/gather/chrome_cookies.rb

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,12 @@ def initialize(info = {})
1515
'License' => MSF_LICENSE,
1616
'Author' => ['mangopdf <mangodotpdf[at]gmail.com>'],
1717
'Platform' => %w[linux unix bsd osx windows],
18-
'SessionTypes' => %w[meterpreter shell]
18+
'SessionTypes' => %w[meterpreter shell],
19+
'Notes' => {
20+
'Stability' => [CRASH_SAFE],
21+
'SideEffects' => [],
22+
'Reliability' => []
23+
}
1924
)
2025
)
2126

@@ -186,7 +191,7 @@ def get_cookies
186191
# Kills spawned chrome process in windows meterpreter sessions.
187192
# In OSX and Linux the meterpreter sessions would stop as well.
188193
if session.platform == 'windows'
189-
kill_output = cmd_exec "#{kill_cmd} #{chrome_pid}"
194+
cmd_exec "#{kill_cmd} #{chrome_pid}"
190195
end
191196
else
192197
# Using shell_command for backgrounding process (&)

modules/post/multi/gather/dbvis_enum.rb

Lines changed: 47 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -30,14 +30,19 @@ def initialize(info = {})
3030
stdapi_sys_config_getenv
3131
]
3232
}
33+
},
34+
'Notes' => {
35+
'Stability' => [CRASH_SAFE],
36+
'SideEffects' => [],
37+
'Reliability' => []
3338
}
3439
)
3540
)
3641
register_options(
3742
[
3843
OptString.new('PASSPHRASE', [false, 'The hardcoded passphrase used for encryption']),
3944
OptInt.new('ITERATION_COUNT', [false, 'The iteration count used in key derivation', 10])
40-
], super.class
45+
]
4146
)
4247
end
4348

@@ -138,6 +143,7 @@ def parse_new_config_file(raw_xml)
138143
db = {}
139144
dbfound = false
140145
version_found = false
146+
141147
# fetch config file
142148
raw_xml.each_line do |line|
143149
if version_found == false
@@ -155,7 +161,7 @@ def parse_new_config_file(raw_xml)
155161
db[:Namespace] = ''
156162
end
157163
# save
158-
dbs << db if (db[:Alias] && db[:Type] && db[:Server] && db[:Port])
164+
dbs << db if db[:Alias] && db[:Type] && db[:Server] && db[:Port]
159165
db = {}
160166
end
161167

@@ -204,21 +210,31 @@ def parse_new_config_file(raw_xml)
204210
end
205211

206212
# Fill the tab and report eligible servers
207-
dbs.each do |db|
208-
if ::Rex::Socket.is_ipv4?(db[:Server].to_s)
209-
print_good("Reporting #{db[:Server]}")
210-
report_host(host: db[:Server])
213+
dbs.each do |database|
214+
if ::Rex::Socket.is_ipv4?(database[:Server].to_s)
215+
print_good("Reporting #{database[:Server]}")
216+
report_host(host: database[:Server])
211217
end
212218

213-
db_table << [ db[:Alias], db[:Type], db[:Server], db[:Port], db[:Database], db[:Namespace], db[:UserID], db[:Password] ]
219+
db_table << [
220+
database[:Alias],
221+
database[:Type],
222+
database[:Server],
223+
database[:Port],
224+
database[:Database],
225+
database[:Namespace],
226+
database[:UserID],
227+
database[:Password]
228+
]
214229
report_cred(
215-
ip: db[:Server],
216-
port: db[:Port].to_i,
217-
service_name: db[:Type],
218-
username: db[:UserID],
219-
password: db[:Password]
230+
ip: database[:Server],
231+
port: database[:Port].to_i,
232+
service_name: database[:Type],
233+
username: database[:UserID],
234+
password: database[:Password]
220235
)
221236
end
237+
222238
return db_table
223239
end
224240

@@ -245,15 +261,15 @@ def parse_old_config_file(raw_xml)
245261
# fetch config file
246262
raw_xml.each_line do |line|
247263
if version_found == false
248-
vesrion_found = find_version(line)
264+
version_found = find_version(line)
249265
end
250266

251267
if line =~ /<Database id=/
252268
dbfound = true
253269
elsif line =~ %r{</Database>}
254270
dbfound = false
255271
# save
256-
dbs << db if (db[:Alias] && db[:Url])
272+
dbs << db if db[:Alias] && db[:Url]
257273
db = {}
258274
end
259275

@@ -287,33 +303,40 @@ def parse_old_config_file(raw_xml)
287303
end
288304

289305
# Fill the tab
290-
dbs.each do |db|
291-
if (db[:URL] =~ %r{[\S+\s+]+/+([\S+\s+]+):[\S+]+}i)
306+
dbs.each do |database|
307+
if (database[:URL] =~ %r{[\S+\s+]+/+([\S+\s+]+):[\S+]+}i)
292308
server = ::Regexp.last_match(1)
293309
if ::Rex::Socket.is_ipv4?(server)
294310
print_good("Reporting #{server}")
295311
report_host(host: server)
296312
end
297313
end
298-
db_table << [ db[:Alias], db[:Type], db[:URL], db[:UserID], db[:Password] ]
314+
db_table << [
315+
database[:Alias],
316+
database[:Type],
317+
database[:URL],
318+
database[:UserID],
319+
database[:Password]
320+
]
299321
report_cred(
300322
ip: server,
301323
port: '',
302-
service_name: db[:Type],
303-
username: db[:UserID],
304-
password: db[:Password]
324+
service_name: database[:Type],
325+
username: database[:UserID],
326+
password: database[:Password]
305327
)
306328
end
329+
307330
return db_table
308331
end
309332

310333
def find_version(tag)
311-
found = false
312334
if tag =~ %r{<Version>([\S+\s+]+)</Version>}i
313-
found = true
314335
print_good("DbVisualizer version: #{::Regexp.last_match(1)}")
336+
return true
315337
end
316-
found
338+
339+
false
317340
end
318341

319342
def report_cred(opts)
@@ -349,7 +372,7 @@ def decrypt_password(enc_password)
349372
des.decrypt
350373
des.key = dk
351374
des.iv = iv
352-
password = des.update(enc_password) + des.final
375+
des.update(enc_password) + des.final
353376
end
354377

355378
def get_derived_key

modules/post/multi/gather/dns_bruteforce.rb

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -16,18 +16,21 @@ def initialize(info = {})
1616
'License' => MSF_LICENSE,
1717
'Author' => [ 'Carlos Perez <carlos_perez[at]darkoperator.com>'],
1818
'Platform' => %w[bsd linux osx solaris win],
19-
'SessionTypes' => [ 'meterpreter', 'shell' ]
19+
'SessionTypes' => [ 'meterpreter', 'shell' ],
20+
'Notes' => {
21+
'Stability' => [CRASH_SAFE],
22+
'SideEffects' => [],
23+
'Reliability' => []
24+
}
2025
)
2126
)
2227
register_options(
2328
[
24-
2529
OptString.new('DOMAIN', [true, 'Domain to do a forward lookup bruteforce against.']),
2630
OptPath.new('NAMELIST', [
2731
true, 'List of hostnames or subdomains to use.',
2832
::File.join(Msf::Config.data_directory, 'wordlists', 'namelist.txt')
2933
])
30-
3134
]
3235
)
3336
end
@@ -92,12 +95,12 @@ def proccess_win(data, ns_opt)
9295
end
9396

9497
# Process the data returned by the host command
95-
def process_nix(r, ns_opt)
96-
r.each_line do |l|
97-
data = l.scan(/(\S*) has address (\S*)$/)
98-
next if data.empty?
98+
def process_nix(data, ns_opt)
99+
data.each_line do |line|
100+
dns_data = line.scan(/(\S*) has address (\S*)$/)
101+
next if dns_data.empty?
99102

100-
data.each do |e|
103+
dns_data.each do |e|
101104
print_good("#{ns_opt} #{e[1]}")
102105
report_host(host: e[1], name: ns_opt.strip)
103106
end

modules/post/multi/gather/dns_reverse_lookup.rb

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,19 +16,21 @@ def initialize(info = {})
1616
'License' => MSF_LICENSE,
1717
'Author' => [ 'Carlos Perez <carlos_perez[at]darkoperator.com>'],
1818
'Platform' => %w[bsd linux osx solaris win],
19-
'SessionTypes' => [ 'meterpreter', 'shell' ]
19+
'SessionTypes' => [ 'meterpreter', 'shell' ],
20+
'Notes' => {
21+
'Stability' => [CRASH_SAFE],
22+
'SideEffects' => [],
23+
'Reliability' => []
24+
}
2025
)
2126
)
2227
register_options(
2328
[
24-
2529
OptAddressRange.new('RHOSTS', [true, 'IP Range to perform reverse lookup against.'])
26-
2730
]
2831
)
2932
end
3033

31-
# Run Method for when run command is issued
3234
def run
3335
iprange = datastore['RHOSTS']
3436
print_status("Performing DNS Reverse Lookup for IP range #{iprange}")

modules/post/multi/gather/dns_srv_lookup.rb

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,12 @@ def initialize(info = {})
1717
'License' => MSF_LICENSE,
1818
'Author' => [ 'Carlos Perez <carlos_perez[at]darkoperator.com>'],
1919
'Platform' => %w[bsd linux osx solaris win],
20-
'SessionTypes' => [ 'meterpreter', 'shell' ]
20+
'SessionTypes' => [ 'meterpreter', 'shell' ],
21+
'Notes' => {
22+
'Stability' => [CRASH_SAFE],
23+
'SideEffects' => [],
24+
'Reliability' => []
25+
}
2126
)
2227
)
2328
register_options(
@@ -156,7 +161,6 @@ def nslookup_srv_consume(srv, ns_out)
156161
def get_ip(host)
157162
ip_add = []
158163
cmd_exec('host', " #{host}").each_line do |l|
159-
ip = ''
160164
ip = l.scan(/has address (\S*)$/).join
161165
ip_add << ip if ip != ''
162166
end

modules/post/multi/gather/docker_creds.rb

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,12 @@ def initialize(info = {})
2222
'License' => MSF_LICENSE,
2323
'Author' => ['Flibustier'],
2424
'Platform' => %w[bsd linux osx unix],
25-
'SessionTypes' => ['shell']
25+
'SessionTypes' => ['shell'],
26+
'Notes' => {
27+
'Stability' => [CRASH_SAFE],
28+
'SideEffects' => [],
29+
'Reliability' => []
30+
}
2631
)
2732
)
2833
end

0 commit comments

Comments
 (0)