Skip to content

Commit e9ce237

Browse files
committed
Auto-resolve target if it's a hostname (owa_login).
Ensures the module does save the creds which it claims to be saving. See MS-2968.
1 parent d6e966b commit e9ce237

File tree

1 file changed

+20
-6
lines changed

1 file changed

+20
-6
lines changed

modules/auxiliary/scanner/http/owa_login.rb

Lines changed: 20 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
##
55

66
require 'rex/proto/ntlm/message'
7+
require 'rex/socket'
78

89
class MetasploitModule < Msf::Auxiliary
910
include Msf::Auxiliary::Report
@@ -93,6 +94,19 @@ def initialize
9394
deregister_options('BLANK_PASSWORDS', 'RHOSTS')
9495
end
9596

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+
96110
def setup
97111
# Here's a weird hack to check if each_user_pass is empty or not
98112
# apparently you cannot do each_user_pass.empty? or even inspect() it
@@ -207,7 +221,7 @@ def try_user_pass(opts)
207221
if res.headers['location'] =~ /expiredpassword/
208222
print_good("#{msg} SUCCESSFUL LOGIN. #{elapsed_time} '#{user}' : '#{pass}': NOTE password change required")
209223
report_cred(
210-
ip: datastore['RHOST'],
224+
ip: lookup_addr(datastore['RHOST']),
211225
port: datastore['RPORT'],
212226
service_name: 'owa',
213227
user: user,
@@ -221,7 +235,7 @@ def try_user_pass(opts)
221235
if res.headers['location'] =~ /owa/ and res.headers['location'] !~ /reason/
222236
print_good("#{msg} SUCCESSFUL LOGIN. #{elapsed_time} '#{user}' : '#{pass}': NOTE a mailbox is not setup")
223237
report_cred(
224-
ip: datastore['RHOST'],
238+
ip: lookup_addr(datastore['RHOST']),
225239
port: datastore['RPORT'],
226240
service_name: 'owa',
227241
user: user,
@@ -241,7 +255,7 @@ def try_user_pass(opts)
241255
# Login didn't work. no point in going on, however, check if valid domain account by response time.
242256
if elapsed_time <= 1
243257
report_cred(
244-
ip: datastore['RHOST'],
258+
ip: lookup_addr(datastore['RHOST']),
245259
port: datastore['RPORT'],
246260
service_name: 'owa',
247261
user: user
@@ -287,7 +301,7 @@ def try_user_pass(opts)
287301
if res.redirect?
288302
if elapsed_time <= 1
289303
report_cred(
290-
ip: datastore['RHOST'],
304+
ip: lookup_addr(datastore['RHOST']),
291305
port: datastore['RPORT'],
292306
service_name: 'owa',
293307
user: user
@@ -303,7 +317,7 @@ def try_user_pass(opts)
303317
if res.body =~ login_check
304318
print_good("#{msg} SUCCESSFUL LOGIN. #{elapsed_time} '#{user}' : '#{pass}'")
305319
report_cred(
306-
ip: datastore['RHOST'],
320+
ip: lookup_addr(datastore['RHOST']),
307321
port: datastore['RPORT'],
308322
service_name: 'owa',
309323
user: user,
@@ -313,7 +327,7 @@ def try_user_pass(opts)
313327
else
314328
if elapsed_time <= 1
315329
report_cred(
316-
ip: datastore['RHOST'],
330+
ip: lookup_addr(datastore['RHOST']),
317331
port: datastore['RPORT'],
318332
service_name: 'owa',
319333
user: user

0 commit comments

Comments
 (0)