1
0
mirror of https://github.com/nmap/nmap.git synced 2025-12-28 02:19:04 +00:00

Reindent some scripts. Whitespace only.

https://secwiki.org/w/Nmap/Code_Standards
This commit is contained in:
dmiller
2014-01-31 16:37:27 +00:00
parent 32936167c2
commit 078aa688c9
50 changed files with 2573 additions and 2573 deletions

View File

@@ -66,64 +66,64 @@ 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) )
local req, statusresponse, buildinfo, err
local req, statusresponse, buildinfo, err
-- 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, arg_db, 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, arg_db, cred.user, cred.pass)
if ( not(status) ) then
return err
end
end
port.service = ps
local status, packet = mongodb.serverStatusQuery()
if not status then return packet end
local status, packet = mongodb.serverStatusQuery()
if not status then return packet end
local statQResult, buildQResult
status,statQResult = mongodb.query(socket, packet)
local statQResult, buildQResult
status,statQResult = mongodb.query(socket, packet)
if not status then return statQResult end
if not status then return statQResult end
port.version.name ='mongodb'
port.version.product='MongoDB'
port.version.name_confidence = 10
nmap.set_port_version(host,port)
port.version.name ='mongodb'
port.version.product='MongoDB'
port.version.name_confidence = 10
nmap.set_port_version(host,port)
status, packet = mongodb.buildInfoQuery()
if not status then return packet end
status, packet = mongodb.buildInfoQuery()
if not status then return packet end
status, buildQResult = mongodb.query(socket,packet )
status, buildQResult = mongodb.query(socket,packet )
if not status then
stdnse.log_error(buildQResult)
return buildQResult
end
if not status then
stdnse.log_error(buildQResult)
return buildQResult
end
local versionNumber = buildQResult['version']
port.version.product='MongoDB '..versionNumber
nmap.set_port_version(host,port)
local versionNumber = buildQResult['version']
port.version.product='MongoDB '..versionNumber
nmap.set_port_version(host,port)
local stat_out = mongodb.queryResultToTable(statQResult)
local build_out = mongodb.queryResultToTable(buildQResult)
local output = {"MongoDB Build info",build_out,"Server status",stat_out}
local stat_out = mongodb.queryResultToTable(statQResult)
local build_out = mongodb.queryResultToTable(buildQResult)
local output = {"MongoDB Build info",build_out,"Server status",stat_out}
return stdnse.format_output(true, output )
return stdnse.format_output(true, output )
end