mirror of
https://github.com/nmap/nmap.git
synced 2025-12-22 15:39:03 +00:00
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.
This commit is contained in:
@@ -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 } )
|
||||
|
||||
@@ -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())
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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.
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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"
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
end
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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 )
|
||||
|
||||
@@ -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 )
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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 )
|
||||
|
||||
@@ -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 )
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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))
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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.
|
||||
|
||||
@@ -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()
|
||||
|
||||
@@ -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)
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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")
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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 )
|
||||
|
||||
@@ -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()
|
||||
|
||||
@@ -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
|
||||
|
||||
|
||||
@@ -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()
|
||||
|
||||
@@ -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()
|
||||
|
||||
@@ -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()
|
||||
|
||||
@@ -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()
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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()
|
||||
|
||||
|
||||
@@ -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):
|
||||
|
||||
Reference in New Issue
Block a user