Skip to content

Commit b800051

Browse files
committed
Land rapid7#3746, reinstate DB_ALL_CREDS
2 parents b9c8eb7 + ef748fd commit b800051

File tree

17 files changed

+87
-2
lines changed

17 files changed

+87
-2
lines changed

lib/msf/core/auxiliary/auth_brute.rb

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,53 @@ def setup
4949
@@max_per_service = nil
5050
end
5151

52+
# This method takes a {Metasploit::Framework::CredentialCollection} and prepends existing NTLMHashes
53+
# from the database. This allows the users to use the DB_ALL_CREDS option.
54+
#
55+
# @param [Metasploit::Framework::CredentialCollection] the credential collection to add to
56+
# @return [Metasploit::Framework::CredentialCollection] the modified Credentialcollection
57+
def prepend_db_hashes(cred_collection)
58+
if datastore['DB_ALL_CREDS'] && framework.db.active
59+
creds = Metasploit::Credential::Core.joins(:private).where(metasploit_credential_privates: { type: 'Metasploit::Credential::NTLMHash' }, workspace_id: myworkspace.id)
60+
creds.each do |cred|
61+
cred_collection.prepend_cred(cred.to_credential)
62+
end
63+
end
64+
cred_collection
65+
end
66+
67+
# This method takes a {Metasploit::Framework::CredentialCollection} and prepends existing SSHKeys
68+
# from the database. This allows the users to use the DB_ALL_CREDS option.
69+
#
70+
# @param [Metasploit::Framework::CredentialCollection] the credential collection to add to
71+
# @return [Metasploit::Framework::CredentialCollection] the modified Credentialcollection
72+
def prepend_db_keys(cred_collection)
73+
if datastore['DB_ALL_CREDS'] && framework.db.active
74+
creds = Metasploit::Credential::Core.joins(:private).where(metasploit_credential_privates: { type: 'Metasploit::Credential::SSHKey' }, workspace_id: myworkspace.id)
75+
creds.each do |cred|
76+
cred_collection.prepend_cred(cred.to_credential)
77+
end
78+
end
79+
cred_collection
80+
end
81+
82+
# This method takes a {Metasploit::Framework::CredentialCollection} and prepends existing Password Credentials
83+
# from the database. This allows the users to use the DB_ALL_CREDS option.
84+
#
85+
# @param [Metasploit::Framework::CredentialCollection] the credential collection to add to
86+
# @return [Metasploit::Framework::CredentialCollection] the modified Credentialcollection
87+
def prepend_db_passwords(cred_collection)
88+
if datastore['DB_ALL_CREDS'] && framework.db.active
89+
creds = Metasploit::Credential::Core.joins(:private).where(metasploit_credential_privates: { type: 'Metasploit::Credential::Password' }, workspace_id: myworkspace.id)
90+
creds.each do |cred|
91+
cred_collection.prepend_cred(cred.to_credential)
92+
end
93+
end
94+
cred_collection
95+
end
96+
97+
98+
5299
# Checks all three files for usernames and passwords, and combines them into
53100
# one credential list to apply against the supplied block. The block (usually
54101
# something like do_login(user,pass) ) is responsible for actually recording

modules/auxiliary/scanner/afp/afp_login.rb

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,8 @@ def run_host(ip)
5454
user_as_pass: datastore['USER_AS_PASS'],
5555
)
5656

57+
cred_collection = prepend_db_passwords(cred_collection)
58+
5759
scanner = Metasploit::Framework::LoginScanner::AFP.new(
5860
host: ip,
5961
port: rport,

modules/auxiliary/scanner/db2/db2_auth.rb

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,8 @@ def run_host(ip)
5252
realm: datastore['DATABASE']
5353
)
5454

55+
cred_collection = prepend_db_passwords(cred_collection)
56+
5557
scanner = Metasploit::Framework::LoginScanner::DB2.new(
5658
host: ip,
5759
port: rport,

modules/auxiliary/scanner/ftp/ftp_login.rb

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,8 @@ def run_host(ip)
6666
prepended_creds: anonymous_creds
6767
)
6868

69+
cred_collection = prepend_db_passwords(cred_collection)
70+
6971
scanner = Metasploit::Framework::LoginScanner::FTP.new(
7072
host: ip,
7173
port: rport,

modules/auxiliary/scanner/http/axis_login.rb

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,8 @@ def run_host(ip)
7272
user_as_pass: datastore['USER_AS_PASS'],
7373
)
7474

75+
cred_collection = prepend_db_passwords(cred_collection)
76+
7577
scanner = Metasploit::Framework::LoginScanner::Axis2.new(
7678
host: ip,
7779
port: rport,

modules/auxiliary/scanner/http/http_login.rb

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,8 @@ def run_host(ip)
129129
user_as_pass: datastore['USER_AS_PASS'],
130130
)
131131

132+
cred_collection = prepend_db_passwords(cred_collection)
133+
132134
scanner = Metasploit::Framework::LoginScanner::HTTP.new(
133135
host: ip,
134136
port: rport,

modules/auxiliary/scanner/http/tomcat_mgr_login.rb

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,13 +103,17 @@ def run_host(ip)
103103
user_as_pass: datastore['USER_AS_PASS'],
104104
)
105105

106+
cred_collection = prepend_db_passwords(cred_collection)
107+
106108
scanner = Metasploit::Framework::LoginScanner::Tomcat.new(
107109
host: ip,
108110
port: rport,
109111
proxies: datastore['PROXIES'],
110112
cred_details: cred_collection,
111113
stop_on_success: datastore['STOP_ON_SUCCESS'],
112-
connection_timeout: 10
114+
connection_timeout: 10,
115+
user_agent: datastore['UserAgent'],
116+
vhost: datastore['VHOST']
113117
)
114118

115119
scanner.scan! do |result|

modules/auxiliary/scanner/mssql/mssql_login.rb

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,8 @@ def run_host(ip)
4343
realm: datastore['DOMAIN']
4444
)
4545

46+
cred_collection = prepend_db_passwords(cred_collection)
47+
4648
scanner = Metasploit::Framework::LoginScanner::MSSQL.new(
4749
host: ip,
4850
port: rport,

modules/auxiliary/scanner/mysql/mysql_login.rb

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,8 @@ def run_host(ip)
4747
user_as_pass: datastore['USER_AS_PASS'],
4848
)
4949

50+
cred_collection = prepend_db_passwords(cred_collection)
51+
5052
scanner = Metasploit::Framework::LoginScanner::MySQL.new(
5153
host: ip,
5254
port: rport,

modules/auxiliary/scanner/pop3/pop3_login.rb

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,8 @@ def run_host(ip)
6262
user_as_pass: datastore['USER_AS_PASS'],
6363
)
6464

65+
cred_collection = prepend_db_passwords(cred_collection)
66+
6567
scanner = Metasploit::Framework::LoginScanner::POP3.new(
6668
host: ip,
6769
port: rport,

0 commit comments

Comments
 (0)