mirror of
https://github.com/nmap/nmap.git
synced 2025-12-10 09:49:05 +00:00
o The NSE Comm library now defaults to trying to read as many bytes as are
available rather than lines if neither the "bytes" nor "lines" options are given. Thanks to Brandon for reporting a problem which he noticed in the dns-test-open-recursion script. [Kris]
This commit is contained in:
@@ -65,6 +65,11 @@ o Nmap's Nsock-utilizing subsystems (DNS, NSE, version detection) have been
|
|||||||
|
|
||||||
o Added --ip-options support for the connect() scan (-sT). [Kris]
|
o Added --ip-options support for the connect() scan (-sT). [Kris]
|
||||||
|
|
||||||
|
o The NSE Comm library now defaults to trying to read as many bytes as are
|
||||||
|
available rather than lines if neither the "bytes" nor "lines" options are
|
||||||
|
given. Thanks to Brandon for reporting a problem which he noticed in the
|
||||||
|
dns-test-open-recursion script. [Kris]
|
||||||
|
|
||||||
o Changed the order preference of timing ping propes. [Michael]
|
o Changed the order preference of timing ping propes. [Michael]
|
||||||
|
|
||||||
o Enabled nmap to switch between multiple types of timing pings during port
|
o Enabled nmap to switch between multiple types of timing pings during port
|
||||||
|
|||||||
@@ -1651,8 +1651,9 @@ if(s) code_to_be_done_on_match end
|
|||||||
The relevant indexes for this table are <literal>bytes</literal>, <literal>lines</literal>,
|
The relevant indexes for this table are <literal>bytes</literal>, <literal>lines</literal>,
|
||||||
<literal>proto</literal> and <literal>timeout</literal>. <literal>bytes</literal>
|
<literal>proto</literal> and <literal>timeout</literal>. <literal>bytes</literal>
|
||||||
is used to provide the minimum number of bytes required for a read. <literal>lines</literal>
|
is used to provide the minimum number of bytes required for a read. <literal>lines</literal>
|
||||||
does the same, but for the minimum number of lines. <literal>proto</literal> is used
|
does the same, but for the minimum number of lines. If neither are provided, these
|
||||||
to set the protocol to communicate with, defaulting to "tcp" if not provided.
|
functions attempt to read as many bytes as are available. <literal>proto</literal>
|
||||||
|
is used to set the protocol to communicate with, defaulting to "tcp" if not provided.
|
||||||
<literal>timeout</literal> is used to set the socket timeout (see the socket function
|
<literal>timeout</literal> is used to set the socket timeout (see the socket function
|
||||||
<literal>set_timeout()</literal> for details).
|
<literal>set_timeout()</literal> for details).
|
||||||
</para>
|
</para>
|
||||||
|
|||||||
@@ -27,10 +27,10 @@ module(..., package.seeall)
|
|||||||
-- proto: Specifies the protocol to be used with the connect() call
|
-- proto: Specifies the protocol to be used with the connect() call
|
||||||
-- timeout: Sets the socket's timeout with nmap.set_timeout()
|
-- timeout: Sets the socket's timeout with nmap.set_timeout()
|
||||||
--
|
--
|
||||||
-- If neither lines nor bytes are specified, the calls read as many lines
|
-- If neither lines nor bytes are specified, the calls attempt to read as many
|
||||||
-- as possible. If only bytes if specified, then it only tries to read that
|
-- bytes as possible. If only bytes is specified, then it only tries to read
|
||||||
-- many bytes. Likewise, it only lines if specified, then it only tries to
|
-- that many bytes. Likewise, it only lines if specified, then it only tries
|
||||||
-- read that many lines. If they're both specified, the lines value is used.
|
-- to read that many lines. If they're both specified, the lines value is used.
|
||||||
--
|
--
|
||||||
------
|
------
|
||||||
|
|
||||||
@@ -71,39 +71,24 @@ local setup_connect = function(host, port, opts)
|
|||||||
return status, err
|
return status, err
|
||||||
end
|
end
|
||||||
|
|
||||||
|
-- If nothing is given, specify bytes=1 so NSE reads everything
|
||||||
|
if not opts.lines and not opts.bytes then
|
||||||
|
opts.bytes = 1
|
||||||
|
end
|
||||||
|
|
||||||
return true, sock
|
return true, sock
|
||||||
end
|
end
|
||||||
|
|
||||||
local read = function(sock, opts)
|
local read = function(sock, opts)
|
||||||
local line, response, status
|
local response, status
|
||||||
|
|
||||||
if opts.lines then
|
if opts.lines then
|
||||||
status, response = sock:receive_lines(opts.lines)
|
status, response = sock:receive_lines(opts.lines)
|
||||||
return status, response
|
return status, response
|
||||||
elseif opts.bytes then
|
|
||||||
status, response = sock:receive_bytes(opts.bytes)
|
|
||||||
return status, response
|
|
||||||
end
|
end
|
||||||
|
|
||||||
response = ""
|
status, response = sock:receive_bytes(opts.bytes)
|
||||||
|
return status, response
|
||||||
while true do
|
|
||||||
status, line = sock:receive_lines(1)
|
|
||||||
|
|
||||||
if not status then
|
|
||||||
break
|
|
||||||
end
|
|
||||||
|
|
||||||
response = response .. line
|
|
||||||
end
|
|
||||||
|
|
||||||
-- Either we reached the end of the stream, or we got all we could
|
|
||||||
-- within the socket timeout
|
|
||||||
if line == "EOF" or (line == "TIMEOUT" and response ~= "") then
|
|
||||||
return true, response
|
|
||||||
end
|
|
||||||
|
|
||||||
return false, line
|
|
||||||
end
|
end
|
||||||
|
|
||||||
get_banner = function(host, port, opts)
|
get_banner = function(host, port, opts)
|
||||||
|
|||||||
@@ -47,7 +47,7 @@ action = function(host, port)
|
|||||||
|
|
||||||
-- Ask proxy to open www.google.com
|
-- Ask proxy to open www.google.com
|
||||||
local req = "GET http://www.google.com HTTP/1.0\r\nHost: www.google.com\r\n\r\n"
|
local req = "GET http://www.google.com HTTP/1.0\r\nHost: www.google.com\r\n\r\n"
|
||||||
local status, result = comm.exchange(host, port, req, {proto=port.protocol, timeout=10000})
|
local status, result = comm.exchange(host, port, req, {lines=1,proto=port.protocol, timeout=10000})
|
||||||
|
|
||||||
if not status then
|
if not status then
|
||||||
return
|
return
|
||||||
|
|||||||
@@ -79,7 +79,7 @@ portrule = shortport.port_or_service({80, 8080}, "http")
|
|||||||
action = function(host, port)
|
action = function(host, port)
|
||||||
local cmd = "TRACE / HTTP/1.0\r\n\r\n"
|
local cmd = "TRACE / HTTP/1.0\r\n\r\n"
|
||||||
|
|
||||||
local status, response = comm.exchange(host, port, cmd, {timeout=5000})
|
local status, response = comm.exchange(host, port, cmd, {lines=1,timeout=5000})
|
||||||
|
|
||||||
if not status then
|
if not status then
|
||||||
return
|
return
|
||||||
|
|||||||
@@ -53,7 +53,7 @@ action = function(host, port)
|
|||||||
payload = payload .. "\000\000\000\000" -- padding for vendor name
|
payload = payload .. "\000\000\000\000" -- padding for vendor name
|
||||||
|
|
||||||
local try = nmap.new_try()
|
local try = nmap.new_try()
|
||||||
local response = try(comm.exchange(host, port, payload, {bytes=1, timeout=5000}))
|
local response = try(comm.exchange(host, port, payload, {timeout=5000}))
|
||||||
|
|
||||||
local result
|
local result
|
||||||
|
|
||||||
|
|||||||
@@ -20,7 +20,7 @@ action = function(host, port)
|
|||||||
poke = poke .. string.char(0x00, 0x00, 0x00, 0x00)
|
poke = poke .. string.char(0x00, 0x00, 0x00, 0x00)
|
||||||
poke = poke .. string.char(0x00, 0x00, 0x06, 0x1e)
|
poke = poke .. string.char(0x00, 0x00, 0x06, 0x1e)
|
||||||
|
|
||||||
local status, recv = comm.exchange(host, port, poke, {bytes=1,proto=port.protocol,timeout=10000})
|
local status, recv = comm.exchange(host, port, poke, {proto=port.protocol,timeout=10000})
|
||||||
|
|
||||||
if not status then
|
if not status then
|
||||||
return
|
return
|
||||||
|
|||||||
@@ -65,7 +65,7 @@ action = function(host)
|
|||||||
"\065\065\065\065\065\000\000\033" ..
|
"\065\065\065\065\065\000\000\033" ..
|
||||||
"\000\001"
|
"\000\001"
|
||||||
|
|
||||||
local status, result = comm.exchange(host, 137, data, {bytes=1, proto="udp", timeout=5000})
|
local status, result = comm.exchange(host, 137, data, {proto="udp", timeout=5000})
|
||||||
|
|
||||||
if (not status) then
|
if (not status) then
|
||||||
return
|
return
|
||||||
|
|||||||
Reference in New Issue
Block a user