mirror of
https://github.com/nmap/nmap.git
synced 2025-12-07 13:11:28 +00:00
Re-indent some scripts. Whitespace-only commit
https://secwiki.org/w/Nmap/Code_Standards
This commit is contained in:
@@ -51,50 +51,50 @@ portrule = shortport.port_or_service({27017}, {"mongodb"})
|
||||
|
||||
function action(host,port)
|
||||
|
||||
local socket = nmap.new_socket()
|
||||
local socket = nmap.new_socket()
|
||||
|
||||
-- set a reasonable timeout value
|
||||
socket:set_timeout(10000)
|
||||
-- do some exception / cleanup
|
||||
local catch = function()
|
||||
socket:close()
|
||||
end
|
||||
-- set a reasonable timeout value
|
||||
socket:set_timeout(10000)
|
||||
-- do some exception / cleanup
|
||||
local catch = function()
|
||||
socket:close()
|
||||
end
|
||||
|
||||
local try = nmap.new_try(catch)
|
||||
local try = nmap.new_try(catch)
|
||||
|
||||
try( socket:connect(host, port) )
|
||||
try( socket:connect(host, port) )
|
||||
|
||||
-- uglyness to allow creds.mongodb to work, as the port is not recognized
|
||||
-- as mongodb, unless a service scan was run
|
||||
local ps = port.service
|
||||
port.service = 'mongodb'
|
||||
local c = creds.Credentials:new(creds.ALL_DATA, host, port)
|
||||
for cred in c:getCredentials(creds.State.VALID + creds.State.PARAM) do
|
||||
local status, err = mongodb.login(socket, "admin", cred.user, cred.pass)
|
||||
if ( not(status) ) then
|
||||
return err
|
||||
end
|
||||
end
|
||||
port.service = ps
|
||||
-- uglyness to allow creds.mongodb to work, as the port is not recognized
|
||||
-- as mongodb, unless a service scan was run
|
||||
local ps = port.service
|
||||
port.service = 'mongodb'
|
||||
local c = creds.Credentials:new(creds.ALL_DATA, host, port)
|
||||
for cred in c:getCredentials(creds.State.VALID + creds.State.PARAM) do
|
||||
local status, err = mongodb.login(socket, "admin", cred.user, cred.pass)
|
||||
if ( not(status) ) then
|
||||
return err
|
||||
end
|
||||
end
|
||||
port.service = ps
|
||||
|
||||
local req, result, packet, err, status
|
||||
--Build packet
|
||||
status, packet = mongodb.listDbQuery()
|
||||
if not status then return result end-- Error message
|
||||
local req, result, packet, err, status
|
||||
--Build packet
|
||||
status, packet = mongodb.listDbQuery()
|
||||
if not status then return result end-- Error message
|
||||
|
||||
--- Send packet
|
||||
status, result = mongodb.query(socket, packet)
|
||||
if not status then return result end-- Error message
|
||||
--- Send packet
|
||||
status, result = mongodb.query(socket, packet)
|
||||
if not status then return result end-- Error message
|
||||
|
||||
port.version.name ='mongodb'
|
||||
port.version.product='MongoDB'
|
||||
nmap.set_port_version(host,port)
|
||||
port.version.name ='mongodb'
|
||||
port.version.product='MongoDB'
|
||||
nmap.set_port_version(host,port)
|
||||
|
||||
local output = mongodb.queryResultToTable(result)
|
||||
if err ~= nil then
|
||||
stdnse.log_error(err)
|
||||
end
|
||||
if result ~= nil then
|
||||
return stdnse.format_output(true, output )
|
||||
end
|
||||
local output = mongodb.queryResultToTable(result)
|
||||
if err ~= nil then
|
||||
stdnse.log_error(err)
|
||||
end
|
||||
if result ~= nil then
|
||||
return stdnse.format_output(true, output )
|
||||
end
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user