From d5af9560c3fc917d64d201eb1bc7bfa71f088f6f Mon Sep 17 00:00:00 2001 From: tomsellers Date: Sat, 20 Dec 2014 01:14:34 +0000 Subject: [PATCH] Add the full ntpd version string, for example v4.2.4p4@1.1520-o, to the port's version attributes if the remote service provides it. Also capture OS info as well as it can provide exact kernel versions in some cases. --- scripts/ntp-info.nse | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/scripts/ntp-info.nse b/scripts/ntp-info.nse index 54df5f937..cfe3f3296 100644 --- a/scripts/ntp-info.nse +++ b/scripts/ntp-info.nse @@ -27,7 +27,7 @@ documentation of the protocol. -- nmap -sU -p 123 --script ntp-info -- @output -- PORT STATE SERVICE VERSION --- 123/udp open ntp NTP v4 +-- 123/udp open ntp NTP v4.2.4p4@1.1520-o -- | ntp-info: -- | receive time stamp: Sat Dec 12 16:22:41 2009 -- | version: ntpd 4.2.4p4@1.1520-o Wed May 13 21:06:31 UTC 2009 (1) @@ -138,6 +138,19 @@ action = function(host, port) if(#output > 0) then stdnse.debug1("Test len: %d", #output) nmap.set_port_state(host, port, "open") + if output['version'] then + -- Look for the version string from the official ntpd and format it + -- in a manner similar to the output of the standard Nmap version detection + local version_num = string.match(output['version'],"^ntpd ([^@]+)") + if version_num then + port.version.version = "v" .. version_num + nmap.set_port_version(host, port, "hardmatched") + end + end + if output['system'] then + port.version.ostype = output['system'] + nmap.set_port_version(host, port, "hardmatched") + end if nmap.verbosity() < 1 then local mt = getmetatable(output) mt["__tostring"] = function(t)