@@ -71,11 +71,23 @@ def login_credentials(credential_data)
7171 def create_credential_login ( credential_data )
7272 return super unless framework . features . enabled? ( Msf ::FeatureManager ::SHOW_SUCCESSFUL_LOGINS ) && datastore [ 'ShowSuccessfulLogins' ] && @report
7373
74- @report [ rhost ] = { successful_logins : [ ] }
74+ @report [ rhost ] ||= { }
75+ @report [ rhost ] [ :successful_logins ] ||= [ ]
7576 @report [ rhost ] [ :successful_logins ] << login_credentials ( credential_data )
7677 super
7778 end
7879
80+ def report_successful_login ( public :, private :)
81+ return super unless framework . features . enabled? ( Msf ::FeatureManager ::SHOW_SUCCESSFUL_LOGINS ) && datastore [ 'ShowSuccessfulLogins' ] && @report
82+
83+ @report [ rhost ] ||= { }
84+ @report [ rhost ] [ :successful_logins ] ||= [ ]
85+ @report [ rhost ] [ :successful_logins ] << {
86+ public : public ,
87+ private_data : private
88+ }
89+ end
90+
7991 # Creates a credential and adds to to the DB if one is present, then calls create_credential_login to
8092 # attempt a login
8193 #
@@ -90,7 +102,8 @@ def create_credential_login(credential_data)
90102 def create_credential_and_login ( credential_data )
91103 return super unless framework . features . enabled? ( Msf ::FeatureManager ::SHOW_SUCCESSFUL_LOGINS ) && datastore [ 'ShowSuccessfulLogins' ] && @report
92104
93- @report [ rhost ] = { successful_logins : [ ] }
105+ @report [ rhost ] ||= { }
106+ @report [ rhost ] [ :successful_logins ] ||= [ ]
94107 @report [ rhost ] [ :successful_logins ] << login_credentials ( credential_data )
95108 super
96109 end
@@ -107,14 +120,9 @@ def create_credential_and_login(credential_data)
107120 def start_session ( obj , info , ds_merge , crlf = false , sock = nil , sess = nil )
108121 return super unless framework . features . enabled? ( Msf ::FeatureManager ::SHOW_SUCCESSFUL_LOGINS ) && datastore [ 'ShowSuccessfulLogins' ]
109122
110- unless @report && @report [ rhost ]
111- elog ( "No RHOST found in report, skipping reporting for #{ rhost } " )
112- print_brute level : :error , ip : rhost , msg : "No RHOST found in report, skipping reporting for #{ rhost } "
113- return super
114- end
115-
116123 result = super
117- @report [ rhost ] . merge! ( { successful_sessions : [ ] } )
124+ @report [ rhost ] ||= { }
125+ @report [ rhost ] [ :successful_sessions ] ||= [ ]
118126 @report [ rhost ] [ :successful_sessions ] << result
119127 result
120128 end
@@ -127,6 +135,7 @@ def start_session(obj, info, ds_merge, crlf = false, sock = nil, sess = nil)
127135 #
128136 # @return [Hash] Rhost keys mapped to successful logins and sessions for each host
129137 def print_report_summary
138+ return unless @report
130139 report = @report
131140
132141 logins = report . flat_map { |_k , v | v [ :successful_logins ] } . compact
0 commit comments