mirror of
https://github.com/nmap/nmap.git
synced 2025-12-27 09:59:04 +00:00
Reindent some scripts. Whitespace only.
https://secwiki.org/w/Nmap/Code_Standards
This commit is contained in:
@@ -33,42 +33,42 @@ portrule = shortport.port_or_service(5060, "sip", {"tcp", "udp"})
|
||||
|
||||
Driver = {
|
||||
|
||||
new = function(self, host, port)
|
||||
local o = {}
|
||||
setmetatable(o, self)
|
||||
self.__index = self
|
||||
o.host = host
|
||||
o.port = port
|
||||
return o
|
||||
end,
|
||||
new = function(self, host, port)
|
||||
local o = {}
|
||||
setmetatable(o, self)
|
||||
self.__index = self
|
||||
o.host = host
|
||||
o.port = port
|
||||
return o
|
||||
end,
|
||||
|
||||
connect = function( self )
|
||||
self.helper = sip.Helper:new(self.host, self.port, { expires = 0 })
|
||||
local status, err = self.helper:connect()
|
||||
if ( not(status) ) then
|
||||
return "ERROR: Failed to connect to SIP server"
|
||||
end
|
||||
return true
|
||||
end,
|
||||
connect = function( self )
|
||||
self.helper = sip.Helper:new(self.host, self.port, { expires = 0 })
|
||||
local status, err = self.helper:connect()
|
||||
if ( not(status) ) then
|
||||
return "ERROR: Failed to connect to SIP server"
|
||||
end
|
||||
return true
|
||||
end,
|
||||
|
||||
login = function( self, username, password )
|
||||
self.helper:setCredentials(username, password)
|
||||
local status, err = self.helper:register()
|
||||
if ( not(status) ) then
|
||||
-- The 3CX System has an anti-hacking option that triggers after
|
||||
-- a certain amount of guesses. This protection basically prevents
|
||||
-- any connection from the offending IP at an application level.
|
||||
if ( err:match("^403 Forbidden") ) then
|
||||
local err = brute.Error:new("The systems seems to have blocked our IP")
|
||||
err:setAbort( true )
|
||||
return false, err
|
||||
end
|
||||
return false, brute.Error:new( "Incorrect password" )
|
||||
end
|
||||
return true, brute.Account:new(username, password, creds.State.VALID)
|
||||
end,
|
||||
login = function( self, username, password )
|
||||
self.helper:setCredentials(username, password)
|
||||
local status, err = self.helper:register()
|
||||
if ( not(status) ) then
|
||||
-- The 3CX System has an anti-hacking option that triggers after
|
||||
-- a certain amount of guesses. This protection basically prevents
|
||||
-- any connection from the offending IP at an application level.
|
||||
if ( err:match("^403 Forbidden") ) then
|
||||
local err = brute.Error:new("The systems seems to have blocked our IP")
|
||||
err:setAbort( true )
|
||||
return false, err
|
||||
end
|
||||
return false, brute.Error:new( "Incorrect password" )
|
||||
end
|
||||
return true, brute.Account:new(username, password, creds.State.VALID)
|
||||
end,
|
||||
|
||||
disconnect = function(self) return self.helper:close() end,
|
||||
disconnect = function(self) return self.helper:close() end,
|
||||
}
|
||||
|
||||
-- Function used to check if we can distinguish existing from non-existing
|
||||
@@ -77,34 +77,34 @@ Driver = {
|
||||
-- was successful which makes it impossible to tell successfull logins
|
||||
-- from non-existing accounts apart.
|
||||
local function checkBadUser(host, port)
|
||||
local user = "baduser-" .. math.random(10000)
|
||||
local pass = "badpass-" .. math.random(10000)
|
||||
local helper = sip.Helper:new(host, port, { expires = 0 })
|
||||
local user = "baduser-" .. math.random(10000)
|
||||
local pass = "badpass-" .. math.random(10000)
|
||||
local helper = sip.Helper:new(host, port, { expires = 0 })
|
||||
|
||||
stdnse.print_debug(2, "Checking bad user: %s/%s", user, pass)
|
||||
local status, err = helper:connect()
|
||||
if ( not(status) ) then return false, "ERROR: Failed to connect" end
|
||||
stdnse.print_debug(2, "Checking bad user: %s/%s", user, pass)
|
||||
local status, err = helper:connect()
|
||||
if ( not(status) ) then return false, "ERROR: Failed to connect" end
|
||||
|
||||
helper:setCredentials(user, pass)
|
||||
local status, err = helper:register()
|
||||
helper:close()
|
||||
return status, err
|
||||
helper:setCredentials(user, pass)
|
||||
local status, err = helper:register()
|
||||
helper:close()
|
||||
return status, err
|
||||
end
|
||||
|
||||
action = function(host, port)
|
||||
local force = stdnse.get_script_args("sip-brute.force")
|
||||
local force = stdnse.get_script_args("sip-brute.force")
|
||||
|
||||
if ( not(force) ) then
|
||||
local status = checkBadUser(host, port)
|
||||
if ( status ) then
|
||||
return "\nERROR: Cannot detect non-existing user accounts, this will result in:\n" ..
|
||||
" * Non-exisiting accounts being detected as found\n" ..
|
||||
" * Passwords for existing accounts being correctly detected\n\n" ..
|
||||
"Supply the sip-brute.force argument to override"
|
||||
end
|
||||
end
|
||||
local engine = brute.Engine:new(Driver, host, port)
|
||||
engine.options.script_name = SCRIPT_NAME
|
||||
local status, result = engine:start()
|
||||
return result
|
||||
if ( not(force) ) then
|
||||
local status = checkBadUser(host, port)
|
||||
if ( status ) then
|
||||
return "\nERROR: Cannot detect non-existing user accounts, this will result in:\n" ..
|
||||
" * Non-exisiting accounts being detected as found\n" ..
|
||||
" * Passwords for existing accounts being correctly detected\n\n" ..
|
||||
"Supply the sip-brute.force argument to override"
|
||||
end
|
||||
end
|
||||
local engine = brute.Engine:new(Driver, host, port)
|
||||
engine.options.script_name = SCRIPT_NAME
|
||||
local status, result = engine:start()
|
||||
return result
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user