@@ -49,6 +49,53 @@ def setup
49
49
@@max_per_service = nil
50
50
end
51
51
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' ]
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' ]
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' ]
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
+
52
99
# Checks all three files for usernames and passwords, and combines them into
53
100
# one credential list to apply against the supplied block. The block (usually
54
101
# something like do_login(user,pass) ) is responsible for actually recording
0 commit comments