mirror of
https://github.com/nmap/nmap.git
synced 2025-12-06 04:31:29 +00:00
Replace host.ip, port.number with host, port
In most cases (e.g. any of the nmap.socket operations), functions can take full host and port tables instead of just host.ip and port.number. This makes for cleaner-looking code and easier extensibility if we decide to check for a protocol on both TCP and UDP, for instance.
This commit is contained in:
@@ -55,8 +55,8 @@ end
|
||||
|
||||
--- Sends the request to the server using the http lib
|
||||
--
|
||||
-- @param host string, the ip of the remote server
|
||||
-- @param port number, the port of the remote server
|
||||
-- @param host string or host table of the remote server
|
||||
-- @param port number or port table of the remote server
|
||||
-- @param xmldata string, the HTTP data part of the request as XML
|
||||
--
|
||||
-- @return string with the response body
|
||||
@@ -78,8 +78,8 @@ end
|
||||
-- This function implements all the supported parameters described in:
|
||||
-- Version 5.0 (draft 1) 24 January 2008
|
||||
--
|
||||
-- @param host string, the ip of the remote server
|
||||
-- @param port number, the port of the remote server
|
||||
-- @param host string or host table of the remote server
|
||||
-- @param port number or port table of the remote server
|
||||
-- @return string HTTP response data
|
||||
--
|
||||
function request_server_farm_data( host, port )
|
||||
@@ -117,8 +117,8 @@ end
|
||||
--
|
||||
-- Supported parameters are Scope, ServerType, ClientType, DesiredDetails
|
||||
--
|
||||
-- @param host string the host which is to be queried
|
||||
-- @param port number the port number of the XML service
|
||||
-- @param host string or host table which is to be queried
|
||||
-- @param port number or port table of the XML service
|
||||
-- @param params table with parameters
|
||||
-- @return string HTTP response data
|
||||
--
|
||||
@@ -302,8 +302,8 @@ end
|
||||
-- This function implements all the supported parameters described in:
|
||||
-- Version 5.0 (draft 1) 24 January 2008
|
||||
--
|
||||
-- @param host string the host which is to be queried
|
||||
-- @param port number the port number of the XML service
|
||||
-- @param host string or host table which is to be queried
|
||||
-- @param port number or port table of the XML service
|
||||
-- @param params table with parameters
|
||||
-- @return string HTTP response data
|
||||
--
|
||||
@@ -355,8 +355,8 @@ end
|
||||
-- This function implements all the supported parameters described in:
|
||||
-- Version 5.0 (draft 1) 24 January 2008
|
||||
--
|
||||
-- @param host string the host which is to be queried
|
||||
-- @param port number the port number of the XML service
|
||||
-- @param host string or host table which is to be queried
|
||||
-- @param port number or port table of the XML service
|
||||
-- @param params table with parameters
|
||||
-- @return string HTTP response data
|
||||
--
|
||||
@@ -387,8 +387,8 @@ end
|
||||
-- This function implements all the supported parameters described in:
|
||||
-- Version 5.0 (draft 1) 24 January 2008
|
||||
--
|
||||
-- @param host string the host which is to be queried
|
||||
-- @param port number the port number of the XML service
|
||||
-- @param host string or host table which is to be queried
|
||||
-- @param port number or port table of the XML service
|
||||
-- @return string HTTP response data
|
||||
--
|
||||
function request_capabilities( host, port )
|
||||
@@ -425,8 +425,8 @@ end
|
||||
-- Version 5.0 (draft 1) 24 January 2008
|
||||
--
|
||||
--
|
||||
-- @param host string the host which is to be queried
|
||||
-- @param port number the port number of the XML service
|
||||
-- @param host string or host table which is to be queried
|
||||
-- @param port number or port table of the XML service
|
||||
-- @param params table with parameters
|
||||
-- @return string HTTP response data
|
||||
--
|
||||
@@ -481,8 +481,8 @@ end
|
||||
-- Consult the NFuse.DTD for a complete list of supported parameters
|
||||
-- This function does NOT implement all the supported parameters
|
||||
----
|
||||
-- @param host string the host which is to be queried
|
||||
-- @param port number the port number of the XML service
|
||||
-- @param host string or host table which is to be queried
|
||||
-- @param port number or port table of the XML service
|
||||
-- @param params table with parameters
|
||||
--
|
||||
function request_reconnect_session_data(host, port, params)
|
||||
|
||||
@@ -42,7 +42,7 @@ categories = {"default", "discovery", "safe", "version"}
|
||||
portrule = shortport.version_port_or_service(5672, "amqp", "tcp", "open")
|
||||
|
||||
action = function(host, port)
|
||||
local cli = amqp.AMQP:new( host.ip, port.number )
|
||||
local cli = amqp.AMQP:new( host, port )
|
||||
|
||||
local status, data = cli:connect()
|
||||
if not status then return "Unable to open connection: " .. data end
|
||||
|
||||
@@ -106,7 +106,7 @@ local backorifice =
|
||||
|
||||
encrypted_ping = self:BOcrypt(PING_PACKET,seed)
|
||||
|
||||
status, response = self.socket:sendto(self.host.ip, self.port.number, encrypted_ping)
|
||||
status, response = self.socket:sendto(self.host, self.port, encrypted_ping)
|
||||
if not(status) then
|
||||
return false, response
|
||||
end
|
||||
|
||||
@@ -271,7 +271,7 @@ action = function( host, port )
|
||||
--send command
|
||||
local data = BOpack( cmds[i].p_code, cmds[i].arg1, cmds[i].arg2 )
|
||||
data = BOcrypt(data, password, initial_seed)
|
||||
try(socket:sendto(host.ip, port.number, data))
|
||||
try(socket:sendto(host, port, data))
|
||||
|
||||
--receive info
|
||||
local output, response, p_type, multi_flag
|
||||
|
||||
@@ -42,8 +42,8 @@ portrule = shortport.portnumber({8080,80,443}, "tcp")
|
||||
|
||||
--- Verifies if the credentials (username, password and domain) are valid
|
||||
--
|
||||
-- @param host string, the ip against which to perform
|
||||
-- @param port number, the port number of the XML service
|
||||
-- @param host string or host table against which to perform
|
||||
-- @param port number or port table of the XML service
|
||||
-- @param username string, the username to authenticate as
|
||||
-- @param password string, the password to authenticate with
|
||||
-- @param domain string, the Windows domain to authenticate against
|
||||
@@ -139,7 +139,7 @@ action = function(host, port)
|
||||
-- iterate over passwordlist
|
||||
while password do
|
||||
local result = "Trying " .. username .. "/" .. password .. " "
|
||||
local account = verify_password(host.ip, port.number, username, password, ntdomain)
|
||||
local account = verify_password(host, port, username, password, ntdomain)
|
||||
|
||||
if account.valid then
|
||||
|
||||
|
||||
@@ -144,7 +144,7 @@ end
|
||||
|
||||
action = function(host,port)
|
||||
|
||||
local response = citrixxml.request_appdata(host.ip, port.number, {ServerAddress="",attr={addresstype="dot"},DesiredDetails={"all","access-list"} })
|
||||
local response = citrixxml.request_appdata(host, port, {ServerAddress="",attr={addresstype="dot"},DesiredDetails={"all","access-list"} })
|
||||
local appdata = citrixxml.parse_appdata_response(response)
|
||||
|
||||
local response = format_output(appdata, (nmap.verbosity() > 1 and "long" or "short"))
|
||||
|
||||
@@ -34,7 +34,7 @@ portrule = shortport.portnumber({8080,80,443}, "tcp")
|
||||
|
||||
action = function(host, port)
|
||||
|
||||
local xmldata = citrixxml.request_server_data(host.ip, port.number)
|
||||
local xmldata = citrixxml.request_server_data(host, port)
|
||||
local servers = citrixxml.parse_server_data_response(xmldata)
|
||||
local response = {}
|
||||
|
||||
|
||||
@@ -60,7 +60,7 @@ SocketPool = {
|
||||
end
|
||||
if ( #self.pool < self.max_sockets ) then
|
||||
local socket = nmap.new_socket()
|
||||
local status = socket:connect( host.ip, port.number, "tcp")
|
||||
local status = socket:connect( host, port )
|
||||
|
||||
if ( status ) then
|
||||
socket:reconnect_ssl()
|
||||
|
||||
@@ -111,7 +111,7 @@ action = function(host, port)
|
||||
cmds = stdnse.strsplit(";%s*", cmd)
|
||||
|
||||
socket:set_timeout(10000)
|
||||
local status = socket:connect( host.ip, port.number, "tcp")
|
||||
local status = socket:connect( host, port )
|
||||
if ( status ) then
|
||||
socket:reconnect_ssl()
|
||||
end
|
||||
|
||||
@@ -56,7 +56,7 @@ action = function( host, port )
|
||||
end
|
||||
|
||||
local socket = nmap.new_socket()
|
||||
local status, err = socket:connect(host.ip, port.number)
|
||||
local status, err = socket:connect(host, port)
|
||||
if not status then
|
||||
return
|
||||
end
|
||||
|
||||
@@ -32,7 +32,7 @@ portrule = shortport.port_or_service (12345, "netbus", {"tcp"})
|
||||
action = function( host, port )
|
||||
|
||||
local socket = nmap.new_socket()
|
||||
local status, err = socket:connect(host.ip, port.number)
|
||||
local status, err = socket:connect(host, port)
|
||||
if not status then
|
||||
return
|
||||
end
|
||||
|
||||
@@ -29,7 +29,7 @@ action = function( host, port )
|
||||
local try = nmap.new_try()
|
||||
local passwords = try(unpwdb.passwords())
|
||||
local socket = nmap.new_socket()
|
||||
local status, err = socket:connect(host.ip, port.number)
|
||||
local status, err = socket:connect(host, port)
|
||||
if not status then
|
||||
return
|
||||
end
|
||||
|
||||
@@ -161,7 +161,7 @@ action = function( host, port )
|
||||
end
|
||||
local socket = nmap.new_socket()
|
||||
socket:set_timeout(5000)
|
||||
local status, err = socket:connect(host.ip, port.number)
|
||||
local status, err = socket:connect(host, port)
|
||||
local buffer, err = stdnse.make_buffer(socket, "\r")
|
||||
local _ = buffer()
|
||||
if not (_ and _:match("^NetBus")) then
|
||||
|
||||
@@ -25,7 +25,7 @@ action = function( host, port )
|
||||
|
||||
local socket = nmap.new_socket()
|
||||
socket:set_timeout(5000)
|
||||
local status, err = socket:connect(host.ip, port.number)
|
||||
local status, err = socket:connect(host, port)
|
||||
if not status then
|
||||
return
|
||||
end
|
||||
|
||||
@@ -73,7 +73,7 @@ local KNOWN_PROTOCOLS = {
|
||||
local function getservers(host, port, q3protocol)
|
||||
local socket = nmap.new_socket()
|
||||
socket:set_timeout(10000)
|
||||
local status, err = socket:connect(host.ip, port.number, "udp")
|
||||
local status, err = socket:connect(host, port)
|
||||
if not status then
|
||||
return {}
|
||||
end
|
||||
|
||||
@@ -201,7 +201,7 @@ end
|
||||
|
||||
function action(host,port, args)
|
||||
|
||||
local registry= rmi.Registry:new( host.ip, port.number)
|
||||
local registry= rmi.Registry:new( host, port )
|
||||
|
||||
|
||||
local status, j_array = registry:list()
|
||||
|
||||
@@ -50,7 +50,7 @@ portrule = shortport.port_or_service({
|
||||
});
|
||||
|
||||
action = function (host, port)
|
||||
local registry = rmi.Registry:new(host.ip, port.number);
|
||||
local registry = rmi.Registry:new(host, port);
|
||||
registry:_handshake();
|
||||
local rmiArgs = rmi.Arguments:new();
|
||||
local argsRaw = "75" .. --TC_ARRAY
|
||||
|
||||
@@ -141,7 +141,7 @@ action = function(host, port)
|
||||
local try = nmap.new_try(catch)
|
||||
|
||||
-- connect to the potential service tags discoverer
|
||||
try(socket:connect(host.ip, port.number, "udp"))
|
||||
try(socket:connect(host, port))
|
||||
|
||||
local payload
|
||||
|
||||
|
||||
@@ -85,7 +85,7 @@ action = function(host, port)
|
||||
try = nmap.new_try(catch)
|
||||
|
||||
-- connect to the potential SNMP system
|
||||
try(socket:connect(host.ip, port.number, "udp"))
|
||||
try(socket:connect(host, port))
|
||||
|
||||
local status, tftpserver, _, _, _ = socket:get_info()
|
||||
if( not(status) ) then
|
||||
|
||||
@@ -70,7 +70,7 @@ svn =
|
||||
self.socket = nmap.new_socket()
|
||||
|
||||
local result
|
||||
status, result = self.socket:connect(self.host.ip, self.port.number, "tcp")
|
||||
status, result = self.socket:connect(self.host, self.port)
|
||||
if( not(status) ) then
|
||||
return false, result
|
||||
end
|
||||
|
||||
@@ -104,7 +104,7 @@ local check_file_present = function(host, port, filename)
|
||||
|
||||
|
||||
local socket = nmap.new_socket()
|
||||
socket:connect(host.ip, port.number, "udp")
|
||||
socket:connect(host, port)
|
||||
local status, lhost, lport, rhost, rport = socket:get_info()
|
||||
|
||||
|
||||
|
||||
@@ -52,7 +52,7 @@ Driver =
|
||||
|
||||
connect = function( self )
|
||||
local status, data
|
||||
self.vnc = vnc.VNC:new( self.host.ip, self.port.number )
|
||||
self.vnc = vnc.VNC:new( self.host, self.port )
|
||||
status, data = self.vnc:connect()
|
||||
if ( not(status) ) then
|
||||
local err = brute.Error:new( "VNC connect failed" )
|
||||
@@ -104,7 +104,7 @@ Driver =
|
||||
end,
|
||||
|
||||
check = function( self )
|
||||
local vnc = vnc.VNC:new( self.host.ip, self.port.number )
|
||||
local vnc = vnc.VNC:new( self.host, self.port )
|
||||
local status, data
|
||||
|
||||
status, data = vnc:connect()
|
||||
|
||||
@@ -44,7 +44,7 @@ portrule = shortport.port_or_service( {5900, 5901, 5902} , "vnc", "tcp", "open")
|
||||
|
||||
action = function(host, port)
|
||||
|
||||
local vnc = vnc.VNC:new( host.ip, port.number )
|
||||
local vnc = vnc.VNC:new( host, port )
|
||||
local status, data
|
||||
local result = stdnse.output_table()
|
||||
|
||||
|
||||
Reference in New Issue
Block a user