From 3c89e089fcc4fcba3a211d7983e07c47a140c519 Mon Sep 17 00:00:00 2001 From: david Date: Mon, 16 Aug 2010 18:59:30 +0000 Subject: [PATCH] Change calls in these forms: socket:connect(host.ip, port.number) socket:connect(host.ip, port.number, port.protocol) to this: socket:connect(host, port) connect can take host and port tables now, and the default protocol is taken from the port table if possible. --- nselib/afp.lua | 2 +- nselib/brute.lua | 2 +- nselib/drda.lua | 6 +++--- nselib/imap.lua | 2 +- nselib/mssql.lua | 2 +- nselib/nmap.luadoc | 2 +- nselib/pgsql.lua | 2 +- nselib/proxy.lua | 2 +- nselib/rpc.lua | 2 +- nselib/smb.lua | 4 ++-- nselib/ssh1.lua | 2 +- nselib/ssh2.lua | 2 +- scripts/afp-serverinfo.nse | 2 +- scripts/auth-owners.nse | 4 ++-- scripts/citrix-enum-apps.nse | 2 +- scripts/citrix-enum-servers.nse | 2 +- scripts/db2-das-info.nse | 2 +- scripts/dhcp-discover.nse | 2 +- scripts/ftp-anon.nse | 2 +- scripts/ftp-bounce.nse | 2 +- scripts/ftp-brute.nse | 2 +- scripts/ftp-libopie.nse | 2 +- scripts/ldap-brute.nse | 2 +- scripts/ldap-rootdse.nse | 4 ++-- scripts/ldap-search.nse | 2 +- scripts/mongodb-databases.nse | 2 +- scripts/mongodb-info.nse | 2 +- scripts/ms-sql-info.nse | 2 +- scripts/mysql-brute.nse | 2 +- scripts/mysql-databases.nse | 2 +- scripts/mysql-empty-password.nse | 2 +- scripts/mysql-users.nse | 2 +- scripts/mysql-variables.nse | 2 +- scripts/ntp-monlist.nse | 2 +- scripts/oracle-sid-brute.nse | 2 +- scripts/pgsql-brute.nse | 2 +- scripts/pjl-ready-message.nse | 2 +- scripts/pop3-brute.nse | 2 +- scripts/realvnc-auth-bypass.nse | 2 +- scripts/smb-check-vulns.nse | 4 ++-- scripts/snmp-brute.nse | 2 +- scripts/snmp-interfaces.nse | 4 ++-- scripts/snmp-netstat.nse | 2 +- scripts/snmp-processes.nse | 2 +- scripts/snmp-sysdescr.nse | 2 +- scripts/snmp-win32-services.nse | 2 +- scripts/snmp-win32-shares.nse | 2 +- scripts/snmp-win32-software.nse | 2 +- scripts/snmp-win32-users.nse | 2 +- scripts/sshv1.nse | 2 +- scripts/ssl-cert.nse | 4 ++-- scripts/sslv2.nse | 2 +- scripts/telnet-brute.nse | 2 +- scripts/upnp-info.nse | 2 +- scripts/x11-access.nse | 2 +- 55 files changed, 63 insertions(+), 63 deletions(-) diff --git a/nselib/afp.lua b/nselib/afp.lua index d662f522b..c5b4c25c0 100644 --- a/nselib/afp.lua +++ b/nselib/afp.lua @@ -1348,7 +1348,7 @@ Helper = { self.socket = nmap.new_socket() self.socket:set_timeout( 5000 ) - status = self.socket:connect(host.ip, port.number, port.protocol) + status = self.socket:connect(host, port) if not status then return false, "Socket connection failed" end diff --git a/nselib/brute.lua b/nselib/brute.lua index e2b56435f..f10640e2e 100644 --- a/nselib/brute.lua +++ b/nselib/brute.lua @@ -67,7 +67,7 @@ -- end, -- connect = function( self ) -- self.socket = nmap.new_socket() --- return self.socket:connect( self.host.ip, self.port.number, "tcp" ) +-- return self.socket:connect( self.host, self.port ) -- end, -- disconnect = function( self ) -- return self.socket:close() diff --git a/nselib/drda.lua b/nselib/drda.lua index f8b1eae9c..d1a940d76 100644 --- a/nselib/drda.lua +++ b/nselib/drda.lua @@ -539,7 +539,7 @@ Helper = { connect = function( self, host, port ) self.db2socket = DB2Socket:new() self.comm = Comm:new( self.db2socket ) - return self.db2socket:connect(host.ip, port.number, port.protocol) + return self.db2socket:connect(host, port) end, --- Closes an open connection. @@ -736,8 +736,8 @@ DB2Socket = { --- Establishes a connection. -- - -- @param hostid Hostname or IP address. - -- @param port Port number. + -- @param hostid Host table, hostname, or IP address. + -- @param port Port table or number. -- @param protocol "tcp", "udp", or -- @return Status (true or false). -- @return Error code (if status is false). diff --git a/nselib/imap.lua b/nselib/imap.lua index eac92d7a1..b0f992ae9 100644 --- a/nselib/imap.lua +++ b/nselib/imap.lua @@ -21,7 +21,7 @@ function capabilities(host, port) local capas = {} socket:set_timeout(10000) local proto = (port.version and port.version.service_tunnel == "ssl" and "ssl") or "tcp" - if not socket:connect(host.ip, port.number, proto) then return nil, "Could Not Connect" end + if not socket:connect(host, port, proto) then return nil, "Could Not Connect" end local status, line = socket:receive_lines(1) if not string.match(line, "^[%*] OK") then return nil, "No Response" end diff --git a/nselib/mssql.lua b/nselib/mssql.lua index 1d47d83d3..a5e9cb76c 100644 --- a/nselib/mssql.lua +++ b/nselib/mssql.lua @@ -654,7 +654,7 @@ TDSStream = { -- the end of the input buffer. So the only time the timeout is -- triggered is when waiting for a response to a query. self.socket:set_timeout( MSSQL_TIMEOUT * 1000 ) - status, result = self.socket:connect(host.ip, port.number, port.protocol) + status, result = self.socket:connect(host, port) status, _, lport, _, _ = self.socket:get_info() if ( status ) then math.randomseed(os.time() * lport ) diff --git a/nselib/nmap.luadoc b/nselib/nmap.luadoc index f02605de1..5d7dfb837 100644 --- a/nselib/nmap.luadoc +++ b/nselib/nmap.luadoc @@ -632,7 +632,7 @@ function pcap_close() -- @return A table as described above. -- @usage -- local s = nmap.new_socket() --- local status, error = s:connect(host.ip, port.number, "ssl") +-- local status, error = s:connect(host, port, "ssl") -- if status then -- local cert = s:get_ssl_certificate() -- local digest = cert:digest("md5") diff --git a/nselib/pgsql.lua b/nselib/pgsql.lua index bc76876ab..436003e74 100644 --- a/nselib/pgsql.lua +++ b/nselib/pgsql.lua @@ -611,7 +611,7 @@ function detectVersion(host, port) local status, response local socket = nmap.new_socket() - socket:connect(host.ip, port.number, "tcp") + socket:connect(host, port) status, response = v3.sendStartup(socket, "versionprobe", "versionprobe") socket:close() diff --git a/nselib/proxy.lua b/nselib/proxy.lua index e9dd01606..a773b0f8a 100644 --- a/nselib/proxy.lua +++ b/nselib/proxy.lua @@ -174,7 +174,7 @@ function connectProxy(host, port, proxyType, hostname) local socket = nmap.new_socket() socket:set_timeout(10000) local try = nmap.new_try(function() socket:close() return false end) - try(socket:connect(host.ip, port.number)) + try(socket:connect(host, port)) if proxyType == "http" then return socket end if proxyType == "socks4" then return socksHandshake(socket, 4, hostname) end if proxyType == "socks5" then return socksHandshake(socket, 5, hostname) end diff --git a/nselib/rpc.lua b/nselib/rpc.lua index ea35dce18..e17b0f4c7 100644 --- a/nselib/rpc.lua +++ b/nselib/rpc.lua @@ -157,7 +157,7 @@ Comm = { return status, err end socket = nmap.new_socket() - status, err = socket:connect(host.ip, port.number, port.protocol) + status, err = socket:connect(host, port) if (not(status)) then return status, string.format("%s connect error: %s", self.program, err) else diff --git a/nselib/smb.lua b/nselib/smb.lua index 2ffc7e3bd..c08eb4b86 100644 --- a/nselib/smb.lua +++ b/nselib/smb.lua @@ -492,7 +492,7 @@ function start_raw(host, port) local socket = nmap.new_socket() socket:set_timeout(TIMEOUT) - status, err = socket:connect(host.ip, port, "tcp") + status, err = socket:connect(host, port, "tcp") if(status == false) then return false, "SMB: Failed to connect to host: " .. err @@ -599,7 +599,7 @@ function start_netbios(host, port, name) stdnse.print_debug(3, "SMB: Connecting to %s", host.ip) socket:set_timeout(TIMEOUT) - status, err = socket:connect(host.ip, port, "tcp") + status, err = socket:connect(host, port, "tcp") if(status == false) then socket:close() return false, "SMB: Failed to connect: " .. err diff --git a/nselib/ssh1.lua b/nselib/ssh1.lua index 57a04d2c5..784bd4497 100644 --- a/nselib/ssh1.lua +++ b/nselib/ssh1.lua @@ -58,7 +58,7 @@ fetch_host_key = function(host, port) local socket = nmap.new_socket() local status, _ - status = socket:connect(host.ip, port.number) + status = socket:connect(host, port) if not status then return end -- fetch banner status = socket:receive_lines(1) diff --git a/nselib/ssh2.lua b/nselib/ssh2.lua index 358f014e8..802820a1c 100644 --- a/nselib/ssh2.lua +++ b/nselib/ssh2.lua @@ -154,7 +154,7 @@ fetch_host_key = function( host, port, key_type ) -- oakley group 2 prime taken from rfc 2409 local prime = "FFFFFFFFFFFFFFFFC90FDAA22168C234C4C6628B80DC1CD129024E088A67CC74020BBEA63B139B22514A08798E3404DDEF9519B3CD3A431B302B0A6DF25F14374FE1356D6D51C245E485B576625E7EC6F44C42E9A637ED6B0BFF5CB6F406B7EDEE386BFB5A899FA5AE9F24117C4B1FE649286651ECE65381FFFFFFFFFFFFFFFF" - status = socket:connect(host.ip, port.number) + status = socket:connect(host, port) if not status then return end -- fetch banner status = socket:receive_lines(1) diff --git a/scripts/afp-serverinfo.nse b/scripts/afp-serverinfo.nse index 429b04534..fcaeba5a9 100644 --- a/scripts/afp-serverinfo.nse +++ b/scripts/afp-serverinfo.nse @@ -65,7 +65,7 @@ action = function(host, port) local try = nmap.new_try(catch) - try( socket:connect(host.ip, port.number, "tcp") ) + try( socket:connect(host, port) ) -- get our data afp_proto = afp.Proto:new( { socket=socket } ) diff --git a/scripts/auth-owners.nse b/scripts/auth-owners.nse index f2f36a420..896d99001 100644 --- a/scripts/auth-owners.nse +++ b/scripts/auth-owners.nse @@ -51,8 +51,8 @@ action = function(host, port) local try = nmap.new_try(catch) - try(client_ident:connect(host.ip, 113)) - try(client_service:connect(host.ip, port.number)) + try(client_ident:connect(host, 113)) + try(client_service:connect(host, port)) local localip, localport, remoteip, remoteport = try(client_service:get_info()) diff --git a/scripts/citrix-enum-apps.nse b/scripts/citrix-enum-apps.nse index 1813d0646..c9e79a8b9 100644 --- a/scripts/citrix-enum-apps.nse +++ b/scripts/citrix-enum-apps.nse @@ -118,7 +118,7 @@ action = function(host, port) try = nmap.new_try(function() socket:close() end) - try( socket:connect(host.ip, port.number, port.protocol) ) + try( socket:connect(host, port) ) -- send the two first packets and never look back repeat diff --git a/scripts/citrix-enum-servers.nse b/scripts/citrix-enum-servers.nse index 2a1d88fed..577035fd7 100644 --- a/scripts/citrix-enum-servers.nse +++ b/scripts/citrix-enum-servers.nse @@ -104,7 +104,7 @@ action = function(host, port) socket:set_timeout(5000) try = nmap.new_try(function() socket:close() end) - try(socket:connect(host.ip, port.number, port.protocol)) + try(socket:connect(host, port)) -- send the two first packets and never look back repeat diff --git a/scripts/db2-das-info.nse b/scripts/db2-das-info.nse index 8108679bd..15af2b7ea 100644 --- a/scripts/db2-das-info.nse +++ b/scripts/db2-das-info.nse @@ -294,7 +294,7 @@ action = function(host, port) local try = nmap.new_try(catch) - try(socket:connect(host.ip, port.number, "tcp")) + try(socket:connect(host, port)) local query diff --git a/scripts/dhcp-discover.nse b/scripts/dhcp-discover.nse index cd6b3b613..faa567b03 100644 --- a/scripts/dhcp-discover.nse +++ b/scripts/dhcp-discover.nse @@ -624,7 +624,7 @@ local function go(host, port) -- Create the UDP socket socket = nmap.new_socket() - status, err = socket:connect(host.ip, port.number, "udp") + status, err = socket:connect(host, port) if(status == false) then return false, "Couldn't create socket: " .. err end diff --git a/scripts/ftp-anon.nse b/scripts/ftp-anon.nse index f2f81bb8c..ea371518e 100644 --- a/scripts/ftp-anon.nse +++ b/scripts/ftp-anon.nse @@ -71,7 +71,7 @@ action = function(host, port) local try = nmap.new_try(err_catch) - try(socket:connect(host.ip, port.number, port.protocol)) + try(socket:connect(host, port)) buffer = stdnse.make_buffer(socket, "\r?\n") -- Read banner. diff --git a/scripts/ftp-bounce.nse b/scripts/ftp-bounce.nse index 4f4e8a232..18ae38bf7 100644 --- a/scripts/ftp-bounce.nse +++ b/scripts/ftp-bounce.nse @@ -109,7 +109,7 @@ action = function(host, port) local fc socket:set_timeout(10000) - socket:connect(host.ip, port.number) + socket:connect(host, port) -- BANNER fc = get_ftp_code(socket) diff --git a/scripts/ftp-brute.nse b/scripts/ftp-brute.nse index b76fa7848..da84a667e 100644 --- a/scripts/ftp-brute.nse +++ b/scripts/ftp-brute.nse @@ -62,7 +62,7 @@ local function login(host, port, user, pass) -- Create a new socket local socket = nmap.new_socket() - status, err = socket:connect(host.ip, port.number) + status, err = socket:connect(host, port) if(not(status)) then socket:close() return false, "Couldn't connect to host: " .. err diff --git a/scripts/ftp-libopie.nse b/scripts/ftp-libopie.nse index b36b6ed4c..957eaa4d8 100644 --- a/scripts/ftp-libopie.nse +++ b/scripts/ftp-libopie.nse @@ -36,7 +36,7 @@ action = function(host, port) local try = nmap.new_try(err_catch) socket:set_timeout(10000) - try(socket:connect(host.ip, port.number, port.protocol)) + try(socket:connect(host, port)) -- First, try a safe User so that we are sure that everything is ok local payload = "USER opie\r\n" diff --git a/scripts/ldap-brute.nse b/scripts/ldap-brute.nse index fce508026..ab840bad1 100644 --- a/scripts/ldap-brute.nse +++ b/scripts/ldap-brute.nse @@ -113,7 +113,7 @@ action = function( host, port ) socket:close() -- set a reasonable timeout value socket:set_timeout(5000) - status = socket:connect(host.ip, port.number, opt) + status = socket:connect(host, port, opt) if not status then return end diff --git a/scripts/ldap-rootdse.nse b/scripts/ldap-rootdse.nse index c03a4694d..e07ee2128 100644 --- a/scripts/ldap-rootdse.nse +++ b/scripts/ldap-rootdse.nse @@ -110,7 +110,7 @@ function action(host,port) -- We close and re-open the socket so that the anonymous bind does not distract us socket:close() - status = socket:connect(host.ip, port.number, opt) + status = socket:connect(host, port, opt) socket:set_timeout(10000) -- Searching for an empty argument list against LDAP on W2K3 returns all attributes @@ -149,4 +149,4 @@ function action(host,port) return stdnse.format_output(true, result ) -end \ No newline at end of file +end diff --git a/scripts/ldap-search.nse b/scripts/ldap-search.nse index f47ab012d..c63a4b62b 100644 --- a/scripts/ldap-search.nse +++ b/scripts/ldap-search.nse @@ -98,7 +98,7 @@ function action(host,port) -- We close and re-open the socket so that the anonymous bind does not distract us socket:close() - status = socket:connect(host.ip, port.number, opt) + status = socket:connect(host, port, opt) socket:set_timeout(10000) local req diff --git a/scripts/mongodb-databases.nse b/scripts/mongodb-databases.nse index d6ce63499..bf27cc386 100644 --- a/scripts/mongodb-databases.nse +++ b/scripts/mongodb-databases.nse @@ -54,7 +54,7 @@ function action(host,port) local try = nmap.new_try(catch) - try( socket:connect(host.ip, port.number, "tcp") ) + try( socket:connect(host, port) ) local req, result, packet, err, status --Build packet diff --git a/scripts/mongodb-info.nse b/scripts/mongodb-info.nse index 9c71801c5..851a56323 100644 --- a/scripts/mongodb-info.nse +++ b/scripts/mongodb-info.nse @@ -66,7 +66,7 @@ function action(host,port) local try = nmap.new_try(catch) - try( socket:connect(host.ip, port.number, "tcp") ) + try( socket:connect(host, port) ) local req, status, statusresponse, buildinfo, packet, err diff --git a/scripts/ms-sql-info.nse b/scripts/ms-sql-info.nse index efd8e10b4..21fec2737 100644 --- a/scripts/ms-sql-info.nse +++ b/scripts/ms-sql-info.nse @@ -137,7 +137,7 @@ action = function(host, port) end -- get_real_version(dst, dstPort) -- connect to the potential SQL server - try(socket:connect(host.ip, port.number, "udp")) + try(socket:connect(host, port)) -- send a magic packet -- details here: http://www.codeproject.com/cs/database/locate_sql_servers.asp diff --git a/scripts/mysql-brute.nse b/scripts/mysql-brute.nse index 28cd90e20..f93d1450f 100644 --- a/scripts/mysql-brute.nse +++ b/scripts/mysql-brute.nse @@ -54,7 +54,7 @@ action = function( host, port ) for username in usernames do for password in passwords do - try( socket:connect(host.ip, port.number, "tcp") ) + try( socket:connect(host, port) ) response = try( mysql.receiveGreeting( socket ) ) stdnse.print_debug( "Trying %s/%s ...", username, password ) diff --git a/scripts/mysql-databases.nse b/scripts/mysql-databases.nse index 287143695..0920a85be 100644 --- a/scripts/mysql-databases.nse +++ b/scripts/mysql-databases.nse @@ -82,7 +82,7 @@ action = function( host, port ) -- for username, password in pairs(users) do - try( socket:connect(host.ip, port.number, "tcp") ) + try( socket:connect(host, port) ) response = try( mysql.receiveGreeting( socket ) ) status, response = mysql.loginRequest( socket, { authversion = "post41", charset = response.charset }, username, password, response.salt ) diff --git a/scripts/mysql-empty-password.nse b/scripts/mysql-empty-password.nse index 288c93cd7..4d33aaece 100644 --- a/scripts/mysql-empty-password.nse +++ b/scripts/mysql-empty-password.nse @@ -37,7 +37,7 @@ action = function( host, port ) socket:set_timeout(5000) for _, v in ipairs( users ) do - try( socket:connect(host.ip, port.number, "tcp") ) + try( socket:connect(host, port) ) response = try( mysql.receiveGreeting( socket ) ) status, response = mysql.loginRequest( socket, { authversion = "post41", charset = response.charset }, v, nil, response.salt ) if response.errorcode == 0 then diff --git a/scripts/mysql-users.nse b/scripts/mysql-users.nse index 03de44ca0..180e73461 100644 --- a/scripts/mysql-users.nse +++ b/scripts/mysql-users.nse @@ -84,7 +84,7 @@ action = function( host, port ) -- for username, password in pairs(users) do - try( socket:connect(host.ip, port.number, "tcp") ) + try( socket:connect(host, port) ) response = try( mysql.receiveGreeting( socket ) ) status, response = mysql.loginRequest( socket, { authversion = "post41", charset = response.charset }, username, password, response.salt ) diff --git a/scripts/mysql-variables.nse b/scripts/mysql-variables.nse index fafb91400..48652b36c 100644 --- a/scripts/mysql-variables.nse +++ b/scripts/mysql-variables.nse @@ -93,7 +93,7 @@ action = function( host, port ) -- for username, password in pairs(users) do - try( socket:connect(host.ip, port.number, "tcp") ) + try( socket:connect(host, port) ) response = try( mysql.receiveGreeting( socket ) ) status, response = mysql.loginRequest( socket, { authversion = "post41", charset = response.charset }, username, password, response.salt ) diff --git a/scripts/ntp-monlist.nse b/scripts/ntp-monlist.nse index f4071a064..f8f5fbfe9 100644 --- a/scripts/ntp-monlist.nse +++ b/scripts/ntp-monlist.nse @@ -167,7 +167,7 @@ function doquery(sock, host, port, inum, rcode, records) if not sock then sock = nmap.new_socket() sock:set_timeout(TIMEOUT) - local constatus, conerr = sock:connect(host.ip, port.number, port.protocol) + local constatus, conerr = sock:connect(host, port) if not constatus then stdnse.print_debug(1, 'Error establishing a UDP connection for %s - %s', target, conerr diff --git a/scripts/oracle-sid-brute.nse b/scripts/oracle-sid-brute.nse index c9efec9a9..aef57c519 100644 --- a/scripts/oracle-sid-brute.nse +++ b/scripts/oracle-sid-brute.nse @@ -144,7 +144,7 @@ action = function(host, port) -- check for comments if not sid:match("#!comment:") then - try(socket:connect(host.ip, port.number)) + try(socket:connect(host, port)) request = create_connect_packet( host.ip, port.number, sid ) try(socket:send(request)) response = try(socket:receive_bytes(1)) diff --git a/scripts/pgsql-brute.nse b/scripts/pgsql-brute.nse index f5fbc4b10..dc8f27aa4 100644 --- a/scripts/pgsql-brute.nse +++ b/scripts/pgsql-brute.nse @@ -61,7 +61,7 @@ local function connectSocket(host, port, ssl) -- set a reasonable timeout value socket:set_timeout(5000) - socket:connect(host.ip, port.number, "tcp") + socket:connect(host, port) -- let's be responsible and avoid sending communication in the clear if ( ssl ) then diff --git a/scripts/pjl-ready-message.nse b/scripts/pjl-ready-message.nse index 064c41f70..0b2930fc3 100644 --- a/scripts/pjl-ready-message.nse +++ b/scripts/pjl-ready-message.nse @@ -52,7 +52,7 @@ action = function(host, port) local socket = nmap.new_socket() socket:set_timeout(15000) try = nmap.new_try(function() socket:close() end) - try(socket:connect(host.ip, port.number)) + try(socket:connect(host, port)) try(socket:send(statusmsg)) --this block gets the current display status response,data=socket:receive() if not response then --send an initial probe. If no response, send nothing further. diff --git a/scripts/pop3-brute.nse b/scripts/pop3-brute.nse index cb487ac24..452e9eb56 100644 --- a/scripts/pop3-brute.nse +++ b/scripts/pop3-brute.nse @@ -90,7 +90,7 @@ action = function(host, port) elseif (perror == pop3.err.userError) then currPw = nil else - local socstatus = socket:connect(host.ip, port.number, bopt) + local socstatus = socket:connect(host, port, bopt) if not socstatus then return else _, line = socket:receive() diff --git a/scripts/realvnc-auth-bypass.nse b/scripts/realvnc-auth-bypass.nse index d8d3025ec..f12c77a30 100644 --- a/scripts/realvnc-auth-bypass.nse +++ b/scripts/realvnc-auth-bypass.nse @@ -22,7 +22,7 @@ action = function(host, port) local result local status = true - socket:connect(host.ip, port.number, port.protocol) + socket:connect(host, port) status, result = socket:receive_lines(1) diff --git a/scripts/smb-check-vulns.nse b/scripts/smb-check-vulns.nse index faf7943d5..466a92f4a 100644 --- a/scripts/smb-check-vulns.nse +++ b/scripts/smb-check-vulns.nse @@ -368,7 +368,7 @@ local function check_smbv2_dos(host) return false, "Couldn't create socket" end - status, result = socket:connect(host.ip, 445) + status, result = socket:connect(host, 445) if(status == false) then socket:close() return false, "Couldn't connect to host: " .. result @@ -396,7 +396,7 @@ local function check_smbv2_dos(host) -- Try and do something simple stdnse.print_debug(1, "smb-check-vulns: Attempting to connect to the host") socket:set_timeout(5000) - status, result = socket:connect(host.ip, 445) + status, result = socket:connect(host, 445) -- Check the result if(status == false or status == nil) then diff --git a/scripts/snmp-brute.nse b/scripts/snmp-brute.nse index 02079d73f..ae58c9cf1 100644 --- a/scripts/snmp-brute.nse +++ b/scripts/snmp-brute.nse @@ -42,7 +42,7 @@ action = function(host, port) local 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 request = snmp.buildGetRequest({}, "1.3.6.1.2.1.1.3.0") diff --git a/scripts/snmp-interfaces.nse b/scripts/snmp-interfaces.nse index 90e07b909..4c2c62471 100644 --- a/scripts/snmp-interfaces.nse +++ b/scripts/snmp-interfaces.nse @@ -355,7 +355,7 @@ action = function(host, port) local status socket:set_timeout(5000) - try(socket:connect(host.ip, port.number, "udp")) + try(socket:connect(host, port)) -- retreive network interface information from IF-MIB status, interfaces = snmp.snmpWalk( socket, if_oid ) @@ -371,7 +371,7 @@ action = function(host, port) interfaces = process_interfaces( interfaces ) -- retreive IP address information from IP-MIB - try(socket:connect(host.ip, port.number, "udp")) + try(socket:connect(host, port)) status, ips = snmp.snmpWalk( socket, ip_oid ) -- associate that IP address information with the correct interface diff --git a/scripts/snmp-netstat.nse b/scripts/snmp-netstat.nse index 661394543..e5afbe4f6 100644 --- a/scripts/snmp-netstat.nse +++ b/scripts/snmp-netstat.nse @@ -84,7 +84,7 @@ action = function(host, port) local status, tcp, udp socket:set_timeout(5000) - try(socket:connect(host.ip, port.number, "udp")) + try(socket:connect(host, port)) status, tcp = snmp.snmpWalk( socket, tcp_oid ) status, udp = snmp.snmpWalk( socket, udp_oid ) diff --git a/scripts/snmp-processes.nse b/scripts/snmp-processes.nse index 00d5a6e4a..b02fbf2f4 100644 --- a/scripts/snmp-processes.nse +++ b/scripts/snmp-processes.nse @@ -116,7 +116,7 @@ action = function(host, port) local status socket:set_timeout(5000) - try(socket:connect(host.ip, port.number, "udp")) + try(socket:connect(host, port)) status, shares = snmp.snmpWalk( socket, snmpoid ) socket:close() diff --git a/scripts/snmp-sysdescr.nse b/scripts/snmp-sysdescr.nse index 4adefb9db..60f7910b4 100644 --- a/scripts/snmp-sysdescr.nse +++ b/scripts/snmp-sysdescr.nse @@ -38,7 +38,7 @@ action = function(host, port) local 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 payload diff --git a/scripts/snmp-win32-services.nse b/scripts/snmp-win32-services.nse index 5dd3e8b78..45a7cbe92 100644 --- a/scripts/snmp-win32-services.nse +++ b/scripts/snmp-win32-services.nse @@ -63,7 +63,7 @@ action = function(host, port) local status socket:set_timeout(5000) - try(socket:connect(host.ip, port.number, "udp")) + try(socket:connect(host, port)) status, services = snmp.snmpWalk( socket, snmpoid ) socket:close() diff --git a/scripts/snmp-win32-shares.nse b/scripts/snmp-win32-shares.nse index 7dca5c65d..a55ed5ba2 100644 --- a/scripts/snmp-win32-shares.nse +++ b/scripts/snmp-win32-shares.nse @@ -81,7 +81,7 @@ action = function(host, port) local shares = {} socket:set_timeout(5000) - try(socket:connect(host.ip, port.number, "udp")) + try(socket:connect(host, port)) status, shares = snmp.snmpWalk( socket, snmpoid ) socket:close() diff --git a/scripts/snmp-win32-software.nse b/scripts/snmp-win32-software.nse index 9f186c4da..6f8d0ec04 100644 --- a/scripts/snmp-win32-software.nse +++ b/scripts/snmp-win32-software.nse @@ -86,7 +86,7 @@ action = function(host, port) local status socket:set_timeout(5000) - try(socket:connect(host.ip, port.number, "udp")) + try(socket:connect(host, port)) status, sw = snmp.snmpWalk( socket, snmpoid ) socket:close() diff --git a/scripts/snmp-win32-users.nse b/scripts/snmp-win32-users.nse index 502ce158f..9a9db1e87 100644 --- a/scripts/snmp-win32-users.nse +++ b/scripts/snmp-win32-users.nse @@ -59,7 +59,7 @@ action = function(host, port) local status socket:set_timeout(5000) - try(socket:connect(host.ip, port.number, "udp")) + try(socket:connect(host, port)) status, users = snmp.snmpWalk( socket, snmpoid ) socket:close() diff --git a/scripts/sshv1.nse b/scripts/sshv1.nse index c65843ceb..a5327b87b 100644 --- a/scripts/sshv1.nse +++ b/scripts/sshv1.nse @@ -20,7 +20,7 @@ action = function(host, port) local result; local status = true; - socket:connect(host.ip, port.number, port.protocol) + socket:connect(host, port) status, result = socket:receive_lines(1); if (not status) then diff --git a/scripts/ssl-cert.nse b/scripts/ssl-cert.nse index 3a061fa2f..9de943994 100644 --- a/scripts/ssl-cert.nse +++ b/scripts/ssl-cert.nse @@ -91,7 +91,7 @@ action = function(host, port) return nil end else - local status, error = s:connect(host.ip, port.number, "ssl") + local status, error = s:connect(host, port, "ssl") if not status then if nmap.verbosity() > 0 then @@ -188,7 +188,7 @@ function starttls_negotiate(host, port) -- Works for SMTP (25) and SMTP Submission (587) -- Open a standard TCP socket - local status, error = s:connect(host.ip, port.number, "tcp") + local status, error = s:connect(host, port, "tcp") if not status then return nil diff --git a/scripts/sslv2.nse b/scripts/sslv2.nse index 71ed5c0cc..db96764a4 100644 --- a/scripts/sslv2.nse +++ b/scripts/sslv2.nse @@ -156,7 +156,7 @@ action = function(host, port) table.insert(t, string.char(0x44, 0xc0, 0x3d, 0xc0)); ssl_v2_hello = table.concat(t, "") - socket:connect(host.ip, port.number, "tcp"); + socket:connect(host, port, "tcp"); socket:send(ssl_v2_hello); status, server_hello = socket:receive_bytes(2); diff --git a/scripts/telnet-brute.nse b/scripts/telnet-brute.nse index 70f9d4ec5..8f88ce01c 100644 --- a/scripts/telnet-brute.nse +++ b/scripts/telnet-brute.nse @@ -200,7 +200,7 @@ action = function(host, port) end if status == 3 or status == 4 then - try(soc:connect(host.ip, port.number, best_opt)) + try(soc:connect(host, port, best_opt)) end status, pair = brute_cred(user, pass, soc) diff --git a/scripts/upnp-info.nse b/scripts/upnp-info.nse index 44475f3ec..b674b0ccd 100644 --- a/scripts/upnp-info.nse +++ b/scripts/upnp-info.nse @@ -40,7 +40,7 @@ action = function(host, port) local try = nmap.new_try(catch) -- connect to the potential UPnP system - try(socket:connect(host.ip, port.number, "udp")) + try(socket:connect(host, port)) local payload = strbuf.new() diff --git a/scripts/x11-access.nse b/scripts/x11-access.nse index 3cd6b6758..cbaa1b6f3 100644 --- a/scripts/x11-access.nse +++ b/scripts/x11-access.nse @@ -38,7 +38,7 @@ action = function(host, port) end try = nmap.new_try(catch) - try(socket:connect(host.ip, port.number)) + try(socket:connect(host, port)) -- Sending the network dump of a x11 connection request (captured -- from the XOpenDisplay() function):