Skip to content

Commit 3ccf18f

Browse files
authored
Merge pull request rapid7#19610 from cgranleese-r7/fixes-report-summary
Updates report summary mixin with an additional fallback when finding creds
2 parents c988308 + dc6cb34 commit 3ccf18f

File tree

1 file changed

+27
-10
lines changed

1 file changed

+27
-10
lines changed

lib/msf/core/auxiliary/report_summary.rb

Lines changed: 27 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -39,19 +39,40 @@ def run
3939
result
4040
end
4141

42+
# Take credentials hash and check data for username and password and then returns a hash for those values
43+
#
44+
# @param [Hash] credential_data
45+
# @return [Hash]
46+
def login_credentials(credential_data)
47+
# If the database is active and core is populated then grab the creds from there, otherwise
48+
# fallback and check in credentials data's top layer
49+
if framework.db&.active && credential_data[:core]
50+
{
51+
public: credential_data[:core].public,
52+
private_data: credential_data[:core].private
53+
}
54+
elsif credential_data[:username] && credential_data[:private_data]
55+
{
56+
public: credential_data[:username],
57+
private_data: credential_data[:private_data]
58+
}
59+
else
60+
{
61+
public: 'credentials could not be reported',
62+
private_data: 'credentials could not be reported'
63+
}
64+
end
65+
end
66+
4267
# Creates a credential and adds to to the DB if one is present
4368
#
4469
# @param [Hash] credential_data
4570
# @return [Metasploit::Credential::Login]
4671
def create_credential_login(credential_data)
4772
return super unless framework.features.enabled?(Msf::FeatureManager::SHOW_SUCCESSFUL_LOGINS) && datastore['ShowSuccessfulLogins'] && @report
4873

49-
credential = {
50-
public: credential_data[:username],
51-
private_data: credential_data[:private_data]
52-
}
5374
@report[rhost] = { successful_logins: [] }
54-
@report[rhost][:successful_logins] << credential
75+
@report[rhost][:successful_logins] << login_credentials(credential_data)
5576
super
5677
end
5778

@@ -69,12 +90,8 @@ def create_credential_login(credential_data)
6990
def create_credential_and_login(credential_data)
7091
return super unless framework.features.enabled?(Msf::FeatureManager::SHOW_SUCCESSFUL_LOGINS) && datastore['ShowSuccessfulLogins'] && @report
7192

72-
credential = {
73-
public: credential_data[:username],
74-
private_data: credential_data[:private_data]
75-
}
7693
@report[rhost] = { successful_logins: [] }
77-
@report[rhost][:successful_logins] << credential
94+
@report[rhost][:successful_logins] << login_credentials(credential_data)
7895
super
7996
end
8097

0 commit comments

Comments
 (0)