• 欢迎访问挑战自我博客网站,安全研究,web渗透,推荐使用最新版火狐浏览器和Chrome浏览器访问本网站,欢迎加入挑战自我博客网站 网站主页

1、修改指定文件的时间为特定时间

powershell.exe -command "ls test.dll | foreach-object { $_.LastWriteTime = '01/11/2004 22:13:36'; $_.CreationTime = '01/11/2004 22:13:36' }"

2、修改指定目录下(folder_path)文件的时间为当前时间

powershell.exe -command "ls 'folder_path\*.dll' | foreach-object { $_.LastWriteTime = Get-Date; $_.CreationTime = Get-Date }"

3、修改指定文件(test.dll)的时间为当前时间

powershell.exe -command "ls test.dll | foreach-object { $_.LastWriteTime = Get-Date; $_.CreationTime = Get-Date }"

4、代码解释

代码将folder_path路径下的所有dll文件的创建时间和修改时间改成现在的时间。

-command: tells powershell to run the following command and return immediately
ls: list all matching files at the path specified
foreach-object: run the following block on each file that ls found
$_.LastWriteTime = Get-Date: for each file, set the LastWriteTime to the value returned by Get-Date (today’s date and time)
$_.CreationTime = Get-Date: for each file, set the CreationTime to the value returned by Get-Date (today’s date and time)

注:正在使用的文件无法修改时间