From 6139ed22e7e17fe7d28aac844ecb107831d3f06a Mon Sep 17 00:00:00 2001 From: dmiller Date: Wed, 18 Feb 2015 14:38:42 +0000 Subject: [PATCH] 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. --- nselib/citrixxml.lua | 32 ++++++++++++++-------------- scripts/amqp-info.nse | 2 +- scripts/backorifice-brute.nse | 2 +- scripts/backorifice-info.nse | 2 +- scripts/citrix-brute-xml.nse | 6 +++--- scripts/citrix-enum-apps-xml.nse | 2 +- scripts/citrix-enum-servers-xml.nse | 2 +- scripts/domcon-brute.nse | 2 +- scripts/domcon-cmd.nse | 2 +- scripts/gopher-ls.nse | 2 +- scripts/netbus-auth-bypass.nse | 2 +- scripts/netbus-brute.nse | 2 +- scripts/netbus-info.nse | 2 +- scripts/netbus-version.nse | 2 +- scripts/quake3-master-getservers.nse | 2 +- scripts/rmi-dumpregistry.nse | 2 +- scripts/rmi-vuln-classloader.nse | 2 +- scripts/servicetags.nse | 2 +- scripts/snmp-ios-config.nse | 2 +- scripts/svn-brute.nse | 2 +- scripts/tftp-enum.nse | 2 +- scripts/vnc-brute.nse | 4 ++-- scripts/vnc-info.nse | 2 +- 23 files changed, 41 insertions(+), 41 deletions(-) diff --git a/nselib/citrixxml.lua b/nselib/citrixxml.lua index 87d31bf62..f75cec44e 100644 --- a/nselib/citrixxml.lua +++ b/nselib/citrixxml.lua @@ -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) diff --git a/scripts/amqp-info.nse b/scripts/amqp-info.nse index 15642be39..05a5f998b 100644 --- a/scripts/amqp-info.nse +++ b/scripts/amqp-info.nse @@ -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 diff --git a/scripts/backorifice-brute.nse b/scripts/backorifice-brute.nse index c0c3d36cc..ba5614bf8 100644 --- a/scripts/backorifice-brute.nse +++ b/scripts/backorifice-brute.nse @@ -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 diff --git a/scripts/backorifice-info.nse b/scripts/backorifice-info.nse index 862bb8486..5200f33a4 100644 --- a/scripts/backorifice-info.nse +++ b/scripts/backorifice-info.nse @@ -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 diff --git a/scripts/citrix-brute-xml.nse b/scripts/citrix-brute-xml.nse index 11218cf97..c187f875f 100644 --- a/scripts/citrix-brute-xml.nse +++ b/scripts/citrix-brute-xml.nse @@ -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 diff --git a/scripts/citrix-enum-apps-xml.nse b/scripts/citrix-enum-apps-xml.nse index ecf10b8e5..1d5e5e534 100644 --- a/scripts/citrix-enum-apps-xml.nse +++ b/scripts/citrix-enum-apps-xml.nse @@ -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")) diff --git a/scripts/citrix-enum-servers-xml.nse b/scripts/citrix-enum-servers-xml.nse index 98bb16a88..20e67699f 100644 --- a/scripts/citrix-enum-servers-xml.nse +++ b/scripts/citrix-enum-servers-xml.nse @@ -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 = {} diff --git a/scripts/domcon-brute.nse b/scripts/domcon-brute.nse index 6793743eb..0ba83a1d1 100644 --- a/scripts/domcon-brute.nse +++ b/scripts/domcon-brute.nse @@ -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() diff --git a/scripts/domcon-cmd.nse b/scripts/domcon-cmd.nse index 90410690c..e9066f473 100644 --- a/scripts/domcon-cmd.nse +++ b/scripts/domcon-cmd.nse @@ -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 diff --git a/scripts/gopher-ls.nse b/scripts/gopher-ls.nse index 582a508a2..a24d8c58e 100644 --- a/scripts/gopher-ls.nse +++ b/scripts/gopher-ls.nse @@ -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 diff --git a/scripts/netbus-auth-bypass.nse b/scripts/netbus-auth-bypass.nse index 94412a912..fbf97d5bd 100644 --- a/scripts/netbus-auth-bypass.nse +++ b/scripts/netbus-auth-bypass.nse @@ -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 diff --git a/scripts/netbus-brute.nse b/scripts/netbus-brute.nse index 20ca594fd..5e050656f 100644 --- a/scripts/netbus-brute.nse +++ b/scripts/netbus-brute.nse @@ -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 diff --git a/scripts/netbus-info.nse b/scripts/netbus-info.nse index 5e0376de9..46a71f635 100644 --- a/scripts/netbus-info.nse +++ b/scripts/netbus-info.nse @@ -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 diff --git a/scripts/netbus-version.nse b/scripts/netbus-version.nse index ce72de0fb..b4bed1627 100644 --- a/scripts/netbus-version.nse +++ b/scripts/netbus-version.nse @@ -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 diff --git a/scripts/quake3-master-getservers.nse b/scripts/quake3-master-getservers.nse index 41bf4a537..507a96a3b 100644 --- a/scripts/quake3-master-getservers.nse +++ b/scripts/quake3-master-getservers.nse @@ -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 diff --git a/scripts/rmi-dumpregistry.nse b/scripts/rmi-dumpregistry.nse index 27dd8f0a5..beb0117bc 100644 --- a/scripts/rmi-dumpregistry.nse +++ b/scripts/rmi-dumpregistry.nse @@ -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() diff --git a/scripts/rmi-vuln-classloader.nse b/scripts/rmi-vuln-classloader.nse index 1c1d942db..751dbe474 100644 --- a/scripts/rmi-vuln-classloader.nse +++ b/scripts/rmi-vuln-classloader.nse @@ -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 diff --git a/scripts/servicetags.nse b/scripts/servicetags.nse index 701c8bb7a..a454ddc0a 100644 --- a/scripts/servicetags.nse +++ b/scripts/servicetags.nse @@ -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 diff --git a/scripts/snmp-ios-config.nse b/scripts/snmp-ios-config.nse index bb242bdd0..f7c26f2f5 100644 --- a/scripts/snmp-ios-config.nse +++ b/scripts/snmp-ios-config.nse @@ -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 diff --git a/scripts/svn-brute.nse b/scripts/svn-brute.nse index 1436ee58c..514b72437 100644 --- a/scripts/svn-brute.nse +++ b/scripts/svn-brute.nse @@ -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 diff --git a/scripts/tftp-enum.nse b/scripts/tftp-enum.nse index 9c303c65e..f2dbf64f4 100644 --- a/scripts/tftp-enum.nse +++ b/scripts/tftp-enum.nse @@ -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() diff --git a/scripts/vnc-brute.nse b/scripts/vnc-brute.nse index cc9a20e11..8be5489c0 100644 --- a/scripts/vnc-brute.nse +++ b/scripts/vnc-brute.nse @@ -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() diff --git a/scripts/vnc-info.nse b/scripts/vnc-info.nse index b6c2fd982..b273cf0a1 100644 --- a/scripts/vnc-info.nse +++ b/scripts/vnc-info.nse @@ -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()