mirror of
https://github.com/nmap/nmap.git
synced 2025-12-23 16:09:02 +00:00
Add a default timeout of 5000 ms to the ntp-info script, and don't try
sending the second probe if the first caused an error. This is based on the results of a test by Richard Sammet showing that the default timeout of 30 s is too long when scanning many open|filtered ports that are in fact filtered.
This commit is contained in:
@@ -38,6 +38,10 @@ require "shortport"
|
|||||||
|
|
||||||
portrule = shortport.port_or_service(123, "ntp", {"udp", "tcp"})
|
portrule = shortport.port_or_service(123, "ntp", {"udp", "tcp"})
|
||||||
|
|
||||||
|
-- This script run against open|filtered ports, so don't wait too long if
|
||||||
|
-- there's no response.
|
||||||
|
local TIMEOUT = 5000
|
||||||
|
|
||||||
-- Transform an array into a table where the array's values all map to true.
|
-- Transform an array into a table where the array's values all map to true.
|
||||||
local function make_set(a)
|
local function make_set(a)
|
||||||
local i, v, result
|
local i, v, result
|
||||||
@@ -69,8 +73,11 @@ action = function(host, port)
|
|||||||
local rlreq = string.char(0x16, 0x02, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00,
|
local rlreq = string.char(0x16, 0x02, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00,
|
||||||
0x00, 0x00, 0x00, 0x00)
|
0x00, 0x00, 0x00, 0x00)
|
||||||
|
|
||||||
status, buftres = comm.exchange(host, port, treq, {proto=port.protocol})
|
status, buftres = comm.exchange(host, port, treq, {proto=port.protocol, timeout=TIMEOUT})
|
||||||
if status then
|
if not status then
|
||||||
|
-- Don't try the second probe if this one didn't work.
|
||||||
|
return nil
|
||||||
|
else
|
||||||
local _, sec, frac, tstamp
|
local _, sec, frac, tstamp
|
||||||
|
|
||||||
_, sec, frac = bin.unpack(">II", buftres, 33)
|
_, sec, frac = bin.unpack(">II", buftres, 33)
|
||||||
@@ -82,7 +89,7 @@ action = function(host, port)
|
|||||||
table.insert(output, string.format("receive time stamp: %s", os.date("%c", tstamp)))
|
table.insert(output, string.format("receive time stamp: %s", os.date("%c", tstamp)))
|
||||||
end
|
end
|
||||||
|
|
||||||
status, bufrlres = comm.exchange(host, port, rlreq, {proto=port.protocol})
|
status, bufrlres = comm.exchange(host, port, rlreq, {proto=port.protocol, timeout=TIMEOUT})
|
||||||
|
|
||||||
if status then
|
if status then
|
||||||
-- This only looks at the first fragment of what can possibly be several
|
-- This only looks at the first fragment of what can possibly be several
|
||||||
|
|||||||
Reference in New Issue
Block a user