mirror of
https://github.com/nmap/nmap.git
synced 2025-12-24 08:29:04 +00:00
Remove trailing whitespace in lua files
Whitespace is not significant, so this should not be a problem. https://secwiki.org/w/Nmap/Code_Standards
This commit is contained in:
@@ -16,7 +16,7 @@ Performs brute force password auditing against Subversion source code control se
|
||||
-- @output
|
||||
-- PORT STATE SERVICE REASON
|
||||
-- 3690/tcp open svn syn-ack
|
||||
-- | svn-brute:
|
||||
-- | svn-brute:
|
||||
-- | Accounts
|
||||
-- |_ patrik:secret => Login correct
|
||||
--
|
||||
@@ -44,10 +44,10 @@ categories = {"intrusive", "brute"}
|
||||
|
||||
portrule = shortport.port_or_service(3690, "svnserve", "tcp", "open")
|
||||
|
||||
svn =
|
||||
svn =
|
||||
{
|
||||
svn_client = "nmap-brute v0.1",
|
||||
|
||||
|
||||
new = function(self, host, port, repo)
|
||||
local o = {}
|
||||
setmetatable(o, self)
|
||||
@@ -62,11 +62,11 @@ svn =
|
||||
--- Connects to the SVN - repository
|
||||
--
|
||||
-- @return status true on success, false on failure
|
||||
-- @return err string containing an error message on failure
|
||||
-- @return err string containing an error message on failure
|
||||
connect = function(self)
|
||||
local repo_url = ( "svn://%s/%s" ):format(self.host.ip, self.repo)
|
||||
local status, msg
|
||||
|
||||
|
||||
self.socket = nmap.new_socket()
|
||||
|
||||
local result
|
||||
@@ -74,23 +74,23 @@ svn =
|
||||
if( not(status) ) then
|
||||
return false, result
|
||||
end
|
||||
|
||||
|
||||
status, msg = self.socket:receive_bytes(1)
|
||||
if ( not(status) or not( msg:match("^%( success") ) ) then
|
||||
return false, "Banner reports failure"
|
||||
end
|
||||
|
||||
|
||||
msg = ("( 2 ( edit-pipeline svndiff1 absent-entries depth mergeinfo log-revprops ) %d:%s %d:%s ( ) ) "):format( #repo_url, repo_url, #self.svn_client, self.svn_client )
|
||||
status = self.socket:send( msg )
|
||||
if ( not(status) ) then
|
||||
return false, "Send failed"
|
||||
end
|
||||
|
||||
|
||||
status, msg = self.socket:receive_bytes(1)
|
||||
if ( not(status) ) then
|
||||
return false, "Receive failed"
|
||||
end
|
||||
|
||||
|
||||
if ( msg:match("%( success") ) then
|
||||
local tmp = msg:match("%( success %( %( ([%S+%s*]-) %)")
|
||||
if ( not(tmp) ) then return false, "Failed to detect authentication" end
|
||||
@@ -101,9 +101,9 @@ svn =
|
||||
return false
|
||||
end
|
||||
|
||||
return true
|
||||
return true
|
||||
end,
|
||||
|
||||
|
||||
--- Attempts to login to the SVN server
|
||||
--
|
||||
-- @param username string containing the login username
|
||||
@@ -113,31 +113,31 @@ svn =
|
||||
login = function( self, username, password )
|
||||
local status, msg
|
||||
local challenge, digest
|
||||
|
||||
|
||||
if ( self.auth_mech["CRAM-MD5"] ) then
|
||||
msg = "( CRAM-MD5 ( ) ) "
|
||||
status = self.socket:send( msg )
|
||||
|
||||
|
||||
status, msg = self.socket:receive_bytes(1)
|
||||
if ( not(status) ) then
|
||||
return false, "error"
|
||||
end
|
||||
|
||||
|
||||
challenge = msg:match("<.+>")
|
||||
|
||||
|
||||
if ( not(challenge) ) then
|
||||
return false, "Failed to read challenge"
|
||||
end
|
||||
|
||||
|
||||
digest = stdnse.tohex(openssl.hmac('md5', password, challenge))
|
||||
msg = ("%d:%s %s "):format(#username + 1 + #digest, username, digest)
|
||||
self.socket:send( msg )
|
||||
|
||||
|
||||
status, msg = self.socket:receive_bytes(1)
|
||||
if ( not(status) ) then
|
||||
return false, "error"
|
||||
end
|
||||
|
||||
|
||||
if ( msg:match("Username not found") ) then
|
||||
return false, "Username not found"
|
||||
elseif ( msg:match("success") ) then
|
||||
@@ -148,21 +148,21 @@ svn =
|
||||
else
|
||||
return false, "Unsupported auth-mechanism"
|
||||
end
|
||||
|
||||
|
||||
end,
|
||||
|
||||
|
||||
--- Close the SVN connection
|
||||
--
|
||||
-- @return status true on success, false on failure
|
||||
close = function(self)
|
||||
return self.socket:close()
|
||||
end,
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
Driver =
|
||||
{
|
||||
{
|
||||
new = function(self, host, port, invalid_users )
|
||||
local o = {}
|
||||
setmetatable(o, self)
|
||||
@@ -173,10 +173,10 @@ Driver =
|
||||
o.invalid_users = invalid_users
|
||||
return o
|
||||
end,
|
||||
|
||||
|
||||
connect = function( self )
|
||||
local status, msg
|
||||
|
||||
|
||||
self.svn = svn:new( self.host, self.port, self.repo )
|
||||
status, msg = self.svn:connect()
|
||||
if ( not(status) ) then
|
||||
@@ -185,14 +185,14 @@ Driver =
|
||||
err:setRetry( true )
|
||||
return false, err
|
||||
end
|
||||
|
||||
|
||||
return true
|
||||
end,
|
||||
|
||||
|
||||
disconnect = function( self )
|
||||
self.svn:close()
|
||||
end,
|
||||
|
||||
|
||||
--- Attempts to login to the SVN server
|
||||
--
|
||||
-- @param username string containing the login username
|
||||
@@ -201,12 +201,12 @@ Driver =
|
||||
-- @return brute.Error object on failure
|
||||
-- brute.Account object on success
|
||||
login = function( self, username, password )
|
||||
local status, msg
|
||||
|
||||
local status, msg
|
||||
|
||||
if ( self.invalid_users[username] ) then
|
||||
return false, brute.Error:new( "User is invalid" )
|
||||
end
|
||||
|
||||
|
||||
status, msg = self.svn:login( username, password )
|
||||
|
||||
if ( not(status) and msg:match("Username not found") ) then
|
||||
@@ -218,7 +218,7 @@ Driver =
|
||||
return false, brute.Error:new( "Incorrect password" )
|
||||
end
|
||||
end,
|
||||
|
||||
|
||||
--- Verifies whether the repository is valid
|
||||
--
|
||||
-- @return status, true on success, false on failure
|
||||
@@ -240,26 +240,26 @@ Driver =
|
||||
|
||||
|
||||
action = function(host, port)
|
||||
local status, accounts
|
||||
|
||||
local status, accounts
|
||||
|
||||
local repo = stdnse.get_script_args('svn-brute.repo')
|
||||
local force = stdnse.get_script_args('svn-brute.force')
|
||||
|
||||
|
||||
if ( not(repo) ) then
|
||||
return "No repository specified (see svn-brute.repo)"
|
||||
end
|
||||
|
||||
|
||||
local svn = svn:new( host, port, repo )
|
||||
local status = svn:connect()
|
||||
|
||||
if ( status and svn.auth_mech["ANONYMOUS"] and not(force) ) then
|
||||
return " \n Anonymous SVN detected, no authentication needed"
|
||||
end
|
||||
|
||||
|
||||
if ( not(svn.auth_mech) or not( svn.auth_mech["CRAM-MD5"] ) ) then
|
||||
return " \n No supported authentication mechanisms detected"
|
||||
end
|
||||
|
||||
|
||||
local invalid_users = {}
|
||||
local engine = brute.Engine:new(Driver, host, port, invalid_users)
|
||||
engine.options.script_name = SCRIPT_NAME
|
||||
|
||||
Reference in New Issue
Block a user