1
0
mirror of https://github.com/nmap/nmap.git synced 2025-12-27 01:49:03 +00:00

Re-indent some scripts. Whitespace-only commit

https://secwiki.org/w/Nmap/Code_Standards
This commit is contained in:
dmiller
2014-01-31 13:02:29 +00:00
parent 64fb5b3482
commit d36c08dcf5
137 changed files with 3977 additions and 3977 deletions

View File

@@ -35,72 +35,72 @@ portrule = shortport.port_or_service({27017}, {"mongodb"})
Driver = {
new = function(self, host, port, options)
local o = { host = host, port = port, sock = nmap.new_socket() }
setmetatable(o, self)
self.__index = self
return o
end,
new = function(self, host, port, options)
local o = { host = host, port = port, sock = nmap.new_socket() }
setmetatable(o, self)
self.__index = self
return o
end,
connect = function(self)
return self.sock:connect(self.host, self.port)
end,
connect = function(self)
return self.sock:connect(self.host, self.port)
end,
login = function(self, username, password)
local status, resp = mongodb.login(self.sock, arg_db, username, password)
if ( status ) then
return true, brute.Account:new(username, password, creds.State.VALID)
elseif ( resp ~= "Authentication failed" ) then
local err = brute.Error:new( resp )
err:setRetry( true )
return false, err
end
return false, brute.Error:new( "Incorrect password" )
end,
login = function(self, username, password)
local status, resp = mongodb.login(self.sock, arg_db, username, password)
if ( status ) then
return true, brute.Account:new(username, password, creds.State.VALID)
elseif ( resp ~= "Authentication failed" ) then
local err = brute.Error:new( resp )
err:setRetry( true )
return false, err
end
return false, brute.Error:new( "Incorrect password" )
end,
disconnect = function(self)
return self.sock:close()
end,
disconnect = function(self)
return self.sock:close()
end,
}
local function needsAuth(host, port)
local socket = nmap.new_socket()
local status, result = socket:connect(host, port)
if ( not(status) ) then
return false, "Failed to connect to server"
end
local socket = nmap.new_socket()
local status, result = socket:connect(host, port)
if ( not(status) ) then
return false, "Failed to connect to server"
end
local packet
status, packet = mongodb.listDbQuery()
if ( not(status) ) then
return false, result
end
local packet
status, packet = mongodb.listDbQuery()
if ( not(status) ) then
return false, result
end
--- Send packet
status, result = mongodb.query(socket, packet)
if ( not(status) ) then
return false, result
end
--- Send packet
status, result = mongodb.query(socket, packet)
if ( not(status) ) then
return false, result
end
socket:close()
if ( status and result.errmsg ) then
return true
end
return false
socket:close()
if ( status and result.errmsg ) then
return true
end
return false
end
action = function(host, port)
if ( not(needsAuth(host, port)) ) then
return "No authentication needed"
end
if ( not(needsAuth(host, port)) ) then
return "No authentication needed"
end
local engine = brute.Engine:new(Driver, host, port )
local engine = brute.Engine:new(Driver, host, port )
engine.options.script_name = SCRIPT_NAME
engine.options.firstonly = true
local status, result = engine:start()
engine.options.script_name = SCRIPT_NAME
engine.options.firstonly = true
local status, result = engine:start()
return result
return result
end