mirror of
https://github.com/nmap/nmap.git
synced 2025-12-06 04:31:29 +00:00
Reindent some scripts. Whitespace only.
https://secwiki.org/w/Nmap/Code_Standards
This commit is contained in:
@@ -53,57 +53,57 @@ portrule = shortport.port_or_service(3306, "mysql")
|
||||
|
||||
action = function( host, port )
|
||||
|
||||
local socket = nmap.new_socket()
|
||||
local catch = function() socket:close() end
|
||||
local try = nmap.new_try(catch)
|
||||
local result, response = {}, nil
|
||||
local users = {}
|
||||
local nmap_args = nmap.registry.args
|
||||
local status, rows
|
||||
local socket = nmap.new_socket()
|
||||
local catch = function() socket:close() end
|
||||
local try = nmap.new_try(catch)
|
||||
local result, response = {}, nil
|
||||
local users = {}
|
||||
local nmap_args = nmap.registry.args
|
||||
local status, rows
|
||||
|
||||
-- set a reasonable timeout value
|
||||
socket:set_timeout(5000)
|
||||
-- set a reasonable timeout value
|
||||
socket:set_timeout(5000)
|
||||
|
||||
-- first, let's see if the script has any credentials as arguments?
|
||||
if nmap_args.mysqluser then
|
||||
users[nmap_args.mysqluser] = nmap_args.mysqlpass or ""
|
||||
-- next, let's see if mysql-brute or mysql-empty-password brought us anything
|
||||
elseif nmap.registry.mysqlusers then
|
||||
-- do we have root credentials?
|
||||
if nmap.registry.mysqlusers['root'] then
|
||||
users['root'] = nmap.registry.mysqlusers['root']
|
||||
else
|
||||
-- we didn't have root, so let's make sure we loop over them all
|
||||
users = nmap.registry.mysqlusers
|
||||
end
|
||||
-- last, no dice, we don't have any credentials at all
|
||||
else
|
||||
stdnse.print_debug("No credentials supplied, aborting ...")
|
||||
return
|
||||
end
|
||||
-- first, let's see if the script has any credentials as arguments?
|
||||
if nmap_args.mysqluser then
|
||||
users[nmap_args.mysqluser] = nmap_args.mysqlpass or ""
|
||||
-- next, let's see if mysql-brute or mysql-empty-password brought us anything
|
||||
elseif nmap.registry.mysqlusers then
|
||||
-- do we have root credentials?
|
||||
if nmap.registry.mysqlusers['root'] then
|
||||
users['root'] = nmap.registry.mysqlusers['root']
|
||||
else
|
||||
-- we didn't have root, so let's make sure we loop over them all
|
||||
users = nmap.registry.mysqlusers
|
||||
end
|
||||
-- last, no dice, we don't have any credentials at all
|
||||
else
|
||||
stdnse.print_debug("No credentials supplied, aborting ...")
|
||||
return
|
||||
end
|
||||
|
||||
--
|
||||
-- Iterates over credentials, breaks once it successfully recieves results
|
||||
--
|
||||
for username, password in pairs(users) do
|
||||
--
|
||||
-- Iterates over credentials, breaks once it successfully recieves results
|
||||
--
|
||||
for username, password in pairs(users) do
|
||||
|
||||
try( socket:connect(host, port) )
|
||||
try( socket:connect(host, port) )
|
||||
|
||||
response = try( mysql.receiveGreeting( socket ) )
|
||||
status, response = mysql.loginRequest( socket, { authversion = "post41", charset = response.charset }, username, password, response.salt )
|
||||
response = try( mysql.receiveGreeting( socket ) )
|
||||
status, response = mysql.loginRequest( socket, { authversion = "post41", charset = response.charset }, username, password, response.salt )
|
||||
|
||||
if status and response.errorcode == 0 then
|
||||
local status, rs = mysql.sqlQuery( socket, "show variables" )
|
||||
if status then
|
||||
for _, row in ipairs(rs.rows) do
|
||||
table.insert(result, ("%s: %s"):format(row[1], row[2]) )
|
||||
end
|
||||
end
|
||||
end
|
||||
if status and response.errorcode == 0 then
|
||||
local status, rs = mysql.sqlQuery( socket, "show variables" )
|
||||
if status then
|
||||
for _, row in ipairs(rs.rows) do
|
||||
table.insert(result, ("%s: %s"):format(row[1], row[2]) )
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
socket:close()
|
||||
end
|
||||
socket:close()
|
||||
end
|
||||
|
||||
return stdnse.format_output(true, result)
|
||||
return stdnse.format_output(true, result)
|
||||
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user