4
4
##
5
5
6
6
require 'rex/proto/ntlm/message'
7
+ require 'rex/socket'
7
8
8
9
class MetasploitModule < Msf ::Auxiliary
9
10
include Msf ::Auxiliary ::Report
@@ -93,6 +94,19 @@ def initialize
93
94
deregister_options ( 'BLANK_PASSWORDS' , 'RHOSTS' )
94
95
end
95
96
97
+ def lookup_addr ( host )
98
+ return host if Rex ::Socket . dotted_ip? ( host )
99
+
100
+ begin
101
+ addr = Rex ::Socket . resolv_to_dotted ( host )
102
+ vprint_status ( "#{ msg } Resolved hostname '#{ host . to_s } ' to address #{ addr . to_s } " )
103
+ rescue ResolverArgumentError , Errno ::ETIMEDOUT , ::NoResponseError , ::Timeout ::Error => e
104
+ print_error ( "#{ msg } Failed to lookup address for #{ host } , datastore persistence skipped" )
105
+ addr = nil
106
+ end
107
+ addr
108
+ end
109
+
96
110
def setup
97
111
# Here's a weird hack to check if each_user_pass is empty or not
98
112
# apparently you cannot do each_user_pass.empty? or even inspect() it
@@ -207,7 +221,7 @@ def try_user_pass(opts)
207
221
if res . headers [ 'location' ] =~ /expiredpassword/
208
222
print_good ( "#{ msg } SUCCESSFUL LOGIN. #{ elapsed_time } '#{ user } ' : '#{ pass } ': NOTE password change required" )
209
223
report_cred (
210
- ip : datastore [ 'RHOST' ] ,
224
+ ip : lookup_addr ( datastore [ 'RHOST' ] ) ,
211
225
port : datastore [ 'RPORT' ] ,
212
226
service_name : 'owa' ,
213
227
user : user ,
@@ -221,7 +235,7 @@ def try_user_pass(opts)
221
235
if res . headers [ 'location' ] =~ /owa/ and res . headers [ 'location' ] !~ /reason/
222
236
print_good ( "#{ msg } SUCCESSFUL LOGIN. #{ elapsed_time } '#{ user } ' : '#{ pass } ': NOTE a mailbox is not setup" )
223
237
report_cred (
224
- ip : datastore [ 'RHOST' ] ,
238
+ ip : lookup_addr ( datastore [ 'RHOST' ] ) ,
225
239
port : datastore [ 'RPORT' ] ,
226
240
service_name : 'owa' ,
227
241
user : user ,
@@ -241,7 +255,7 @@ def try_user_pass(opts)
241
255
# Login didn't work. no point in going on, however, check if valid domain account by response time.
242
256
if elapsed_time <= 1
243
257
report_cred (
244
- ip : datastore [ 'RHOST' ] ,
258
+ ip : lookup_addr ( datastore [ 'RHOST' ] ) ,
245
259
port : datastore [ 'RPORT' ] ,
246
260
service_name : 'owa' ,
247
261
user : user
@@ -287,7 +301,7 @@ def try_user_pass(opts)
287
301
if res . redirect?
288
302
if elapsed_time <= 1
289
303
report_cred (
290
- ip : datastore [ 'RHOST' ] ,
304
+ ip : lookup_addr ( datastore [ 'RHOST' ] ) ,
291
305
port : datastore [ 'RPORT' ] ,
292
306
service_name : 'owa' ,
293
307
user : user
@@ -303,7 +317,7 @@ def try_user_pass(opts)
303
317
if res . body =~ login_check
304
318
print_good ( "#{ msg } SUCCESSFUL LOGIN. #{ elapsed_time } '#{ user } ' : '#{ pass } '" )
305
319
report_cred (
306
- ip : datastore [ 'RHOST' ] ,
320
+ ip : lookup_addr ( datastore [ 'RHOST' ] ) ,
307
321
port : datastore [ 'RPORT' ] ,
308
322
service_name : 'owa' ,
309
323
user : user ,
@@ -313,7 +327,7 @@ def try_user_pass(opts)
313
327
else
314
328
if elapsed_time <= 1
315
329
report_cred (
316
- ip : datastore [ 'RHOST' ] ,
330
+ ip : lookup_addr ( datastore [ 'RHOST' ] ) ,
317
331
port : datastore [ 'RPORT' ] ,
318
332
service_name : 'owa' ,
319
333
user : user
0 commit comments