mirror of
https://github.com/nmap/nmap.git
synced 2025-12-07 21:21:31 +00:00
Re-indent some scripts. Whitespace-only commit
https://secwiki.org/w/Nmap/Code_Standards
This commit is contained in:
@@ -48,26 +48,26 @@ portrule = shortport.port_or_service(1521, 'oracle-tns' )
|
||||
|
||||
local function checkAccount( host, port, user )
|
||||
|
||||
local helper = tns.Helper:new( host, port, nmap.registry.args['oracle-enum-users.sid'] )
|
||||
local status, data = helper:Connect()
|
||||
local tnscomm, auth
|
||||
local auth_options = tns.AuthOptions:new()
|
||||
local helper = tns.Helper:new( host, port, nmap.registry.args['oracle-enum-users.sid'] )
|
||||
local status, data = helper:Connect()
|
||||
local tnscomm, auth
|
||||
local auth_options = tns.AuthOptions:new()
|
||||
|
||||
|
||||
if ( not(status) ) then
|
||||
return false, data
|
||||
end
|
||||
if ( not(status) ) then
|
||||
return false, data
|
||||
end
|
||||
|
||||
-- A bit ugly, the helper should probably provide a getSocket function
|
||||
tnscomm = tns.Comm:new( helper.tnssocket )
|
||||
-- A bit ugly, the helper should probably provide a getSocket function
|
||||
tnscomm = tns.Comm:new( helper.tnssocket )
|
||||
|
||||
status, auth = tnscomm:exchTNSPacket( tns.Packet.PreAuth:new( user, auth_options, helper.os ) )
|
||||
if ( not(status) ) then
|
||||
return false, auth
|
||||
end
|
||||
helper:Close()
|
||||
status, auth = tnscomm:exchTNSPacket( tns.Packet.PreAuth:new( user, auth_options, helper.os ) )
|
||||
if ( not(status) ) then
|
||||
return false, auth
|
||||
end
|
||||
helper:Close()
|
||||
|
||||
return true, auth["AUTH_VFR_DATA"]
|
||||
return true, auth["AUTH_VFR_DATA"]
|
||||
end
|
||||
|
||||
---Generates a random string of the requested length. This can be used to check how hosts react to
|
||||
@@ -76,85 +76,85 @@ end
|
||||
--@param set (optional) The set of letters to choose from. Default: upper, lower, numbers, and underscore.
|
||||
--@return The random string.
|
||||
local function get_random_string(length, set)
|
||||
if(length == nil) then
|
||||
length = 8
|
||||
end
|
||||
if(length == nil) then
|
||||
length = 8
|
||||
end
|
||||
|
||||
if(set == nil) then
|
||||
set = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789_"
|
||||
end
|
||||
if(set == nil) then
|
||||
set = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789_"
|
||||
end
|
||||
|
||||
local str = ""
|
||||
local str = ""
|
||||
|
||||
for i = 1, length, 1 do
|
||||
local random = math.random(#set)
|
||||
str = str .. string.sub(set, random, random)
|
||||
end
|
||||
for i = 1, length, 1 do
|
||||
local random = math.random(#set)
|
||||
str = str .. string.sub(set, random, random)
|
||||
end
|
||||
|
||||
return str
|
||||
return str
|
||||
end
|
||||
|
||||
|
||||
|
||||
action = function( host, port )
|
||||
|
||||
local known_good_accounts = { "system", "sys", "dbsnmp", "scott" }
|
||||
local known_good_accounts = { "system", "sys", "dbsnmp", "scott" }
|
||||
|
||||
local status, salt
|
||||
local count = 0
|
||||
local result = {}
|
||||
local usernames
|
||||
local status, salt
|
||||
local count = 0
|
||||
local result = {}
|
||||
local usernames
|
||||
|
||||
if ( not( nmap.registry.args['oracle-enum-users.sid'] ) and not( nmap.registry.args['tns.sid'] ) ) then
|
||||
return "ERROR: Oracle instance not set (see oracle-enum-users.sid or tns.sid)"
|
||||
end
|
||||
if ( not( nmap.registry.args['oracle-enum-users.sid'] ) and not( nmap.registry.args['tns.sid'] ) ) then
|
||||
return "ERROR: Oracle instance not set (see oracle-enum-users.sid or tns.sid)"
|
||||
end
|
||||
|
||||
status, usernames = unpwdb.usernames()
|
||||
if( not(status) ) then
|
||||
return stdnse.format_output(true, "ERROR: Failed to load the usernames dictionary")
|
||||
end
|
||||
status, usernames = unpwdb.usernames()
|
||||
if( not(status) ) then
|
||||
return stdnse.format_output(true, "ERROR: Failed to load the usernames dictionary")
|
||||
end
|
||||
|
||||
-- Check for some known good accounts
|
||||
for _, user in ipairs( known_good_accounts ) do
|
||||
status, salt = checkAccount(host, port, user)
|
||||
if( not(status) ) then return salt end
|
||||
if ( salt ) then
|
||||
count = count + #salt
|
||||
end
|
||||
end
|
||||
-- Check for some known good accounts
|
||||
for _, user in ipairs( known_good_accounts ) do
|
||||
status, salt = checkAccount(host, port, user)
|
||||
if( not(status) ) then return salt end
|
||||
if ( salt ) then
|
||||
count = count + #salt
|
||||
end
|
||||
end
|
||||
|
||||
-- did we atleast get a single salt back?
|
||||
if ( count < 20 ) then
|
||||
return stdnse.format_output(true, "ERROR: None of the known accounts were detected (oracle < 11g)")
|
||||
end
|
||||
-- did we atleast get a single salt back?
|
||||
if ( count < 20 ) then
|
||||
return stdnse.format_output(true, "ERROR: None of the known accounts were detected (oracle < 11g)")
|
||||
end
|
||||
|
||||
-- Check for some known bad accounts
|
||||
count = 0
|
||||
for i=1, 10 do
|
||||
local user = get_random_string(10)
|
||||
status, salt = checkAccount(host, port, user)
|
||||
if( not(status) ) then return salt end
|
||||
if ( salt ) then
|
||||
count = count + #salt
|
||||
end
|
||||
end
|
||||
-- Check for some known bad accounts
|
||||
count = 0
|
||||
for i=1, 10 do
|
||||
local user = get_random_string(10)
|
||||
status, salt = checkAccount(host, port, user)
|
||||
if( not(status) ) then return salt end
|
||||
if ( salt ) then
|
||||
count = count + #salt
|
||||
end
|
||||
end
|
||||
|
||||
-- It's unlikely that we hit 3 random combinations as valid users
|
||||
if ( count > 60 ) then
|
||||
return stdnse.format_output(true, ("ERROR: %d of %d random accounts were detected (Patched Oracle 11G or Oracle 11G R2)"):format(count/20, 10))
|
||||
end
|
||||
-- It's unlikely that we hit 3 random combinations as valid users
|
||||
if ( count > 60 ) then
|
||||
return stdnse.format_output(true, ("ERROR: %d of %d random accounts were detected (Patched Oracle 11G or Oracle 11G R2)"):format(count/20, 10))
|
||||
end
|
||||
|
||||
for user in usernames do
|
||||
status, salt = checkAccount(host, port, user)
|
||||
if ( not(status) ) then return salt end
|
||||
if ( salt and #salt == 20 ) then
|
||||
table.insert( result, ("%s is a valid user account"):format(user))
|
||||
end
|
||||
end
|
||||
for user in usernames do
|
||||
status, salt = checkAccount(host, port, user)
|
||||
if ( not(status) ) then return salt end
|
||||
if ( salt and #salt == 20 ) then
|
||||
table.insert( result, ("%s is a valid user account"):format(user))
|
||||
end
|
||||
end
|
||||
|
||||
if ( #result == 0 ) then
|
||||
table.insert( result, "Failed to find any valid user accounts")
|
||||
end
|
||||
if ( #result == 0 ) then
|
||||
table.insert( result, "Failed to find any valid user accounts")
|
||||
end
|
||||
|
||||
return stdnse.format_output(true, result)
|
||||
return stdnse.format_output(true, result)
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user