Skip to content

Commit fa2aa47

Browse files
committed
Further fixes to guest and bogus checks
1 parent 5377144 commit fa2aa47

File tree

1 file changed

+17
-17
lines changed

1 file changed

+17
-17
lines changed

modules/auxiliary/scanner/smb/smb_login.rb

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -71,19 +71,19 @@ def initialize
7171
def run_host(ip)
7272
print_brute(:level => :vstatus, :ip => ip, :msg => "Starting SMB login bruteforce")
7373

74-
if accepts_bogus_logins?
74+
domain = datastore['SMBDomain'] || ""
75+
76+
if accepts_bogus_logins?(domain)
7577
print_error("#{smbhost} - This system accepts authentication with any credentials, brute force is ineffective.")
7678
return
7779
end
7880

7981
unless datastore['RECORD_GUEST']
80-
if accepts_guest_logins?
82+
if accepts_guest_logins?(domain)
8183
print_status("#{ip} - This system allows guest sessions with any credentials, these instances will not be reported.")
8284
end
8385
end
8486

85-
domain = datastore['SMBDomain'] || ""
86-
8787
begin
8888
each_user_pass do |user, pass|
8989
result = try_user_pass(domain, user, pass)
@@ -128,12 +128,12 @@ def check_login_status(domain, user, pass)
128128

129129
# If login is succesful and auth_user is unset
130130
# the login was as a guest user.
131-
def accepts_guest_logins?
131+
def accepts_guest_logins?(domain)
132132
guest = false
133133
user = Rex::Text.rand_text_alpha(8)
134134
pass = Rex::Text.rand_text_alpha(8)
135135

136-
guest_login = ((check_login_status(datastore['SMBDomain'], user, pass) == 'STATUS_SUCCESS') && simple.client.auth_user.nil?)
136+
guest_login = ((check_login_status(domain, user, pass) == 'STATUS_SUCCESS') && simple.client.auth_user.nil?)
137137

138138
if guest_login
139139
@accepts_guest_logins['rhost'] ||=[] unless @accepts_guest_logins.include?(rhost)
@@ -153,10 +153,10 @@ def accepts_guest_logins?
153153

154154
# If login is successul and auth_user is set
155155
# then bogus creds are accepted.
156-
def accepts_bogus_logins?
156+
def accepts_bogus_logins?(domain)
157157
user = Rex::Text.rand_text_alpha(8)
158158
pass = Rex::Text.rand_text_alpha(8)
159-
bogus_login = ((check_login_status(datastore['SMBDomain'], user, pass) == 'STATUS_SUCCESS') && !simple.client.auth_user.nil?)
159+
bogus_login = ((check_login_status(domain, user, pass) == 'STATUS_SUCCESS') && !simple.client.auth_user.nil?)
160160
return bogus_login
161161
end
162162

@@ -194,19 +194,19 @@ def try_user_pass(domain, user, pass)
194194

195195
case status
196196
when 'STATUS_SUCCESS'
197+
# Auth user indicates if the login was as a guest or not
197198
if(simple.client.auth_user)
198199
print_good(output_message % "SUCCESSFUL LOGIN")
199200
vprint_status("Auth-User: #{simple.client.auth_user}")
200-
else
201-
print_status(output_message % "GUEST LOGIN")
202-
@accepts_guest_logins[rhost] = [user, pass] unless datastore['RECORD_GUEST']
203-
end
204-
205-
unless @accepts_guest_logins.find { |g_host, g_creds| g_host == rhost and g_creds == [user,pass] }
201+
validuser_case_sensitive?(domain, user, pass)
206202
report_creds(domain,user,pass,true)
207-
end
208-
209-
validuser_case_sensitive?(domain, user, pass)
203+
else
204+
if datastore['RECORD_GUEST']
205+
print_status(output_message % "GUEST LOGIN")
206+
@accepts_guest_logins[rhost] = [user, pass]
207+
report_creds(domain,user,pass,true)
208+
end
209+
end
210210
when *@correct_credentials_status_codes
211211
print_status(output_message % "FAILED LOGIN, VALID CREDENTIALS" )
212212
report_creds(domain,user,pass,false)

0 commit comments

Comments
 (0)