mirror of
https://github.com/nmap/nmap.git
synced 2025-12-07 21:21:31 +00:00
Whitespace fixes: removed trailing whitespaces, always use tabs for indentation.
This commit is contained in:
@@ -10,13 +10,13 @@ The script needs to be run in privileged mode.
|
|||||||
-- @output
|
-- @output
|
||||||
-- PORT STATE SERVICE
|
-- PORT STATE SERVICE
|
||||||
-- 513/tcp open login
|
-- 513/tcp open login
|
||||||
-- | rlogin-brute:
|
-- | rlogin-brute:
|
||||||
-- | Accounts
|
-- | Accounts
|
||||||
-- | nmap:test - Valid credentials
|
-- | nmap:test - Valid credentials
|
||||||
-- | Statistics
|
-- | Statistics
|
||||||
-- |_ Performed 4 guesses in 5 seconds, average tps: 0
|
-- |_ Performed 4 guesses in 5 seconds, average tps: 0
|
||||||
--
|
--
|
||||||
-- @args rlogin-brute.timeout number
|
-- @args rlogin-brute.timeout number
|
||||||
|
|
||||||
-- Version 0.1
|
-- Version 0.1
|
||||||
-- Created 11/02/2011 - v0.1 - created by Patrik Karlsson <patrik@cqure.net>
|
-- Created 11/02/2011 - v0.1 - created by Patrik Karlsson <patrik@cqure.net>
|
||||||
@@ -42,14 +42,14 @@ Driver = {
|
|||||||
setmetatable(o, self)
|
setmetatable(o, self)
|
||||||
self.__index = self
|
self.__index = self
|
||||||
return o
|
return o
|
||||||
end,
|
end,
|
||||||
|
|
||||||
-- connects to the rlogin service
|
-- connects to the rlogin service
|
||||||
-- it sets the source port to a random value between 513 and 1024
|
-- it sets the source port to a random value between 513 and 1024
|
||||||
connect = function(self)
|
connect = function(self)
|
||||||
|
|
||||||
local status
|
local status
|
||||||
|
|
||||||
self.socket = nmap.new_socket()
|
self.socket = nmap.new_socket()
|
||||||
-- apparently wee need a source port below 1024
|
-- apparently wee need a source port below 1024
|
||||||
-- this approach is not very elegant as it causes address already in
|
-- this approach is not very elegant as it causes address already in
|
||||||
@@ -75,7 +75,7 @@ Driver = {
|
|||||||
end
|
end
|
||||||
return status
|
return status
|
||||||
end,
|
end,
|
||||||
|
|
||||||
login = function(self, username, password)
|
login = function(self, username, password)
|
||||||
local data = ("\0%s\0%s\0vt100/9600\0"):format(username, username)
|
local data = ("\0%s\0%s\0vt100/9600\0"):format(username, username)
|
||||||
local status, err = self.socket:send(data)
|
local status, err = self.socket:send(data)
|
||||||
@@ -88,11 +88,11 @@ Driver = {
|
|||||||
end
|
end
|
||||||
if ( data ~= "\0" ) then
|
if ( data ~= "\0" ) then
|
||||||
stdnse.print_debug(2, "ERROR: Expected null byte")
|
stdnse.print_debug(2, "ERROR: Expected null byte")
|
||||||
local err = brute.Error:new( "Expected null byte" )
|
local err = brute.Error:new( "Expected null byte" )
|
||||||
err:setRetry( true )
|
err:setRetry( true )
|
||||||
return false, err
|
return false, err
|
||||||
end
|
end
|
||||||
|
|
||||||
status, data = self.socket:receive()
|
status, data = self.socket:receive()
|
||||||
if (not(status)) then
|
if (not(status)) then
|
||||||
local err = brute.Error:new("Failed to read response from server")
|
local err = brute.Error:new("Failed to read response from server")
|
||||||
@@ -101,11 +101,11 @@ Driver = {
|
|||||||
end
|
end
|
||||||
if ( data ~= "Password: " ) then
|
if ( data ~= "Password: " ) then
|
||||||
stdnse.print_debug(2, "ERROR: Expected password prompt")
|
stdnse.print_debug(2, "ERROR: Expected password prompt")
|
||||||
local err = brute.Error:new( "Expected password prompt" )
|
local err = brute.Error:new( "Expected password prompt" )
|
||||||
err:setRetry( true )
|
err:setRetry( true )
|
||||||
return false, err
|
return false, err
|
||||||
end
|
end
|
||||||
|
|
||||||
status, err = self.socket:send(password .. "\r")
|
status, err = self.socket:send(password .. "\r")
|
||||||
status, data = self.socket:receive()
|
status, data = self.socket:receive()
|
||||||
if (not(status)) then
|
if (not(status)) then
|
||||||
@@ -113,21 +113,21 @@ Driver = {
|
|||||||
err:setRetry( true )
|
err:setRetry( true )
|
||||||
return false, err
|
return false, err
|
||||||
end
|
end
|
||||||
|
|
||||||
status, data = self.socket:receive()
|
status, data = self.socket:receive()
|
||||||
if (not(status)) then
|
if (not(status)) then
|
||||||
local err = brute.Error:new("Failed to read response from server")
|
local err = brute.Error:new("Failed to read response from server")
|
||||||
err:setRetry( true )
|
err:setRetry( true )
|
||||||
return false, err
|
return false, err
|
||||||
end
|
end
|
||||||
|
|
||||||
if ( data:match("[Pp]assword") or data:match("[Ii]ncorrect") ) then
|
if ( data:match("[Pp]assword") or data:match("[Ii]ncorrect") ) then
|
||||||
return false, brute.Error:new( "Incorrect password" )
|
return false, brute.Error:new( "Incorrect password" )
|
||||||
end
|
end
|
||||||
|
|
||||||
return true, brute.Account:new(username, password, creds.State.VALID)
|
return true, brute.Account:new(username, password, creds.State.VALID)
|
||||||
end,
|
end,
|
||||||
|
|
||||||
disconnect = function(self)
|
disconnect = function(self)
|
||||||
return self.socket:close()
|
return self.socket:close()
|
||||||
end,
|
end,
|
||||||
@@ -142,13 +142,13 @@ action = function(host, port)
|
|||||||
local options = {
|
local options = {
|
||||||
timeout = stdnse.get_script_args("rlogin-brute.timeout")
|
timeout = stdnse.get_script_args("rlogin-brute.timeout")
|
||||||
}
|
}
|
||||||
|
|
||||||
options.timeout = options.timeout and
|
options.timeout = options.timeout and
|
||||||
tonumber(options.timeout) * 1000 or
|
tonumber(options.timeout) * 1000 or
|
||||||
10000
|
10000
|
||||||
|
|
||||||
local engine = brute.Engine:new(Driver, host, port, options)
|
local engine = brute.Engine:new(Driver, host, port, options)
|
||||||
engine.options.script_name = SCRIPT_NAME
|
engine.options.script_name = SCRIPT_NAME
|
||||||
status, result = engine:start()
|
status, result = engine:start()
|
||||||
return result
|
return result
|
||||||
end
|
end
|
||||||
|
|||||||
Reference in New Issue
Block a user