1
0
mirror of https://github.com/nmap/nmap.git synced 2025-12-06 04:31:29 +00:00

Use stdnse.format_timestamp in more places to avoid formatting issues. See #1255, #1303

This commit is contained in:
dmiller
2018-08-16 21:26:48 +00:00
parent 834e37d475
commit 6c4e02e89d
8 changed files with 13 additions and 13 deletions

View File

@@ -1778,9 +1778,9 @@ Helper = {
local item = ( response.result.file ) and response.result.file or response.result.dir
local diff = os.time{year=2000, month=1, day=1, hour=0} - os.time{year=1970, month=1, day=1, hour=0}
local create = os.date("%Y-%m-%d %H:%M", item.CreationDate + diff)
local backup = os.date("%Y-%m-%d %H:%M", item.BackupDate )
local modify = os.date("%Y-%m-%d %H:%M", item.ModificationDate + diff )
local create = stdnse.format_timestamp(item.CreationDate + diff)
local backup = stdnse.format_timestamp(item.BackupDate )
local modify = stdnse.format_timestamp(item.ModificationDate + diff )
return true, { create = create, backup = backup, modify = modify }
end,

View File

@@ -523,7 +523,7 @@ OptionToString = {
if ( HWTYPE_ETHER == opt.hwtype ) then
local mac = stdnse.tohex(opt.mac):upper()
mac = mac:gsub("..", "%1:"):sub(1, -2)
local tm = os.date("%Y-%m-%d %H:%M:%S", opt.time)
local tm = stdnse.format_timestamp(opt.time)
return "Client identifier", ("MAC: %s; Time: %s"):format(mac, tm)
end
end,

View File

@@ -410,7 +410,7 @@ Helper = {
results[printer] = results[printer] or {}
table.insert(results[printer], {
id = id,
time = os.date("%Y-%m-%d %H:%M:%S", tm),
time = stdnse.format_timestamp(tm),
state = ( IPP.StateName[tonumber(state)] or "Unknown" ),
size = size,
owner = owner,

View File

@@ -834,7 +834,7 @@ function convertADTimeStamp(timestamp)
result = ( timestamp // 10000000 ) - 3036
result = result + base_time
result = os.date("%Y/%m/%d %H:%M:%S UTC", result)
result = stdnse.format_timestamp(result, 0)
else
result = 'Never'
end

View File

@@ -2629,7 +2629,7 @@ function winreg_enumkey(smbstate, handle, index, name)
-- [in,out,unique] NTTIME *last_changed_time
pos, result['changed_time'] = msrpctypes.unmarshall_NTTIME_ptr(arguments, pos)
result['changed_date'] = os.date("%Y-%m-%d %H:%M:%S", result['changed_time'])
result['changed_date'] = stdnse.format_timestamp(result['changed_time'])
pos, result['return'] = msrpctypes.unmarshall_int32(arguments, pos)
if(result['return'] == nil) then
@@ -2771,7 +2771,7 @@ function winreg_queryinfokey(smbstate, handle)
-- [out,ref] NTTIME *last_changed_time
pos, result['last_changed_time'] = msrpctypes.unmarshall_NTTIME(arguments, pos)
result['last_changed_date'] = os.date("%Y-%m-%d %H:%M:%S", result['last_changed_time'])
result['last_changed_date'] = stdnse.format_timestamp(result['last_changed_time'])
pos, result['return'] = msrpctypes.unmarshall_int32(arguments, pos)
if(result['return'] == nil) then
@@ -4421,7 +4421,7 @@ local function get_domain_info(host, domain)
response['groups'] = groups
response['users'] = names
if(querydomaininfo2_result_8['info']['domain_create_time'] ~= 0) then
response['created'] = os.date("%Y-%m-%d %H:%M:%S", querydomaininfo2_result_8['info']['domain_create_time'])
response['created'] = stdnse.format_timestamp(querydomaininfo2_result_8['info']['domain_create_time'])
else
response['created'] = "unknown"
end
@@ -4889,7 +4889,7 @@ function get_server_stats(host)
local stats = netservergetstatistics_result['stat']
-- Convert the date to a string
stats['start_str'] = os.date("%Y-%m-%d %H:%M:%S", stats['start'])
stats['start_str'] = stdnse.format_timestamp(stats['start'])
-- Get the period and convert it to a proper time offset
stats['period'] = os.time() - stats['start']

View File

@@ -67,7 +67,7 @@ action = function(host, port)
if ( target.ALLOW_NEW_TARGETS ) then
target.add(node.address.host)
end
tab.addrow(response, ("%s:%d"):format(node.address.host, node.address.port), os.date("%x %X", node.ts))
tab.addrow(response, ("%s:%d"):format(node.address.host, node.address.port), stdnse.format_timestamp(node.ts))
end
if ( #response > 1 ) then

View File

@@ -74,7 +74,7 @@ action = function()
end
local ts
if ( info.timestamp and 1000 < info.timestamp ) then
ts = os.date("%x %X", info.timestamp//1000)
ts = stdnse.format_timestamp(info.timestamp//1000)
else
ts = "-"
end

View File

@@ -156,7 +156,7 @@ local function get_info_registry(host)
result['status-currentversion'], result['currentversion'] = reg_get_value(smbstate, openhklm_result['handle'], "Software\\Microsoft\\Windows NT\\CurrentVersion", "CurrentVersion")
result['status-installdate'], result['installdate'] = reg_get_value(smbstate, openhklm_result['handle'], "Software\\Microsoft\\Windows NT\\CurrentVersion", "InstallDate")
if(result['status-installdate'] ~= false) then
result['installdate'] = os.date("%Y-%m-%d %H:%M:%S", result['installdate'])
result['installdate'] = stdnse.format_timestamp(result['installdate'])
end
result['status-productname'], result['productname'] = reg_get_value(smbstate, openhklm_result['handle'], "Software\\Microsoft\\Windows NT\\CurrentVersion", "Productname")