diff --git a/nselib/afp.lua b/nselib/afp.lua index 5ec743ce6..f216d05e1 100644 --- a/nselib/afp.lua +++ b/nselib/afp.lua @@ -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, diff --git a/nselib/dhcp6.lua b/nselib/dhcp6.lua index f1ea45ca2..46f67cf1d 100644 --- a/nselib/dhcp6.lua +++ b/nselib/dhcp6.lua @@ -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, diff --git a/nselib/ipp.lua b/nselib/ipp.lua index acb0f8b9e..f1ea9ddfd 100644 --- a/nselib/ipp.lua +++ b/nselib/ipp.lua @@ -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, diff --git a/nselib/ldap.lua b/nselib/ldap.lua index 74a8a0dab..e9d8bc942 100644 --- a/nselib/ldap.lua +++ b/nselib/ldap.lua @@ -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 diff --git a/nselib/msrpc.lua b/nselib/msrpc.lua index 48006b6e3..302370a67 100644 --- a/nselib/msrpc.lua +++ b/nselib/msrpc.lua @@ -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'] diff --git a/scripts/bitcoin-getaddr.nse b/scripts/bitcoin-getaddr.nse index 2108feb17..7788faa4d 100644 --- a/scripts/bitcoin-getaddr.nse +++ b/scripts/bitcoin-getaddr.nse @@ -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 diff --git a/scripts/http-icloud-findmyiphone.nse b/scripts/http-icloud-findmyiphone.nse index b6b997727..b2bb71b36 100644 --- a/scripts/http-icloud-findmyiphone.nse +++ b/scripts/http-icloud-findmyiphone.nse @@ -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 diff --git a/scripts/smb-system-info.nse b/scripts/smb-system-info.nse index 2e186a4f0..bfdc6205f 100644 --- a/scripts/smb-system-info.nse +++ b/scripts/smb-system-info.nse @@ -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")