Skip to content

Commit 5f65ce2

Browse files
authored
Land rapid7#19438, Fixes a nil error if login is successful with ldap_login module
2 parents db55e5e + 242d91e commit 5f65ce2

File tree

1 file changed

+30
-1
lines changed

1 file changed

+30
-1
lines changed

lib/msf/core/auxiliary/report_summary.rb

Lines changed: 30 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,29 @@ def create_credential_login(credential_data)
5555
super
5656
end
5757

58+
# Creates a credential and adds to to the DB if one is present, then calls create_credential_login to
59+
# attempt a login
60+
#
61+
# This is needed when create_credential_and_login in
62+
# lib/metasploit/framework/data_service/proxy/credential_data_proxy.rb
63+
# is called, which doesn't call of to create_credential_login at any point to initialize @report[rhost]
64+
#
65+
# This allow modules that make use of create_credential_and_login to make use of the report summary mixin
66+
#
67+
# @param [Hash] credential_data
68+
# @return [Metasploit::Credential::Login]
69+
def create_credential_and_login(credential_data)
70+
return super unless framework.features.enabled?(Msf::FeatureManager::SHOW_SUCCESSFUL_LOGINS) && datastore['ShowSuccessfulLogins'] && @report
71+
72+
credential = {
73+
public: credential_data[:username],
74+
private_data: credential_data[:private_data]
75+
}
76+
@report[rhost] = { successful_logins: [] }
77+
@report[rhost][:successful_logins] << credential
78+
super
79+
end
80+
5881
# Framework is notified that we have a new session opened
5982
#
6083
# @param [MetasploitModule] obj
@@ -65,7 +88,13 @@ def create_credential_login(credential_data)
6588
# @param [Msf::Sessions::<SESSION_CLASS>] sess
6689
# @return [Msf::Sessions::<SESSION_CLASS>]
6790
def start_session(obj, info, ds_merge, crlf = false, sock = nil, sess = nil)
68-
return super unless framework.features.enabled?(Msf::FeatureManager::SHOW_SUCCESSFUL_LOGINS) && datastore['ShowSuccessfulLogins'] && @report
91+
return super unless framework.features.enabled?(Msf::FeatureManager::SHOW_SUCCESSFUL_LOGINS) && datastore['ShowSuccessfulLogins']
92+
93+
unless @report && @report[rhost]
94+
elog("No RHOST found in report, skipping reporting for #{rhost}")
95+
print_brute level: :error, ip: rhost, msg: "No RHOST found in report, skipping reporting for #{rhost}"
96+
return super
97+
end
6998

7099
result = super
71100
@report[rhost].merge!({ successful_sessions: [] })

0 commit comments

Comments
 (0)