diff --git a/scripts/http-date.nse b/scripts/http-date.nse
index e16094af5..ab7320cf4 100644
--- a/scripts/http-date.nse
+++ b/scripts/http-date.nse
@@ -18,7 +18,7 @@ sent, so the difference includes at least the duration of one RTT.
-- |_http-date: Thu, 02 Aug 2012 22:07:12 GMT; -3m51s from local time.
--
-- @xmloutput
--- 2012-08-02T23:07:12Z
+-- 2012-08-02T23:07:12+00:00
-- -231
author = "David Fifield"
@@ -31,8 +31,7 @@ categories = {"discovery", "safe"}
portrule = shortport.http
action = function(host, port)
- -- Get the local date in UTC.
- local request_date = os.date("!*t")
+ local request_time = os.time()
local response = http.get(host, port, "/")
if not response.status or not response.header["date"] then
return
@@ -42,14 +41,14 @@ action = function(host, port)
if not response_date then
return
end
+ local response_time = stdnse.date_to_timestamp(response_date)
local output_tab = stdnse.output_table()
- -- ISO 8601 date and time.
- output_tab.date = os.date("%Y-%m-%dT%H:%M:%SZ", os.time(response_date))
- output_tab.delta = os.difftime(os.time(response_date), os.time(request_date))
+ output_tab.date = stdnse.format_timestamp(response_time, 0)
+ output_tab.delta = os.difftime(response_time, request_time)
local output_str = string.format("%s; %s from local time.",
- response.header["date"], stdnse.format_difftime(response_date, request_date))
+ response.header["date"], stdnse.format_difftime(os.date("!*t", response_time), os.date("!*t", request_time)))
return output_tab, output_str
end
diff --git a/scripts/smb-os-discovery.nse b/scripts/smb-os-discovery.nse
index 96629cd76..11be42802 100644
--- a/scripts/smb-os-discovery.nse
+++ b/scripts/smb-os-discovery.nse
@@ -57,7 +57,7 @@ will speed up the script on targets that do not allow guest access.
-- | FQDN: Sql2008.lab.test.local
-- | NetBIOS computer name: SQL2008
-- | NetBIOS domain name: LAB
--- |_ System time: 2011-04-20 13:34:06 UTC-5
+-- |_ System time: 2011-04-20T13:34:06-05:00
--
--@xmloutput
-- Windows Server (R) 2008 Standard 6001 Service Pack 1 (Windows Server (R) 2008 Standard 6.0)
@@ -67,7 +67,7 @@ will speed up the script on targets that do not allow guest access.
-- Sql2008.lab.test.local
-- SQL2008
-- LAB
--- 2011-04-20 13:34:06 UTC-5
+-- 2011-04-20T13:34:06-05:00
author = "Ron Bowes"
license = "Same as Nmap--See http://nmap.org/book/man-legal.html"
@@ -125,8 +125,8 @@ action = function(host)
if (result['os'] and result['lanmanager']) then
os_string = string.format( "%s (%s)", get_windows_version( result['os'] ), result['lanmanager'] )
end
- if (result['date'] and result['timezone_str']) then
- time_string = string.format("%s%+03d%02d", os.date("%Y-%m-%dT%H:%M:%S", result.time), result.timezone, math.abs(math.fmod(result.timezone, 1)) * 60)
+ if (result['time'] and result['timezone']) then
+ time_string = stdnse.format_timestamp(result.time, result.timezone * 60 * 60)
end
diff --git a/scripts/ssl-cert.nse b/scripts/ssl-cert.nse
index b3c6ba51d..eb23cd3dd 100644
--- a/scripts/ssl-cert.nse
+++ b/scripts/ssl-cert.nse
@@ -96,8 +96,8 @@ certificate.
-- 2048
--
--
--- 2011-03-23T00:00:00Z
--- 2013-04-01T23:59:59Z
+-- 2011-03-23T00:00:00+00:00
+-- 2013-04-01T23:59:59+00:00
--
-- bf47cecad861efa77d1488ad4a73cb5b
-- d8465221467a0d153df09f2eaf6d439002139a68
@@ -183,10 +183,6 @@ local function name_to_table(name)
return output
end
-local function format_time(t)
- return os.date("%Y-%m-%dT%H:%M:%SZ", os.time(t))
-end
-
local function output_tab(cert)
local o = stdnse.output_table()
o.subject = name_to_table(cert.subject)
@@ -194,7 +190,7 @@ local function output_tab(cert)
o.pubkey = cert.pubkey
o.validity = {}
for k, v in pairs(cert.validity) do
- o.validity[k] = format_time(v)
+ o.validity[k] = stdnse.format_timestamp(stdnse.date_to_timestamp(v, 0), 0)
end
o.md5 = stdnse.tohex(cert:digest("md5"))
o.sha1 = stdnse.tohex(cert:digest("sha1"))
diff --git a/scripts/ssl-date.nse b/scripts/ssl-date.nse
index 99dbac4d1..58d87a989 100644
--- a/scripts/ssl-date.nse
+++ b/scripts/ssl-date.nse
@@ -38,7 +38,7 @@ end
-- |_ssl-date: 2012-08-02T18:29:31Z; +4s from local time.
--
-- @xmloutput
--- 2012-08-02T18:29:31Z
+-- 2012-08-02T18:29:31+00:00
-- 4
--
@@ -164,7 +164,7 @@ action = function(host, port)
status, result = extract_time(response)
if status then
local output = {
- date = os.date("!%Y-%m-%dT%H:%M:%SZ",result),
+ date = stdnse.format_timestamp(result, 0),
delta = os.difftime(result, now),
}
return output, string.format("%s; %s from local time.", output.date,