@@ -55,6 +55,29 @@ def create_credential_login(credential_data)
55
55
super
56
56
end
57
57
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
+
58
81
# Framework is notified that we have a new session opened
59
82
#
60
83
# @param [MetasploitModule] obj
@@ -65,7 +88,13 @@ def create_credential_login(credential_data)
65
88
# @param [Msf::Sessions::<SESSION_CLASS>] sess
66
89
# @return [Msf::Sessions::<SESSION_CLASS>]
67
90
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
69
98
70
99
result = super
71
100
@report [ rhost ] . merge! ( { successful_sessions : [ ] } )
0 commit comments