1
0
mirror of https://github.com/nmap/nmap.git synced 2026-01-23 22:59:20 +00:00

Fixed a really tricky bug that I spent all evening chasing. Normally, during login, every account in the list (by default, guest and anonymous) are attempted. Unless something fails badly, anonymous will work. Unfortunately, if something DOES fail badly, after the first script runs this list is empty. That means if something bad is happening, and two or more scripts are running, every script after the first will have an empty list of accounts to use, and it would fail mysteriously. This patch checks the return value from the get_next_account() function properly to see if we've run out of accounts and report that to the user rather than an ugly stacktrace.

This commit is contained in:
ron
2010-09-24 00:47:43 +00:00
parent 3bc39efc4b
commit 2035b82dfd

View File

@@ -1301,6 +1301,9 @@ function start_session_extended(smb, log_errors, overrides)
local os, lanmanager
local username, domain, password, password_hash, hash_type
-- Set a default status_name, in case everything fails
status_name = "An unknown error has occurred"
-- Get the first account, unless they overrode it
if(overrides ~= nil and overrides['username'] ~= nil) then
result = true
@@ -1311,6 +1314,9 @@ function start_session_extended(smb, log_errors, overrides)
hash_type = overrides['hash_type']
else
result, username, domain, password, password_hash, hash_type = smbauth.get_account(smb['host'])
if(not(result)) then
return result, username
end
end
while result ~= false do
@@ -1429,6 +1435,9 @@ function start_session_extended(smb, log_errors, overrides)
if(overrides == nil or overrides['username'] == nil) then
smbauth.next_account(smb['host'])
result, username, domain, password, password_hash, hash_type = smbauth.get_account(smb['host'])
if(not(result)) then
return false, username
end
else
result = false
end