Windows Defender - 以编程方式添加排除文件夹

问题描述 投票:7回答:5

为了研究目的,我正在检查不同的键盘记录器,偶然发现了Refog:

https://www.refog.com/keylogger/

这个程序可以捕获很多系统事件,但真正引起我注意的是其他东西。该程序创建了一个名为Mpk的隐藏文件夹,路径为C:\ Windows \ SysWOW64 \ Mpk。它被标记为操作系统文件文件夹,因为在我取消标记Hide protected operating system files (recommended)之前它是不可见的。我想,这可以通过像这个attrib +s +h "C:\Windows\SysWOW64\Mpk"这样的attrib命令来完成,所以没什么革命性的。

Hide

但是,他们还为Windows Defender添加了此文件夹的排除项。他们怎么能以编程方式执行此操作?我正在运行Windows 10 Pro x64。

Exclusion

windows windows-10 windows-defender
5个回答
10
投票

执行此操作的正确方法是使用Add-MpPreference PowerShell cmdlet。使用此cmdlet可为文件扩展名,路径和进程添加排除项,并为高,中和低威胁添加默认操作。

您可以使用以下命令行从Windows 10中的高架cmd shell轻松执行此操作:

powershell -inputformat none -outputformat none -NonInteractive -Command Add-MpPreference -ExclusionPath "C:\Windows\SysWOW64\Mpk"

6
投票

经过一番挖掘后,我找到了以下文件夹:

HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows Defender\Exclusions\Paths

我无法在我的用户处添加密钥。我收到以下错误:Cannot create key: You do not have the requisite permissions to create a new key under Paths

但是,SYSTEM,WinDefend和TrustedInstaller都具有完全控制权。最好的猜测是他们使用了像DevxExec devxexec.exe /user:TrustedInstaller cmd这样的东西并将密钥写入了注册表。

Enter image description here


2
投票

在提升的shell中运行(在“开始”菜单中搜索cmd并按Ctrl + Shift + Enter)。

powershell -Command Add-MpPreference -ExclusionPath "C:\tmp"
powershell -Command Add-MpPreference -ExclusionProcess "java.exe"
powershell -Command Add-MpPreference -ExclusionExtension ".java"

powershell -Command Remove-MpPreference -ExclusionExtension ".java"

1
投票

最简单的方法是使用CMD中的PowerShell提升权限(如balrob's answer),但您也可以使用PowerShell环境变量来简化生活;例如:

powershell -inputformat none -outputformat none -NonInteractive -Command Add-MpPreference -ExclusionPath $ENV:USERPROFILE\Downloads

这将添加当前用户的下载文件夹,例如。 C:\用户\苏珊娜\下载。

要获取PowerShell提供的环境变量列表,可以使用此PowerShell命令:

Get-ChildItem Env: | Sort Name

如您所见,有windir变量。除了您提到的子文件夹之外,他们还可以使用它。


0
投票

转到powershell

Add-MpPreference -ExclusionPath“C:\ Temp”

参考:https://docs.microsoft.com/en-us/powershell/module/defender/add-mppreference?view=win10-ps

© www.soinside.com 2019 - 2024. All rights reserved.