@@ -99,22 +99,45 @@ def do_login(user='nessus', pass='nessus')
99
99
100
100
if res . code == 200
101
101
if res . body =~ /<status>OK<\/ status>/
102
- print_good ( "SUCCESSFUL LOGIN. '#{ user } ' : '#{ pass } '" )
103
-
104
- report_hash = {
105
- :host => datastore [ 'RHOST' ] ,
106
- :port => datastore [ 'RPORT' ] ,
107
- :sname => 'nessus-xmlrpc' ,
108
- :user => user ,
109
- :pass => pass ,
110
- :active => true ,
111
- :type => 'password' }
112
-
113
- report_auth_info ( report_hash )
102
+ print_good ( "SUCCESSFUL LOGIN. '#{ user } ':'#{ pass } '" )
103
+ report_cred (
104
+ ip : datastore [ 'RHOST' ] ,
105
+ port : datastore [ 'RPORT' ] ,
106
+ service_name : 'nessus-xmlrpc' ,
107
+ user : user ,
108
+ password : pass
109
+ )
114
110
return :next_user
115
111
end
116
112
end
117
- vprint_error ( "FAILED LOGIN. '#{ user } ' : '#{ pass } '" )
113
+ vprint_error ( "FAILED LOGIN. '#{ user } ': '#{ pass } '" )
118
114
return :skip_pass
119
115
end
116
+
117
+ def report_cred ( opts )
118
+ service_data = {
119
+ address : opts [ :ip ] ,
120
+ port : opts [ :port ] ,
121
+ service_name : opts [ :service_name ] ,
122
+ protocol : 'tcp' ,
123
+ workspace_id : myworkspace_id
124
+ }
125
+
126
+ credential_data = {
127
+ origin_type : :service ,
128
+ module_fullname : fullname ,
129
+ username : opts [ :user ] ,
130
+ private_data : opts [ :password ] ,
131
+ private_type : :password
132
+ } . merge ( service_data )
133
+
134
+ login_data = {
135
+ last_attempted_at : DateTime . now ,
136
+ core : create_credential ( credential_data ) ,
137
+ status : Metasploit ::Model ::Login ::Status ::SUCCESSFUL ,
138
+ } . merge ( service_data )
139
+
140
+ create_credential_login ( login_data )
141
+ end
142
+
120
143
end
0 commit comments