mirror of
https://github.com/nmap/nmap.git
synced 2025-12-10 17:59:04 +00:00
Squashed commit of the following:
commit 7c26e4de2ab365a30fe6e91f3a531eb38c8dfdba Author: Daniel Miller <bonsaiviking@gmail.com> Date: Tue Aug 7 16:36:54 2012 -0500 Fix indentation on netbios.lua (no code change) commit 47dc3e32e6b47bd80620cfbc54e7590193dd0c1a Author: Daniel Miller <bonsaiviking@gmail.com> Date: Tue Jul 31 16:42:27 2012 -0500 Make smbauth.lua use host, not nmap, registry commit 3738f8e6d551a1260463609d8cda86918843a372 Author: Daniel Miller <bonsaiviking@gmail.com> Date: Tue Jul 31 16:35:45 2012 -0500 Make netbios.lua use host registry. Functions now can take host table or IP commit 031cadb9d407ab7fd43aaddffda1a89c24cbdd45 Author: Daniel Miller <bonsaiviking@gmail.com> Date: Tue Jul 31 15:54:12 2012 -0500 Remove mac-geolocation info from snmp-interfaces commit 2218dbaf8ffd4a33de2bc028def9be7301dfb3a2 Author: Daniel Miller <bonsaiviking@gmail.com> Date: Tue Jul 31 15:52:36 2012 -0500 Make path-mtu.nse use host, not nmap, registry commit 5a3d006bdb9cd3e981a8e753c92b5ade5059a29b Author: Daniel Miller <bonsaiviking@gmail.com> Date: Tue Jul 31 15:51:53 2012 -0500 Make cvs-* scripts use host, not nmap, registry
This commit is contained in:
@@ -105,11 +105,11 @@ local ACCOUNT_TYPES = {
|
||||
}
|
||||
|
||||
local function account_exists(host, username, domain)
|
||||
if(nmap.registry[host.ip] == nil or nmap.registry[host.ip]['smbaccounts'] == nil) then
|
||||
if(host.registry['smbaccounts'] == nil) then
|
||||
return false
|
||||
end
|
||||
|
||||
for i, j in pairs(nmap.registry[host.ip]['smbaccounts']) do
|
||||
for i, j in pairs(host.registry['smbaccounts']) do
|
||||
if(j['username'] == username and j['domain'] == domain) then
|
||||
return true
|
||||
end
|
||||
@@ -120,13 +120,13 @@ end
|
||||
|
||||
function next_account(host, num)
|
||||
if(num == nil) then
|
||||
if(nmap.registry[host.ip]['smbindex'] == nil) then
|
||||
nmap.registry[host.ip]['smbindex'] = 1
|
||||
if(host.registry['smbindex'] == nil) then
|
||||
host.registry['smbindex'] = 1
|
||||
else
|
||||
nmap.registry[host.ip]['smbindex'] = nmap.registry[host.ip]['smbindex'] + 1
|
||||
host.registry['smbindex'] = host.registry['smbindex'] + 1
|
||||
end
|
||||
else
|
||||
nmap.registry[host.ip]['smbindex'] = num
|
||||
host.registry['smbindex'] = num
|
||||
end
|
||||
end
|
||||
|
||||
@@ -165,11 +165,8 @@ function add_account(host, username, domain, password, password_hash, hash_type,
|
||||
return
|
||||
end
|
||||
|
||||
if(nmap.registry[host.ip] == nil) then
|
||||
nmap.registry[host.ip] = {}
|
||||
end
|
||||
if(nmap.registry[host.ip]['smbaccounts'] == nil) then
|
||||
nmap.registry[host.ip]['smbaccounts'] = {}
|
||||
if(host.registry['smbaccounts'] == nil) then
|
||||
host.registry['smbaccounts'] = {}
|
||||
end
|
||||
|
||||
-- Determine the type of account, if it wasn't given
|
||||
@@ -204,10 +201,10 @@ function add_account(host, username, domain, password, password_hash, hash_type,
|
||||
new_entry['account_type'] = account_type
|
||||
|
||||
-- Insert the new entry into the table
|
||||
table.insert(nmap.registry[host.ip]['smbaccounts'], new_entry)
|
||||
table.insert(host.registry['smbaccounts'], new_entry)
|
||||
|
||||
-- Sort the table based on the account type (we want anonymous at the end, administrator at the front)
|
||||
table.sort(nmap.registry[host.ip]['smbaccounts'], function(a,b) return a['account_type'] > b['account_type'] end)
|
||||
table.sort(host.registry['smbaccounts'], function(a,b) return a['account_type'] > b['account_type'] end)
|
||||
|
||||
-- Print a debug message
|
||||
stdnse.print_debug(1, "SMB: Added account '%s' to account list", username)
|
||||
@@ -215,7 +212,7 @@ function add_account(host, username, domain, password, password_hash, hash_type,
|
||||
-- Reset the credentials
|
||||
next_account(host, 1)
|
||||
|
||||
-- io.write("\n\n" .. nsedebug.tostr(nmap.registry[host.ip]['smbaccounts']) .. "\n\n")
|
||||
-- io.write("\n\n" .. nsedebug.tostr(host.registry['smbaccounts']) .. "\n\n")
|
||||
end
|
||||
|
||||
---Retrieve the current set of credentials set in the registry. If these fail, <code>next_credentials</code> should be
|
||||
@@ -225,12 +222,12 @@ end
|
||||
--@return (result, username, domain, password, password_hash, hash_type) If result is false, username is an error message. Otherwise, username and password are
|
||||
-- the current username and password that should be used.
|
||||
function get_account(host)
|
||||
if(nmap.registry[host.ip]['smbindex'] == nil) then
|
||||
nmap.registry[host.ip]['smbindex'] = 1
|
||||
if(host.registry['smbindex'] == nil) then
|
||||
host.registry['smbindex'] = 1
|
||||
end
|
||||
|
||||
local index = nmap.registry[host.ip]['smbindex']
|
||||
local account = nmap.registry[host.ip]['smbaccounts'][index]
|
||||
local index = host.registry['smbindex']
|
||||
local account = host.registry['smbaccounts'][index]
|
||||
|
||||
if(account == nil) then
|
||||
return false, "No accounts left to try"
|
||||
@@ -244,18 +241,13 @@ end
|
||||
--
|
||||
--@param host The host object.
|
||||
function init_account(host)
|
||||
-- Create the key if it exists
|
||||
if(nmap.registry[host.ip] == nil) then
|
||||
nmap.registry[host.ip] = {}
|
||||
end
|
||||
|
||||
-- Don't run this more than once for each host
|
||||
if(nmap.registry[host.ip]['smbaccounts'] ~= nil) then
|
||||
if(host.registry['smbaccounts'] ~= nil) then
|
||||
return
|
||||
end
|
||||
|
||||
-- Create the list
|
||||
nmap.registry[host.ip]['smbaccounts'] = {}
|
||||
host.registry['smbaccounts'] = {}
|
||||
|
||||
-- Add the anonymous/guest accounts
|
||||
add_account(host, '', '', '', nil, 'none')
|
||||
|
||||
Reference in New Issue
Block a user