Skip to content

Commit 702511d

Browse files
David MaloneyDavid Maloney
authored andcommitted
respect DB_ALL_USERS & DB_ALL_PASS
fix last few things in authbrute and make the CredentialCollections understand the additional seperate components MSP-11986
1 parent 7ff2ba0 commit 702511d

File tree

2 files changed

+33
-3
lines changed

2 files changed

+33
-3
lines changed

lib/metasploit/framework/credential_collection.rb

Lines changed: 31 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,9 @@ def initialize(opts = {})
7171
opts.each do |attribute, value|
7272
public_send("#{attribute}=", value)
7373
end
74-
self.prepended_creds ||= []
74+
self.prepended_creds ||= []
75+
self.additional_privates ||= []
76+
self.additional_publics ||= []
7577
end
7678

7779
# Adds a string as an addition private credential
@@ -131,6 +133,9 @@ def each
131133
end
132134
pass_fd.seek(0)
133135
end
136+
additional_privates.each do |add_private|
137+
yield Metasploit::Framework::Credential.new(public: username, private: add_private, realm: realm, private_type: private_type(add_private))
138+
end
134139
end
135140

136141
if user_file.present?
@@ -153,6 +158,9 @@ def each
153158
end
154159
pass_fd.seek(0)
155160
end
161+
additional_privates.each do |add_private|
162+
yield Metasploit::Framework::Credential.new(public: user_from_file, private: add_private, realm: realm, private_type: private_type(add_private))
163+
end
156164
end
157165
end
158166
end
@@ -171,6 +179,28 @@ def each
171179
end
172180
end
173181

182+
additional_publics.each do |add_public|
183+
if password.present?
184+
yield Metasploit::Framework::Credential.new(public: add_public, private: password, realm: realm, private_type: private_type(password) )
185+
end
186+
if user_as_pass
187+
yield Metasploit::Framework::Credential.new(public: add_public, private: user_from_file, realm: realm, private_type: :password)
188+
end
189+
if blank_passwords
190+
yield Metasploit::Framework::Credential.new(public: add_public, private: "", realm: realm, private_type: :password)
191+
end
192+
if pass_fd
193+
pass_fd.each_line do |pass_from_file|
194+
pass_from_file.chomp!
195+
yield Metasploit::Framework::Credential.new(public: add_public, private: pass_from_file, realm: realm, private_type: private_type(pass_from_file))
196+
end
197+
pass_fd.seek(0)
198+
end
199+
additional_privates.each do |add_private|
200+
yield Metasploit::Framework::Credential.new(public: add_public, private: add_private, realm: realm, private_type: private_type(add_private))
201+
end
202+
end
203+
174204
ensure
175205
pass_fd.close if pass_fd && !pass_fd.closed?
176206
end

lib/msf/core/auxiliary/auth_brute.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ def prepend_db_hashes(cred_collection)
112112
# the credential collection to add to
113113
# @return [Metasploit::Framework::CredentialCollection] the modified Credentialcollection
114114
def prepend_db_keys(cred_collection)
115-
if datastore['DB_ALL_CREDS'] && framework.db.active
115+
if prepend_db_creds?
116116
each_ssh_cred do |cred|
117117
process_cred_for_collection(cred_collection,cred)
118118
end
@@ -127,7 +127,7 @@ def prepend_db_keys(cred_collection)
127127
# the credential collection to add to
128128
# @return [Metasploit::Framework::CredentialCollection] the modified Credentialcollection
129129
def prepend_db_passwords(cred_collection)
130-
if datastore['DB_ALL_CREDS'] && framework.db.active
130+
if prepend_db_creds?
131131
each_password_cred do |cred|
132132
process_cred_for_collection(cred_collection,cred)
133133
end

0 commit comments

Comments
 (0)