diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-17 07:42:04 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-17 07:42:04 +0000 |
commit | 0d47952611198ef6b1163f366dc03922d20b1475 (patch) | |
tree | 3d840a3b8c0daef0754707bfb9f5e873b6b1ac13 /scripts/smb2-time.nse | |
parent | Initial commit. (diff) | |
download | nmap-0d47952611198ef6b1163f366dc03922d20b1475.tar.xz nmap-0d47952611198ef6b1163f366dc03922d20b1475.zip |
Adding upstream version 7.94+git20230807.3be01efb1+dfsg.upstream/7.94+git20230807.3be01efb1+dfsgupstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'scripts/smb2-time.nse')
-rw-r--r-- | scripts/smb2-time.nse | 51 |
1 files changed, 51 insertions, 0 deletions
diff --git a/scripts/smb2-time.nse b/scripts/smb2-time.nse new file mode 100644 index 0000000..4b19400 --- /dev/null +++ b/scripts/smb2-time.nse @@ -0,0 +1,51 @@ +local os = require "os" +local datetime = require "datetime" +local smb = require "smb" +local stdnse = require "stdnse" +local smb2 = require "smb2" + +description = [[ +Attempts to obtain the current system date and the start date of a SMB2 server. +]] + +--- +-- @usage nmap -p445 --script smb2-time <target> +-- +-- @output +-- Host script results: +-- | smb2-time: +-- | date: 2017-07-28 03:06:34 +-- |_ start_date: 2017-07-20 09:29:49 +-- +-- @xmloutput +-- <elem key="date">2017-07-28 03:07:57</elem> +-- <elem key="start_date">2017-07-20 09:29:49</elem> +--- + +author = "Paulino Calderon <calderon()websec.mx>" +license = "Same as Nmap--See https://nmap.org/book/man-legal.html" +categories = {"discovery", "safe", "default"} + +hostrule = function(host) + return smb.get_port(host) ~= nil +end + +action = function(host,port) + local smbstate, status + local output = stdnse.output_table() + status, smbstate = smb.start(host) + status = smb2.negotiate_v2(smbstate) + + if status then + datetime.record_skew(host, smbstate.time, os.time()) + stdnse.debug2("SMB2: Date: %s (%s) Start date:%s (%s)", + smbstate['date'], smbstate['time'], + smbstate['start_date'], smbstate['start_time']) + output.date = smbstate['date'] + output.start_date = smbstate['start_date'] + return output + else + stdnse.debug2("Negotiation failed") + return "Protocol negotiation failed (SMB2)" + end +end |