Skip to content

Commit ac9669d

Browse files
authored
Merge pull request rapid7#20092 from bcoles/rubocop-modules-post-windows-gather-credentials
modules/post/windows/gather/credentials: Resolve RuboCop violations
2 parents 912931d + 333c38b commit ac9669d

Some content is hidden

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

79 files changed

+621
-500
lines changed

modules/post/windows/gather/credentials/adi_irc.rb

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
##
55

66
class MetasploitModule < Msf::Post
7-
# this associative array defines the artifacts known to PackRat
87
include Msf::Post::File
98
include Msf::Post::Windows::UserProfiles
109
include Msf::Post::Windows::Packrat
@@ -53,7 +52,7 @@ def initialize(info = {})
5352
PackRat is a post-exploitation module that gathers file and information artifacts from end users' systems.
5453
PackRat searches for and downloads files of interest (such as config files, and received and deleted emails) and extracts information (such as contacts and usernames and passwords), using regexp, JSON, XML, and SQLite queries.
5554
Further details can be found in the module documentation.
56-
This is a module that searches for credentials stored on AdiIRC Client in a windows remote host.
55+
This module searches for credentials stored on AdiIRC Client in a windows remote host.
5756
},
5857
'License' => MSF_LICENSE,
5958
'Author' => [
@@ -94,6 +93,6 @@ def run
9493
run_packrat(userprofile, ARTIFACTS)
9594
end
9695

97-
print_status 'PackRat credential sweep Completed'
96+
print_status 'PackRat credential sweep completed'
9897
end
9998
end

modules/post/windows/gather/credentials/aim.rb

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,9 @@
1-
# frozen_string_literal: true
2-
31
##
42
# This module requires Metasploit: https://metasploit.com/download
53
# Current source: https://github.com/rapid7/metasploit-framework
64
##
75

86
class MetasploitModule < Msf::Post
9-
# this associative array defines the artifacts known to PackRat
107
include Msf::Post::File
118
include Msf::Post::Windows::UserProfiles
129
include Msf::Post::Windows::Packrat
@@ -79,7 +76,7 @@ def initialize(info = {})
7976
PackRat is a post-exploitation module that gathers file and information artifacts from end users' systems.
8077
PackRat searches for and downloads files of interest (such as config files, and received and deleted emails) and extracts information (such as contacts and usernames and passwords), using regexp, JSON, XML, and SQLite queries.
8178
Further details can be found in the module documentation.
82-
This is a module that searches for Aim credentials on a windows remote host.
79+
This module searches for Aim credentials on a Windows host.
8380
},
8481
'License' => MSF_LICENSE,
8582
'Author' => [
@@ -124,6 +121,6 @@ def run
124121
run_packrat(userprofile, ARTIFACTS)
125122
end
126123

127-
print_status 'PackRat credential sweep Completed'
124+
print_status 'PackRat credential sweep completed'
128125
end
129126
end

modules/post/windows/gather/credentials/avira_password.rb

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,11 @@ def initialize(info = {})
1919
'Author' => [ 'Robert Kugler / robertchrk'],
2020
'Platform' => [ 'win' ],
2121
'SessionTypes' => [ 'meterpreter' ],
22+
'Notes' => {
23+
'Stability' => [CRASH_SAFE],
24+
'SideEffects' => [],
25+
'Reliability' => []
26+
},
2227
'Compat' => {
2328
'Meterpreter' => {
2429
'Commands' => %w[
@@ -35,8 +40,9 @@ def initialize(info = {})
3540
end
3641

3742
def run
38-
print_status('Checking default location...')
39-
check_programdata('C:\\ProgramData\\Avira\\Antivirus\\CONFIG\\AVWIN.INI')
43+
path = 'C:\\ProgramData\\Avira\\Antivirus\\CONFIG\\AVWIN.INI'
44+
print_status("Checking default location (#{path}) ...")
45+
check_programdata(path)
4046
end
4147

4248
def check_programdata(path)

modules/post/windows/gather/credentials/bulletproof_ftp.rb

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,11 @@ def initialize(info = {})
2222
'Author' => [ 'juan vazquez'],
2323
'Platform' => [ 'win' ],
2424
'SessionTypes' => [ 'meterpreter' ],
25+
'Notes' => {
26+
'Stability' => [CRASH_SAFE],
27+
'SideEffects' => [],
28+
'Reliability' => []
29+
},
2530
'Compat' => {
2631
'Meterpreter' => {
2732
'Commands' => %w[

modules/post/windows/gather/credentials/carotdav_ftp.rb

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
##
55

66
class MetasploitModule < Msf::Post
7-
# this associative array defines the artifacts known to PackRat
87
include Msf::Post::File
98
include Msf::Post::Windows::UserProfiles
109
include Msf::Post::Windows::Packrat
@@ -45,7 +44,7 @@ def initialize(info = {})
4544
PackRat is a post-exploitation module that gathers file and information artifacts from end users' systems.
4645
PackRat searches for and downloads files of interest (such as config files, and received and deleted emails) and extracts information (such as contacts and usernames and passwords), using regexp, JSON, XML, and SQLite queries.
4746
Further details can be found in the module documentation.
48-
This is a module that searches for credentials stored on CarotDAV FTP Client in a windows remote host.
47+
This module searches for credentials stored on CarotDAV FTP Client in a windows remote host.
4948
},
5049
'License' => MSF_LICENSE,
5150
'Author' => [
@@ -86,6 +85,6 @@ def run
8685
run_packrat(userprofile, ARTIFACTS)
8786
end
8887

89-
print_status 'PackRat credential sweep Completed'
88+
print_status 'PackRat credential sweep completed'
9089
end
9190
end

modules/post/windows/gather/credentials/chrome.rb

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,12 @@
1-
# frozen_string_literal: true
2-
31
##
42
# This module requires Metasploit: https://metasploit.com/download
53
# Current source: https://github.com/rapid7/metasploit-framework
64
##
75

86
class MetasploitModule < Msf::Post
9-
# this associative array defines the artifacts known to PackRat
107
include Msf::Post::File
118
include Msf::Post::Windows::UserProfiles
129
include Msf::Post::Windows::Packrat
13-
1410
include Msf::Exploit::Deprecated
1511

1612
deprecated nil, 'The post/windows/gather/enum_browsers module now supersedes this module'
@@ -97,7 +93,7 @@ def initialize(info = {})
9793
PackRat is a post-exploitation module that gathers file and information artifacts from end users' systems.
9894
PackRat searches for and downloads files of interest (such as config files, and received and deleted emails) and extracts information (such as contacts and usernames and passwords), using regexp, JSON, XML, and SQLite queries.
9995
Further details can be found in the module documentation.
100-
This is a module that searches for credentials stored on Chrome in a windows remote host.
96+
This module searches for credentials stored on Chrome in a windows remote host.
10197
},
10298
'License' => MSF_LICENSE,
10399
'Author' => [
@@ -142,6 +138,6 @@ def run
142138
run_packrat(userprofile, ARTIFACTS)
143139
end
144140

145-
print_status 'PackRat credential sweep Completed'
141+
print_status 'PackRat credential sweep completed'
146142
end
147143
end

modules/post/windows/gather/credentials/comodo.rb

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,13 @@
1-
# frozen_string_literal: true
2-
31
##
42
# This module requires Metasploit: https://metasploit.com/download
53
# Current source: https://github.com/rapid7/metasploit-framework
64
##
75

86
class MetasploitModule < Msf::Post
9-
# this associative array defines the artifacts known to PackRat
107
include Msf::Post::File
118
include Msf::Post::Windows::UserProfiles
129
include Msf::Post::Windows::Packrat
10+
1311
ARTIFACTS =
1412
{
1513
application: 'comodo',
@@ -127,7 +125,7 @@ def initialize(info = {})
127125
PackRat is a post-exploitation module that gathers file and information artifacts from end users' systems.
128126
PackRat searches for and downloads files of interest (such as config files, and received and deleted emails) and extracts information (such as contacts and usernames and passwords), using regexp, JSON, XML, and SQLite queries.
129127
Further details can be found in the module documentation.
130-
This is a module that searches for credentials stored in Comodo on a windows remote host.
128+
This module searches for credentials stored in Comodo on a remote Windows host.
131129
},
132130
'License' => MSF_LICENSE,
133131
'Author' => [
@@ -153,9 +151,12 @@ def initialize(info = {})
153151
OptBool.new('EXTRACT_DATA', [false, 'Extract data and stores in a separate file', true]),
154152
# enumerates the options based on the artifacts that are defined below
155153
OptEnum.new('ARTIFACTS', [
156-
false, 'Type of artifacts to collect', 'All', ARTIFACTS[:gatherable_artifacts].map do |k|
157-
k[:filetypes]
158-
end.uniq.unshift('All')
154+
false,
155+
'Type of artifacts to collect',
156+
'All',
157+
ARTIFACTS[:gatherable_artifacts].map do |k|
158+
k[:filetypes]
159+
end.uniq.unshift('All')
159160
])
160161
]
161162
)
@@ -172,6 +173,6 @@ def run
172173
run_packrat(userprofile, ARTIFACTS)
173174
end
174175

175-
print_status 'PackRat credential sweep Completed'
176+
print_status('PackRat credential sweep completed')
176177
end
177178
end

modules/post/windows/gather/credentials/coolnovo.rb

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,9 @@
1-
# frozen_string_literal: true
2-
31
##
42
# This module requires Metasploit: https://metasploit.com/download
53
# Current source: https://github.com/rapid7/metasploit-framework
64
##
75

86
class MetasploitModule < Msf::Post
9-
# this associative array defines the artifacts known to PackRat
107
include Msf::Post::File
118
include Msf::Post::Windows::UserProfiles
129
include Msf::Post::Windows::Packrat
@@ -48,6 +45,7 @@ class MetasploitModule < Msf::Post
4845

4946
]
5047
}.freeze
48+
5149
def initialize(info = {})
5250
super(
5351
update_info(
@@ -57,7 +55,7 @@ def initialize(info = {})
5755
PackRat is a post-exploitation module that gathers file and information artifacts from end users' systems.
5856
PackRat searches for and downloads files of interest (such as config files, and received and deleted emails) and extracts information (such as contacts and usernames and passwords), using regexp, JSON, XML, and SQLite queries.
5957
Further details can be found in the module documentation.
60-
This is a module that searches for Coolnovo credentials on a windows remote host.
58+
This module searches for Coolnovo credentials on a Windows host.
6159
},
6260
'License' => MSF_LICENSE,
6361
'Author' => [
@@ -102,6 +100,6 @@ def run
102100
run_packrat(userprofile, ARTIFACTS)
103101
end
104102

105-
print_status 'PackRat credential sweep Completed'
103+
print_status 'PackRat credential sweep completed'
106104
end
107105
end

modules/post/windows/gather/credentials/coreftp.rb

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,12 @@ def initialize(info = {})
2121
'License' => MSF_LICENSE,
2222
'Author' => ['theLightCosine'],
2323
'Platform' => [ 'win' ],
24-
'SessionTypes' => [ 'meterpreter' ]
24+
'SessionTypes' => [ 'meterpreter' ],
25+
'Notes' => {
26+
'Stability' => [CRASH_SAFE],
27+
'SideEffects' => [],
28+
'Reliability' => []
29+
}
2530
)
2631
)
2732
end
@@ -81,7 +86,7 @@ def run
8186

8287
# Merge in the service data and create our Login
8388
login_data.merge!(service_data)
84-
login = create_credential_login(login_data)
89+
create_credential_login(login_data)
8590
end
8691
rescue StandardError
8792
print_error("Cannot Access User SID: #{hive['HKU']}")

modules/post/windows/gather/credentials/credential_collector.rb

Lines changed: 14 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,18 @@ def initialize(info = {})
1111
update_info(
1212
info,
1313
'Name' => 'Windows Gather Credential Collector',
14-
'Description' => %q{ This module harvests credentials found on the host and stores them in the database.},
14+
'Description' => %q{
15+
This module harvests credentials found on the host and stores them in the database.
16+
},
1517
'License' => MSF_LICENSE,
1618
'Author' => [ 'tebo[at]attackresearch.com'],
1719
'Platform' => [ 'win' ],
1820
'SessionTypes' => [ 'meterpreter'],
21+
'Notes' => {
22+
'Stability' => [CRASH_SAFE],
23+
'SideEffects' => [],
24+
'Reliability' => []
25+
},
1926
'Compat' => {
2027
'Meterpreter' => {
2128
'Commands' => %w[
@@ -28,15 +35,9 @@ def initialize(info = {})
2835
)
2936
end
3037

31-
# Run Method for when run command is issued
3238
def run
33-
print_status("Running module against #{sysinfo['Computer']}")
34-
# Collect even without a database to store them.
35-
if session.framework.db.active
36-
db_ok = true
37-
else
38-
db_ok = false
39-
end
39+
hostname = sysinfo.nil? ? cmd_exec('hostname') : sysinfo['Computer']
40+
print_status("Running module against #{hostname} (#{session.session_host})")
4041

4142
# Make sure we're rockin Priv and Incognito
4243
session.core.use('priv') if !session.priv
@@ -46,16 +47,15 @@ def run
4647
begin
4748
hashes = client.priv.sam_hashes
4849
rescue StandardError
49-
print_error('Error accessing hashes, did you migrate to a process that matched the target\'s architecture?')
50-
return
50+
fail_with(Failure::Unknown, "Error accessing hashes, did you migrate to a process that matched the target's architecture?")
5151
end
5252

5353
# Target infos for the db record
5454
addr = session.session_host
5555
# client.framework.db.report_host(:host => addr, :state => Msf::HostState::Alive)
5656

5757
# Record hashes to the running db instance
58-
print_good 'Collecting hashes...'
58+
print_good('Collecting hashes...')
5959

6060
hashes.each do |hash|
6161
# Build service information
@@ -107,7 +107,8 @@ def run
107107
data[:update] = :unique_data
108108

109109
print_line " #{data[:data]}"
110-
report_note(data) if db_ok
110+
111+
report_note(data)
111112
end
112113
end
113114
end

0 commit comments

Comments
 (0)