在我的可执行文件(tsk_gettimes)中,它打印出一个unix时间戳,其中包含它在终端中打印出的每一条信息。我想知道是否有一种方法,我可以让用户输入一个日期(2004,09,19),它输出当天发生的所有unix时间戳(换句话说,我将上面的日期发送到unix转换器使用零时,分,秒等,并打印出当天的所有时间),请让我知道我是否需要更好地表达这一点!
我已经更新了代码,使用一个范围,但我没有收到输出。
from asyncio import subprocess
import datetime
import time
import subprocess, os
#print("[file name] [year, month, day]")
#filename, keydate = input().split(' ')
def UNIX(date):
#takes in input
x = date
#prints input date as normal
print("[date]", x)
#creates unix timestamp after conversion
keyunix = int(time.mktime(datetime.datetime.strptime(x, "%d/%m/%Y").timetuple()))
#prints unix timestamp
print("[UNIXTimestamp]", keyunix)
return keyunix
# user file input
print("Enter file name with extention")
filename = input()
#print file name
print("[file name]", filename )
assert os.path.exists(filename)
assert os.path.exists("C:\Program Files\sleuthkit-4.11.1-win32\bin\tsk_gettimes.exe")
# user date input
print("Enter date [dd/mm/yyyy]")
userdate = input()
keydate = str(UNIX(userdate))
#86400 seconds in a day
interval = str(int(keydate) + int('86400'))
print("[interval]",
interval)
#reading the output of the executable fileclear
test = subprocess.run(["C:\Program Files\sleuthkit-4.11.1-win32\bin\tsk_gettimes.exe", filename],
stdout = subprocess.PIPE)
output = test.stdout.decode().split('n')
#retreiving all the matches of the keydate (i)
for i in output:
#looking for the keydate in the i
if keydate in i:
#looking if its in range
if keydate in range(keydate,interval):
print(i)
def UNIX(date):
#takes in input
x = date
#prints input date as normal
print("[date]", x)
#creates unix timestamp after conversion
keyunix = int(time.mktime(datetime.datetime.strptime(x, "%d/%m/%Y").timetuple()))
#prints unix timestamp
print("[UNIXTimestamp]", keyunix)
return keyunix
#looking if its in range
for keydate in str(range(keydate, interval)):
#retreiving all the matches of the keydate (i)
for i in output:
#looking for the keydate in the i
if keydate in i:
print(i)
this从可执行文件中打印出我需要的输入。