4
4
##
5
5
6
6
require 'rex/proto/ntlm/message'
7
- require 'rex/socket'
8
7
9
8
class MetasploitModule < Msf ::Auxiliary
10
9
include Msf ::Auxiliary ::Report
@@ -94,19 +93,6 @@ def initialize
94
93
deregister_options ( 'BLANK_PASSWORDS' , 'RHOSTS' )
95
94
end
96
95
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
-
110
96
def setup
111
97
# Here's a weird hack to check if each_user_pass is empty or not
112
98
# apparently you cannot do each_user_pass.empty? or even inspect() it
@@ -211,6 +197,10 @@ def try_user_pass(opts)
211
197
return
212
198
end
213
199
200
+ if res . peerinfo [ 'addr' ] != datastore [ 'RHOST' ]
201
+ vprint_status ( "#{ msg } Resolved hostname '#{ datastore [ 'RHOST' ] } ' to address #{ res . peerinfo [ 'addr' ] } " )
202
+ end
203
+
214
204
if action . name != "OWA_2013" and res . get_cookies . empty?
215
205
print_error ( "#{ msg } Received invalid repsonse due to a missing cookie (possibly due to invalid version), aborting" )
216
206
return :abort
@@ -221,7 +211,7 @@ def try_user_pass(opts)
221
211
if res . headers [ 'location' ] =~ /expiredpassword/
222
212
print_good ( "#{ msg } SUCCESSFUL LOGIN. #{ elapsed_time } '#{ user } ' : '#{ pass } ': NOTE password change required" )
223
213
report_cred (
224
- ip : lookup_addr ( datastore [ 'RHOST' ] ) ,
214
+ ip : res . peerinfo [ 'addr' ] ,
225
215
port : datastore [ 'RPORT' ] ,
226
216
service_name : 'owa' ,
227
217
user : user ,
@@ -235,7 +225,7 @@ def try_user_pass(opts)
235
225
if res . headers [ 'location' ] =~ /owa/ and res . headers [ 'location' ] !~ /reason/
236
226
print_good ( "#{ msg } SUCCESSFUL LOGIN. #{ elapsed_time } '#{ user } ' : '#{ pass } ': NOTE a mailbox is not setup" )
237
227
report_cred (
238
- ip : lookup_addr ( datastore [ 'RHOST' ] ) ,
228
+ ip : res . peerinfo [ 'addr' ] ,
239
229
port : datastore [ 'RPORT' ] ,
240
230
service_name : 'owa' ,
241
231
user : user ,
@@ -255,7 +245,7 @@ def try_user_pass(opts)
255
245
# Login didn't work. no point in going on, however, check if valid domain account by response time.
256
246
if elapsed_time <= 1
257
247
report_cred (
258
- ip : lookup_addr ( datastore [ 'RHOST' ] ) ,
248
+ ip : res . peerinfo [ 'addr' ] ,
259
249
port : datastore [ 'RPORT' ] ,
260
250
service_name : 'owa' ,
261
251
user : user
@@ -301,7 +291,7 @@ def try_user_pass(opts)
301
291
if res . redirect?
302
292
if elapsed_time <= 1
303
293
report_cred (
304
- ip : lookup_addr ( datastore [ 'RHOST' ] ) ,
294
+ ip : res . peerinfo [ 'addr' ] ,
305
295
port : datastore [ 'RPORT' ] ,
306
296
service_name : 'owa' ,
307
297
user : user
@@ -317,7 +307,7 @@ def try_user_pass(opts)
317
307
if res . body =~ login_check
318
308
print_good ( "#{ msg } SUCCESSFUL LOGIN. #{ elapsed_time } '#{ user } ' : '#{ pass } '" )
319
309
report_cred (
320
- ip : lookup_addr ( datastore [ 'RHOST' ] ) ,
310
+ ip : res . peerinfo [ 'addr' ] ,
321
311
port : datastore [ 'RPORT' ] ,
322
312
service_name : 'owa' ,
323
313
user : user ,
@@ -327,7 +317,7 @@ def try_user_pass(opts)
327
317
else
328
318
if elapsed_time <= 1
329
319
report_cred (
330
- ip : lookup_addr ( datastore [ 'RHOST' ] ) ,
320
+ ip : res . peerinfo [ 'addr' ] ,
331
321
port : datastore [ 'RPORT' ] ,
332
322
service_name : 'owa' ,
333
323
user : user
0 commit comments