如何让 Windows 认为文件“来自另一台计算机”?

jpm*_*c26 16 windows security ntfs

“此文件来自另一台计算机...”中的答案- 如何取消阻止文件夹中的所有文件而不必单独取消阻止它们?解释如何“取消阻止”来自远程源的文件。出于测试目的,我想完成相反的操作。如何设置文件的区域标识符以便 Windows 将“阻止”它?

我偏爱 PowerShell 解决方案,但其他机制也是可以接受的。

Hel*_*and 22

下载文件后,您可能会注意到文件属性对话框中有一个Security带有Unblock复选框的附加部分: 在此处输入图片说明

有关文件的此附加数据存储在备用数据流 (ADS) 中。可以通过多种方式查看备用数据流,使用Streams等工具,但现在使用 PowerShell 更方便。

例如,要查看文件的所有流,可以使用以下 PowerShell 命令:

Get-Item -Path Autologon.exe -Stream *

输出如下:

PSPath        : Microsoft.PowerShell.Core\FileSystem::C:\ads\Autologon.exe::$DATA
PSParentPath  : Microsoft.PowerShell.Core\FileSystem::C:\ads
PSChildName   : Autologon.exe::$DATA
PSDrive       : C
PSProvider    : Microsoft.PowerShell.Core\FileSystem
PSIsContainer : False
FileName      : C:\ads\Autologon.exe
Stream        : :$DATA
Length        : 138920

PSPath        : Microsoft.PowerShell.Core\FileSystem::C:\ads\Autologon.exe:Zone.Identifier
PSParentPath  : Microsoft.PowerShell.Core\FileSystem::C:\ads
PSChildName   : Autologon.exe:Zone.Identifier
PSDrive       : C
PSProvider    : Microsoft.PowerShell.Core\FileSystem
PSIsContainer : False
FileName      : C:\ads\Autologon.exe
Stream        : Zone.Identifier
Length        : 26
Run Code Online (Sandbox Code Playgroud)

对于这个问题,Zone.Identifier我们感兴趣的是流。

要手动添加或更新Zone.Identifier命名流并设置流的值,我们可以运行以下 PowerShell 命令:

Set-Content -Path .\file.exe -Stream Zone.Identifier -Value '[ZoneTransfer]','ZoneId=3'

其中ZoneId指定的可以是以下值之一:

0 = "Local machine"
1 = "Local intranet"
2 = "Trusted sites"
3 = "Internet"
4 = "Restricted sites"
Run Code Online (Sandbox Code Playgroud)

注意:要从ZoneTransfer文件中删除流并因此执行与从文件属性对话框取消阻止文件相同的操作,您可以运行以下任一命令:

  • Unblock-File -path .\file.exe
  • Remove-Item -Path .\file.exe -Stream Zone.Identifier