Skip to content

Commit 25ee278

Browse files
David MaloneyDavid Maloney
authored andcommitted
strip vestigial realms
in the cases where we don't want a realm we should be stripping it from the credential so we can build accurate results
1 parent 9bbf948 commit 25ee278

File tree

2 files changed

+9
-1
lines changed

2 files changed

+9
-1
lines changed

lib/metasploit/framework/login_scanner/base.rb

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,10 +101,15 @@ def each_cred_adjusted_for_realm(credential)
101101
yield credential
102102
elsif credential.realm.present? && self.class::REALM_KEY.blank?
103103
second_cred = credential.dup
104+
# Strip the realm off here, as we don't want it
105+
credential.realm = nil
106+
credential.realm_key = nil
104107
yield credential
105108
# Some services can take a domain in the username like this even though
106109
# they do not explicitly take a domain as part of the protocol.
107110
second_cred.public = "#{second_cred.realm}\\#{second_cred.public}"
111+
second_cred.realm = nil
112+
second_cred.realm_key = nil
108113
yield second_cred
109114
else
110115
yield credential

spec/support/shared/examples/metasploit/framework/login_scanner/login_scanner_base.rb

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -325,7 +325,10 @@
325325
context 'when login_scanner has no REALM_KEY' do
326326
context 'when the credential has a realm' do
327327
it 'yields the original credential as well as one with the realm in the public' do
328-
second_cred = ad_cred.dup
328+
first_cred = ad_cred.dup
329+
first_cred.realm = nil
330+
first_cred.realm_key = nil
331+
second_cred = first_cred.dup
329332
second_cred.public = "#{realm}\\#{public}"
330333
expect{ |b| login_scanner.each_cred_adjusted_for_realm(ad_cred, &b)}.to yield_successive_args(ad_cred,second_cred)
331334
end

0 commit comments

Comments
 (0)