Skip to content

Commit 71a1ccf

Browse files
author
jvazquez-r7
committed
Clean owa_login enum_domain feature
1 parent 4b48045 commit 71a1ccf

File tree

1 file changed

+22
-23
lines changed

1 file changed

+22
-23
lines changed

modules/auxiliary/scanner/http/owa_login.rb

Lines changed: 22 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ def initialize
7171
register_advanced_options(
7272
[
7373
OptString.new('AD_DOMAIN', [ false, "Optional AD domain to prepend to usernames", '']),
74-
OptBool.new('ENUM_DOMAIN', [ true, "Automatically enumerate AD domain using NTLM authentication", true]),
74+
OptBool.new('ENUM_DOMAIN', [ true, "Automatically enumerate AD domain using NTLM authentication", false]),
7575
OptBool.new('SSL', [ true, "Negotiate SSL for outgoing connections", true])
7676
], self.class)
7777

@@ -118,14 +118,14 @@ def run
118118

119119
domain = nil
120120

121-
if datastore['AD_DOMAIN'].nil? or datastore['AD_DOMAIN'] == ''
122-
if datastore['ENUM_DOMAIN']
123-
domain = get_ad_domain
124-
end
125-
else
121+
if datastore['AD_DOMAIN'] and not datastore['AD_DOMAIN'].empty?
126122
domain = datastore['AD_DOMAIN']
127123
end
128124

125+
if ((datastore['AD_DOMAIN'].nil? or datastore['AD_DOMAIN'] == '') and datastore['ENUM_DOMAIN'])
126+
domain = get_ad_domain
127+
end
128+
129129
begin
130130
each_user_pass do |user, pass|
131131
vprint_status("#{msg} Trying #{user} : #{pass}")
@@ -164,7 +164,7 @@ def try_user_pass(opts)
164164
'method' => 'POST',
165165
'headers' => headers,
166166
'data' => data
167-
}, 25)
167+
})
168168

169169
rescue ::Rex::ConnectionError, Errno::ECONNREFUSED, Errno::ETIMEDOUT
170170
print_error("#{msg} HTTP Connection Failed, Aborting")
@@ -240,31 +240,30 @@ def get_ad_domain
240240

241241
domain = nil
242242

243-
begin
244-
urls.each do |url|
243+
urls.each do |url|
244+
begin
245245
res = send_request_cgi({
246246
'encode' => true,
247247
'uri' => "/#{url}",
248248
'method' => 'GET',
249249
'headers' => {"Authorization" => "NTLM TlRMTVNTUAABAAAAB4IIogAAAAAAAAAAAAAAAAAAAAAGAbEdAAAADw=="}
250250
})
251+
rescue ::Rex::ConnectionError, Errno::ECONNREFUSED, Errno::ETIMEDOUT
252+
vprint_error("#{msg} HTTP Connection Failed")
253+
next
254+
end
251255

252-
if not res
253-
print_error("#{msg} HTTP Connection Error, Aborting")
254-
return nil
255-
end
256-
257-
if res and res.code == 401 and res['WWW-Authenticate'].match(/^NTLM/i)
258-
hash = res['WWW-Authenticate'].split('NTLM ')[1]
259-
domain = Rex::Proto::NTLM::Message.parse(Rex::Text.decode_base64(hash))[:target_name].value().gsub(/\0/,'')
260-
print_good("Found target domain: " + domain)
261-
return domain
262-
end
256+
if not res
257+
vprint_error("#{msg} HTTP Connection Timeout")
258+
next
263259
end
264260

265-
rescue ::Rex::ConnectionError, Errno::ECONNREFUSED, Errno::ETIMEDOUT
266-
print_error("#{msg} HTTP Connection Failed, Aborting")
267-
return nil
261+
if res and res.code == 401 and res['WWW-Authenticate'].match(/^NTLM/i)
262+
hash = res['WWW-Authenticate'].split('NTLM ')[1]
263+
domain = Rex::Proto::NTLM::Message.parse(Rex::Text.decode_base64(hash))[:target_name].value().gsub(/\0/,'')
264+
print_good("Found target domain: " + domain)
265+
return domain
266+
end
268267
end
269268

270269
return domain

0 commit comments

Comments
 (0)