@@ -71,19 +71,19 @@ def initialize
71
71
def run_host ( ip )
72
72
print_brute ( :level => :vstatus , :ip => ip , :msg => "Starting SMB login bruteforce" )
73
73
74
- if accepts_bogus_logins?
74
+ domain = datastore [ 'SMBDomain' ] || ""
75
+
76
+ if accepts_bogus_logins? ( domain )
75
77
print_error ( "#{ smbhost } - This system accepts authentication with any credentials, brute force is ineffective." )
76
78
return
77
79
end
78
80
79
81
unless datastore [ 'RECORD_GUEST' ]
80
- if accepts_guest_logins?
82
+ if accepts_guest_logins? ( domain )
81
83
print_status ( "#{ ip } - This system allows guest sessions with any credentials, these instances will not be reported." )
82
84
end
83
85
end
84
86
85
- domain = datastore [ 'SMBDomain' ] || ""
86
-
87
87
begin
88
88
each_user_pass do |user , pass |
89
89
result = try_user_pass ( domain , user , pass )
@@ -128,12 +128,12 @@ def check_login_status(domain, user, pass)
128
128
129
129
# If login is succesful and auth_user is unset
130
130
# the login was as a guest user.
131
- def accepts_guest_logins?
131
+ def accepts_guest_logins? ( domain )
132
132
guest = false
133
133
user = Rex ::Text . rand_text_alpha ( 8 )
134
134
pass = Rex ::Text . rand_text_alpha ( 8 )
135
135
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? )
137
137
138
138
if guest_login
139
139
@accepts_guest_logins [ 'rhost' ] ||=[ ] unless @accepts_guest_logins . include? ( rhost )
@@ -153,10 +153,10 @@ def accepts_guest_logins?
153
153
154
154
# If login is successul and auth_user is set
155
155
# then bogus creds are accepted.
156
- def accepts_bogus_logins?
156
+ def accepts_bogus_logins? ( domain )
157
157
user = Rex ::Text . rand_text_alpha ( 8 )
158
158
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? )
160
160
return bogus_login
161
161
end
162
162
@@ -194,19 +194,19 @@ def try_user_pass(domain, user, pass)
194
194
195
195
case status
196
196
when 'STATUS_SUCCESS'
197
+ # Auth user indicates if the login was as a guest or not
197
198
if ( simple . client . auth_user )
198
199
print_good ( output_message % "SUCCESSFUL LOGIN" )
199
200
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 )
206
202
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
210
210
when *@correct_credentials_status_codes
211
211
print_status ( output_message % "FAILED LOGIN, VALID CREDENTIALS" )
212
212
report_creds ( domain , user , pass , false )
0 commit comments