@@ -76,7 +76,6 @@ def initialize
76
76
}
77
77
)
78
78
79
-
80
79
register_options (
81
80
[
82
81
OptInt . new ( 'RPORT' , [ true , "The target port" , 443 ] ) ,
@@ -128,21 +127,29 @@ def run
128
127
each_user_pass do |user , pass |
129
128
next if ( user . blank? or pass . blank? )
130
129
vprint_status ( "#{ msg } Trying #{ user } : #{ pass } " )
131
- try_user_pass ( { "user" => user , "domain" => domain , "pass" => pass , "auth_path" => auth_path , "inbox_path" => inbox_path , "login_check" => login_check , "vhost" => vhost } )
130
+ try_user_pass ( {
131
+ user : user ,
132
+ domain : domain ,
133
+ pass : pass ,
134
+ auth_path : auth_path ,
135
+ inbox_path : inbox_path ,
136
+ login_check : login_check ,
137
+ vhost : vhost
138
+ } )
132
139
end
133
140
rescue ::Rex ::ConnectionError , Errno ::ECONNREFUSED
134
141
print_error ( "#{ msg } HTTP Connection Error, Aborting" )
135
142
end
136
143
end
137
144
138
145
def try_user_pass ( opts )
139
- user = opts [ " user" ]
140
- pass = opts [ " pass" ]
141
- auth_path = opts [ " auth_path" ]
142
- inbox_path = opts [ " inbox_path" ]
143
- login_check = opts [ " login_check" ]
144
- vhost = opts [ " vhost" ]
145
- domain = opts [ " domain" ]
146
+ user = opts [ : user]
147
+ pass = opts [ : pass]
148
+ auth_path = opts [ : auth_path]
149
+ inbox_path = opts [ : inbox_path]
150
+ login_check = opts [ : login_check]
151
+ vhost = opts [ : vhost]
152
+ domain = opts [ : domain]
146
153
147
154
user = domain + '\\' + user if domain
148
155
@@ -208,7 +215,13 @@ def try_user_pass(opts)
208
215
:active => true ,
209
216
:type => 'password' }
210
217
211
- report_auth_info ( report_hash )
218
+ report_cred (
219
+ ip : datastore [ 'RHOST' ] ,
220
+ port : datastore [ 'RPORT' ] ,
221
+ service_name : 'owa' ,
222
+ user : user ,
223
+ password : pass
224
+ )
212
225
return :next_user
213
226
end
214
227
@@ -273,7 +286,13 @@ def try_user_pass(opts)
273
286
:active => true ,
274
287
:type => 'password' }
275
288
276
- report_auth_info ( report_hash )
289
+ report_cred (
290
+ ip : datastore [ 'RHOST' ] ,
291
+ port : datastore [ 'RPORT' ] ,
292
+ service_name : 'owa' ,
293
+ user : user ,
294
+ password : pass
295
+ )
277
296
return :next_user
278
297
else
279
298
vprint_error ( "#{ msg } FAILED LOGIN. #{ elapsed_time } '#{ user } ' : '#{ pass } ' (response body did not match)" )
@@ -282,14 +301,14 @@ def try_user_pass(opts)
282
301
end
283
302
284
303
def get_ad_domain
285
- urls = [ " aspnet_client" ,
286
- " Autodiscover" ,
287
- " ecp" ,
288
- " EWS" ,
289
- " Microsoft-Server-ActiveSync" ,
290
- " OAB" ,
291
- " PowerShell" ,
292
- " Rpc" ]
304
+ urls = [ ' aspnet_client' ,
305
+ ' Autodiscover' ,
306
+ ' ecp' ,
307
+ ' EWS' ,
308
+ ' Microsoft-Server-ActiveSync' ,
309
+ ' OAB' ,
310
+ ' PowerShell' ,
311
+ ' Rpc' ]
293
312
294
313
domain = nil
295
314
@@ -299,7 +318,7 @@ def get_ad_domain
299
318
'encode' => true ,
300
319
'uri' => "/#{ url } " ,
301
320
'method' => 'GET' ,
302
- 'headers' => { " Authorization" => " NTLM TlRMTVNTUAABAAAAB4IIogAAAAAAAAAAAAAAAAAAAAAGAbEdAAAADw==" }
321
+ 'headers' => { ' Authorization' => ' NTLM TlRMTVNTUAABAAAAB4IIogAAAAAAAAAAAAAAAAAAAAAGAbEdAAAADw==' }
303
322
} )
304
323
rescue ::Rex ::ConnectionError , Errno ::ECONNREFUSED , Errno ::ETIMEDOUT
305
324
vprint_error ( "#{ msg } HTTP Connection Failed" )
@@ -314,14 +333,39 @@ def get_ad_domain
314
333
if res && res . code == 401 && res . headers . has_key? ( 'WWW-Authenticate' ) && res . headers [ 'WWW-Authenticate' ] . match ( /^NTLM/i )
315
334
hash = res [ 'WWW-Authenticate' ] . split ( 'NTLM ' ) [ 1 ]
316
335
domain = Rex ::Proto ::NTLM ::Message . parse ( Rex ::Text . decode_base64 ( hash ) ) [ :target_name ] . value ( ) . gsub ( /\0 / , '' )
317
- print_good ( "Found target domain: " + domain )
336
+ print_good ( "Found target domain: #{ domain } " )
318
337
return domain
319
338
end
320
339
end
321
340
322
341
return domain
323
342
end
324
343
344
+ def report_cred ( opts )
345
+ service_data = {
346
+ address : opts [ :ip ] ,
347
+ port : opts [ :port ] ,
348
+ service_name : opts [ :service_name ] ,
349
+ protocol : 'tcp' ,
350
+ workspace_id : myworkspace_id
351
+ }
352
+
353
+ credential_data = {
354
+ origin_type : :service ,
355
+ module_fullname : fullname ,
356
+ username : opts [ :user ] ,
357
+ private_data : opts [ :password ] ,
358
+ private_type : :password
359
+ } . merge ( service_data )
360
+
361
+ login_data = {
362
+ core : create_credential ( credential_data ) ,
363
+ status : Metasploit ::Model ::Login ::Status ::UNTRIED ,
364
+ } . merge ( service_data )
365
+
366
+ create_credential_login ( login_data )
367
+ end
368
+
325
369
def msg
326
370
"#{ vhost } :#{ rport } OWA -"
327
371
end
0 commit comments