Skip to content

Commit a0f200d

Browse files
authored
Merge pull request rapid7#20100 from bcoles/rubocop-modules-post-windows-gather
modules/post/windows/gather: Resolve RuboCop violations
2 parents 0c7ddd5 + 7b8cf0b commit a0f200d

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

62 files changed

+1109
-812
lines changed

modules/post/windows/gather/ad_to_sqlite.rb

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,12 @@ def initialize(info = {})
2323
'Stuart Morgan <stuart.morgan[at]mwrinfosecurity.com>'
2424
],
2525
'Platform' => [ 'win' ],
26-
'SessionTypes' => [ 'meterpreter' ]
26+
'SessionTypes' => [ 'meterpreter' ],
27+
'Notes' => {
28+
'Stability' => [CRASH_SAFE],
29+
'SideEffects' => [],
30+
'Reliability' => []
31+
}
2732
)
2833
)
2934

@@ -35,15 +40,14 @@ def initialize(info = {})
3540
])
3641
end
3742

38-
# Entry point
3943
def run
4044
max_search = datastore['MAX_SEARCH']
4145

4246
db, dbfile = create_sqlite_db
43-
print_status "Temporary database created: #{dbfile.path}"
47+
print_status("Temporary database created: #{dbfile.path}")
4448

4549
# Download the list of groups from Active Directory
46-
vprint_status 'Retrieving AD Groups'
50+
vprint_status('Retrieving AD Groups')
4751
begin
4852
group_fields = ['distinguishedName', 'objectSid', 'samAccountType', 'sAMAccountName', 'whenChanged', 'whenCreated', 'description', 'groupType', 'adminCount', 'comment', 'managedBy', 'cn']
4953
if datastore['GROUP_FILTER'].nil? || datastore['GROUP_FILTER'].empty?
@@ -64,8 +68,8 @@ def run
6468
end
6569

6670
# Go through each of the groups and identify the individual users in each group
67-
vprint_status "Groups retrieval completed: #{groups[:results].size} group(s)"
68-
vprint_status 'Retrieving AD Group Membership'
71+
vprint_status("Groups retrieval completed: #{groups[:results].size} group(s)")
72+
vprint_status('Retrieving AD Group Membership')
6973
users_fields = ['distinguishedName', 'objectSid', 'sAMAccountType', 'sAMAccountName', 'displayName', 'description', 'logonCount', 'userAccountControl', 'userPrincipalName', 'whenChanged', 'whenCreated', 'primaryGroupID', 'badPwdCount', 'comment', 'title', 'cn', 'adminCount', 'manager']
7074

7175
remaining_groups = groups[:results]
@@ -254,7 +258,7 @@ def run
254258
group_gather.map(&:join)
255259
end
256260

257-
vprint_status 'Retrieving computers'
261+
vprint_status('Retrieving computers')
258262
begin
259263
computer_filter = '(objectClass=computer)'
260264
computer_fields = ['distinguishedName', 'objectSid', 'cn', 'dNSHostName', 'sAMAccountType', 'sAMAccountName', 'displayName', 'logonCount', 'userAccountControl', 'whenChanged', 'whenCreated', 'primaryGroupID', 'badPwdCount', 'operatingSystem', 'operatingSystemServicePack', 'operatingSystemVersion', 'description', 'comment']

modules/post/windows/gather/arp_scanner.rb

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,13 +14,18 @@ def initialize(info = {})
1414
info,
1515
'Name' => 'Windows Gather ARP Scanner',
1616
'Description' => %q{
17-
This Module will perform an ARP scan for a given IP range through a
18-
Meterpreter Session.
17+
This module will perform an ARP scan for a given IP range through a
18+
Meterpreter session.
1919
},
2020
'License' => MSF_LICENSE,
2121
'Author' => [ 'Carlos Perez <carlos_perez[at]darkoperator.com>'],
2222
'Platform' => [ 'win' ],
2323
'SessionTypes' => [ 'meterpreter'],
24+
'Notes' => {
25+
'Stability' => [CRASH_SAFE],
26+
'SideEffects' => [],
27+
'Reliability' => []
28+
},
2429
'Compat' => {
2530
'Meterpreter' => {
2631
'Commands' => %w[
@@ -34,14 +39,13 @@ def initialize(info = {})
3439
[
3540
OptString.new('RHOSTS', [true, 'The target address range or CIDR identifier', nil]),
3641
OptInt.new('THREADS', [false, 'The number of concurrent threads', 10])
37-
3842
]
3943
)
4044
end
4145

42-
# Run Method for when run command is issued
4346
def run
44-
print_status("Running module against #{sysinfo['Computer']}")
47+
hostname = sysinfo.nil? ? cmd_exec('hostname') : sysinfo['Computer']
48+
print_status("Running module against #{hostname} (#{session.session_host})")
4549
arp_scan(datastore['RHOSTS'], datastore['THREADS'])
4650
end
4751

@@ -63,7 +67,7 @@ def arp_scan(cidr, threads)
6367
iplst << ipa
6468
end
6569

66-
while (!iplst.nil? && !iplst.empty?)
70+
while !iplst.nil? && !iplst.empty?
6771
a = []
6872
1.upto(threads) do
6973
a << framework.threads.spawn("Module(#{refname})", false, iplst.shift) do |ip_text|

modules/post/windows/gather/bitcoin_jacker.rb

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,11 @@ def initialize(info = {})
2626
],
2727
'Platform' => [ 'win' ], # TODO: Several more platforms host Bitcoin wallets...
2828
'SessionTypes' => [ 'meterpreter' ],
29+
'Notes' => {
30+
'Stability' => [CRASH_SAFE],
31+
'SideEffects' => [],
32+
'Reliability' => []
33+
},
2934
'Compat' => {
3035
'Meterpreter' => {
3136
'Commands' => %w[
@@ -90,7 +95,7 @@ def jack_wallet(wallet_path)
9095

9196
begin
9297
data = read_file(wallet_path) || ''
93-
rescue ::Exception => e
98+
rescue StandardError => e
9499
print_error("Failed to download #{wallet_path}: #{e.class} #{e}")
95100
return
96101
end

modules/post/windows/gather/bitlocker_fvek.rb

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,13 @@ def initialize(info = {})
2626
'Author' => ['Danil Bazin <danil.bazin[at]hsc.fr>'], # @danilbaz
2727
'References' => [
2828
['URL', 'https://github.com/libyal/libbde/blob/master/documentation/BitLocker Drive Encryption (BDE) format.asciidoc'],
29-
['URL', 'http://www.hsc.fr/ressources/outils/dislocker/']
29+
['URL', 'https://web.archive.org/web/20170914195545/http://www.hsc.fr/ressources/outils/dislocker/'],
3030
],
31+
'Notes' => {
32+
'Stability' => [CRASH_SAFE],
33+
'SideEffects' => [],
34+
'Reliability' => []
35+
},
3136
'Compat' => {
3237
'Meterpreter' => {
3338
'Commands' => %w[
@@ -129,7 +134,7 @@ def run
129134
if !fvek.blank?
130135
stored_path = store_loot('windows.file', 'application/octet-stream',
131136
session, fvek)
132-
print_good("Successfuly extract FVEK in #{stored_path}")
137+
print_good("Successfully extracted FVEK in #{stored_path}")
133138
print_good('This hard drive could later be decrypted using : dislocker -k <key_file> ...')
134139
else
135140
print_error('Failed to generate FVEK, wrong recovery key?')

0 commit comments

Comments
 (0)