Windows 11 系统强化终极指南:对抗国家级威胁的深度防护配置

关于 Windows 的本质警告

在继续阅读之前,必须明确一点:Windows 是闭源操作系统,其安全性本质上无法被独立验证。

Windows 的闭源特性意味着:

  • 你无法审计其源代码中是否存在后门
  • 微软与美国情报机构的合作历史有据可查(PRISM 项目)
  • 系统遥测数据的完整内容无法被用户确认
  • 安全补丁的完整性依赖于对微软的信任

如果你有高度安全需求,强烈建议迁移至 Linux 发行版(如Tails、Whonix、或经过强化的 Debian/Arch)。Linux 的开源特性允许全球安全研究人员审计代码,且其设计哲学更符合最小权限原则。

然而,若因软件兼容性、专业工作流程或其他原因不得不使用 Windows,本文将提供目前已知的最深度系统强化措施,使你的 Windows 11 防护能力最大化。


第一章:攻击面削减规则(ASR)——微软隐藏的企业级防护

ASR 规则是 Windows 11 纵深防御安全模型的关键组件,提供针对常见攻击向量和恶意行为的主动防护。这些规则属于 Microsoft Defender for Endpoint 的一部分,帮助防止恶意软件通常用于入侵 Windows 设备的行为。可将其视为阻止风险行为的护栏,例如阻止 Office 宏启动可执行文件、阻止脚本从邮件下载文件、或阻止进程从 LSASS 窃取凭据。

1.1 通过 PowerShell 启用全部关键 ASR 规则

配置 ASR 规则的主要方法是使用 Set-MpPreference PowerShell cmdlet,配合 AttackSurfaceReductionRules_Ids 和 AttackSurfaceReductionRules_Actions 参数。

以管理员权限打开 PowerShell,执行以下命令批量启用所有关键 ASR 规则:

# 阻止 Office 应用创建可执行内容
Add-MpPreference -AttackSurfaceReductionRules_Ids 3b576869-a4ec-4529-8536-b80a7769e899 -AttackSurfaceReductionRules_Actions Enabled

# 阻止 Office 应用向其他进程注入代码
Add-MpPreference -AttackSurfaceReductionRules_Ids 75668c1f-73b5-4cf0-bb93-3ecf5cb7cc84 -AttackSurfaceReductionRules_Actions Enabled

# 阻止 JavaScript 或 VBScript 启动下载的可执行内容
Add-MpPreference -AttackSurfaceReductionRules_Ids d3e037e1-3eb8-44c8-a917-57927947596d -AttackSurfaceReductionRules_Actions Enabled

# 阻止执行可能被混淆的脚本
Add-MpPreference -AttackSurfaceReductionRules_Ids 5beb7efe-fd9a-4556-801d-275e5ffc04cc -AttackSurfaceReductionRules_Actions Enabled

# 阻止 Win32 API 调用来自 Office 宏
Add-MpPreference -AttackSurfaceReductionRules_Ids 92e97fa1-2edf-4476-bdd6-9dd0b4dddc7b -AttackSurfaceReductionRules_Actions Enabled

# 阻止从邮件客户端和 Webmail 执行可执行内容
Add-MpPreference -AttackSurfaceReductionRules_Ids be9ba2d9-53ea-4cdc-84e5-9b1eeee46550 -AttackSurfaceReductionRules_Actions Enabled

# 阻止来自 USB 的不受信任和未签名进程运行
Add-MpPreference -AttackSurfaceReductionRules_Ids b2b3f03d-6a65-4f7b-a9c7-1c7ef74a9ba4 -AttackSurfaceReductionRules_Actions Enabled

# 阻止从 Windows 本地安全授权子系统窃取凭据 (lsass.exe)
Add-MpPreference -AttackSurfaceReductionRules_Ids 9e6c4e1f-7d60-472f-ba1a-a39ef669e4b2 -AttackSurfaceReductionRules_Actions Enabled

# 阻止通过 WMI 事件订阅实现持久化
Add-MpPreference -AttackSurfaceReductionRules_Ids e6db77e5-3df2-4cf1-b95a-636979351e5b -AttackSurfaceReductionRules_Actions Enabled

# 阻止 Adobe Reader 创建子进程
Add-MpPreference -AttackSurfaceReductionRules_Ids 7674ba52-37eb-4a4f-a9a1-f0f9a1619a2c -AttackSurfaceReductionRules_Actions Enabled

# 阻止 Office 通信应用创建子进程
Add-MpPreference -AttackSurfaceReductionRules_Ids 26190899-1602-49e8-8b27-eb1d0a1ce869 -AttackSurfaceReductionRules_Actions Enabled

# 使用高级勒索软件防护
Add-MpPreference -AttackSurfaceReductionRules_Ids c1db55ab-c21a-4637-bb3f-a12568109d35 -AttackSurfaceReductionRules_Actions Enabled

# 阻止滥用被利用的易受攻击签名驱动程序
Add-MpPreference -AttackSurfaceReductionRules_Ids 56a863a9-875e-4185-98a7-b882c64b5ce5 -AttackSurfaceReductionRules_Actions Enabled

# 阻止使用复制或冒充的系统工具
Add-MpPreference -AttackSurfaceReductionRules_Ids c0033c00-d16d-4114-a5a0-dc9b3a7d2ceb -AttackSurfaceReductionRules_Actions Enabled

1.2 验证 ASR 规则状态

Get-MpPreference | Select-Object AttackSurfaceReductionRules_Ids, AttackSurfaceReductionRules_Actions

在监控方面,打开事件查看器 → 应用程序和服务日志 → Microsoft → Windows → Windows Defender → Operational,筛选事件 ID 1121(阻止模式)、1122(审计模式)和 5007(设置更改)。

1.3 通过组策略配置 ASR(替代方法)

策略路径:Windows 组件 → Microsoft Defender 防病毒 → Microsoft Defender Exploit Guard → 攻击面减少。策略设置名称:配置攻击面减少规则。

在本地组策略编辑器(gpedit.msc)中导航至上述路径,启用该策略并添加规则 GUID 及其对应值:

  • 1 = 阻止
  • 2 = 审计
  • 6 = 警告

第二章:禁用不安全的遗留协议

2.1 禁用 LLMNR(Link-Local Multicast Name Resolution)

默认情况下,Windows 附带不安全的遗留协议如 LLMNR 和 NetBIOS 已启用。这些协议可能在网络上泄露用户名和密码哈希,经常被 Responder 等工具滥用。禁用它们可显著减少攻击面。

广播协议 NetBIOS over TCP/IP、LLMNR 和 mDNS (Multicast DNS) 用于在没有 DNS 服务器的 Windows 网络中解析名称。这些协议在具有 DNS 服务器的企业网络中通常不需要。此外,这些广播协议不安全,攻击者可轻松利用它们实施欺骗、中继和中间人攻击,在本地子网拦截用户凭据(包括 NTLM 哈希)。

方法一:通过组策略禁用 LLMNR

在 Active Directory 环境中,可使用组策略禁用域计算机和服务器上的 LLMNR 广播。打开 gpmc.msc,创建新 GPO 或编辑应用于所有工作站和服务器的现有 GPO。转到计算机配置 → 管理模板 → 网络 → DNS 客户端;启用”关闭多播名称解析”和”关闭智能多宿主名称解析”策略。

对于家用电脑,使用本地组策略编辑器(gpedit.msc):

计算机配置 → 管理模板 → 网络 → DNS 客户端
启用:Turn off multicast name resolution
启用:Turn off smart multi-homed name resolution

方法二:通过注册表禁用 LLMNR

# 创建注册表项(如果不存在)
New-Item -Path "HKLM:\SOFTWARE\Policies\Microsoft\Windows NT\DNSClient" -Force
Set-ItemProperty -Path "HKLM:\SOFTWARE\Policies\Microsoft\Windows NT\DNSClient" -Name "EnableMulticast" -Value 0 -Type DWord

2.2 禁用 NetBIOS over TCP/IP

NetBIOS over TCP/IP 为多种入侵方法提供便利。为降低此风险,应为所有网络接口禁用 NetBIOS over TCP/IP。由于 NetBIOS over TCP/IP 仅用于支持 Windows 2000 之前的遗留 Microsoft Windows 操作系统,不应有业务需求继续使用它。

通过 PowerShell 禁用所有网络适配器的 NetBIOS:

# 禁用所有网络接口的 NetBIOS over TCP/IP
$key = 'HKLM:\SYSTEM\CurrentControlSet\services\NetBT\Parameters\Interfaces'
Get-ChildItem $key | ForEach-Object {
    Set-ItemProperty -Path "$key\$($_.PSChildName)" -Name NetbiosOptions -Value 2
}

检查注册表键 HKEY_LOCAL_MACHINE\System\CurrentControlSet\Services\NetBT\Parameters\Interfaces,找到每个网络接口的 GUID,将 NetbiosOptions 设为 0 的改为 2。这相当于在网络适配器设置 GUI(WINS 选项卡)中禁用 NetBIOS。

验证是否已禁用:

wmic nicconfig get caption,index,TcpipNetbiosOptions

2.3 禁用 SMBv1

SMBv1 存在严重的安全漏洞,强烈建议不要使用它。SMBv1 在 Windows 11 或 Windows Server 2019 及更高版本的任何版本中默认不安装。Windows 10 也默认不安装 SMBv1(家庭版和专业版除外)。

通过 PowerShell 禁用 SMBv1:

# 检查 SMBv1 状态
Get-SmbServerConfiguration | Select EnableSMB1Protocol

# 禁用 SMBv1
Set-SmbServerConfiguration -EnableSMB1Protocol $false -Force

# 通过 Windows 功能完全禁用
Disable-WindowsOptionalFeature -Online -FeatureName SMB1Protocol -NoRestart

在 Windows 8.1、Windows 10 和 Windows 11 上,可以使用”程序和功能”禁用 SMBv1。在控制面板中,选择”程序和功能”。在控制面板主页下,选择”启用或关闭 Windows 功能”以打开 Windows 功能对话框。在 Windows 功能对话框中,向下滚动列表,清除”SMB 1.0/CIFS 文件共享支持”的复选框,然后选择确定。

2.4 禁用 mDNS(可选)

Multicast DNS (mDNS) 网络协议从 Windows 10 version 1703 和 Windows Server 2019 开始可用。它允许在不使用中央 DNS 服务器的情况下在小型本地网络中解析主机名到 IP 地址。

# 通过注册表禁用 mDNS
Set-ItemProperty -Path "HKLM:\SYSTEM\CurrentControlSet\Services\Dnscache\Parameters" -Name "EnableMDNS" -Value 0 -Type DWord

禁用 MDNS 可能会产生影响——主要是服务/设备发现。工作站可能无法找到无线屏幕镜像设备(如 Chromecast、打印机和其他依赖 MDNS 的设备)。如果这是需求,请仔细测试 MDNS 注册表键!


第三章:凭据保护——阻止 Mimikatz 等工具

3.1 启用 LSA 保护(RunAsPPL)

LSA 保护是一项安全功能,通过阻止不受信任的 LSA 代码注入和进程内存转储来防御敏感信息(如凭据)被盗。LSA 保护在后台运行,通过将 LSA 进程隔离在容器中,防止其他进程(如恶意行为者或应用)访问该功能。这种隔离使 LSA 保护成为至关重要的安全功能,因此在 Windows 11 中默认启用。

RunAsPPL for LSASS 是一个真正的快速胜利。它非常容易配置,因为你只需要在注册表中添加一个简单的值并重启。像任何其他保护一样,它不是万无一失的,单独使用也不够,但它仍然特别有效。如果攻击者想要绑过它,他们将不得不使用一些相对高级的技巧,这最终增加了他们被检测到的机会。

通过注册表启用 LSA 保护:

在注册表编辑器的左侧窗格中,按照此路径:HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Lsa。双击 RunAsPPL 并将其值更改为 1(启用 LSA 保护)或 0(禁用)。你还可以选择将 RunAsPPLBoot 的值更改为 1 以确保 LSA 在启动时受到保护。

# 启用 LSA 保护
New-ItemProperty -Path "HKLM:\SYSTEM\CurrentControlSet\Control\Lsa" -Name "RunAsPPL" -Value 1 -PropertyType DWORD -Force

# 确保启动时也启用保护
New-ItemProperty -Path "HKLM:\SYSTEM\CurrentControlSet\Control\Lsa" -Name "RunAsPPLBoot" -Value 1 -PropertyType DWORD -Force

重启后生效。

3.2 启用 Credential Guard

Credential Guard 通过保护 NTLM 密码哈希、Kerberos 票据授予票据 (TGT) 和应用程序存储的域凭据来防止凭据盗窃攻击。Credential Guard 使用基于虚拟化的安全 (VBS) 隔离机密,因此只有特权系统软件才能访问它们。未经授权访问这些机密可能导致凭据盗窃攻击,如传递哈希和传递票据。启用后,Credential Guard 提供以下好处:硬件安全、基于虚拟化的安全。

针对高级持续性威胁的保护:当凭据使用 VBS 保护时,许多定向攻击中使用的凭据盗窃攻击技术和工具会被阻止。在操作系统中以管理员权限运行的恶意软件无法提取 VBS 保护的机密。

从 Windows 11 22H2 和 Windows Server 2025 开始,Credential Guard 在符合要求的设备上默认启用。系统管理员可以使用本文所述的方法之一显式启用或禁用 Credential Guard。

检查 Credential Guard 状态:

# 检查 LsaCfgFlags 值
reg query HKLM\System\CurrentControlSet\Control\LSA /v LsaCfgFlags

# 使用系统信息检查
Get-CimInstance Win32_DeviceGuard -Namespace root\Microsoft\Windows\DeviceGuard | Select *

值为”1″表示使用 UEFI 锁定激活,”2″表示无锁定,”0″表示未启用。此注册表检查虽然是一个强指标,但不是启用 Credential Guard 的唯一步骤。

通过注册表手动启用 Credential Guard:

通过编程方式更改注册表值启用 Credential Guard:

Set-ItemProperty -Path "HKLM:\SYSTEM\CurrentControlSet\Control\Lsa" -Name "LsaCfgFlags" -Value 1

通过编程方式更改注册表值启用 LSA 保护:

New-ItemProperty -Path "HKLM:\SYSTEM\CurrentControlSet\Control\Lsa" -Name "RunAsPPL" -Value 1 -PropertyType DWORD -Force

你需要重启 Windows 10 或 Windows 11 设备以应用这些更改。

完整的 Credential Guard 启用命令:

# 启用基于虚拟化的安全
reg add "HKLM\SYSTEM\CurrentControlSet\Control\DeviceGuard" /v EnableVirtualizationBasedSecurity /t REG_DWORD /d 1 /f

# 设置平台安全功能要求
reg add "HKLM\SYSTEM\CurrentControlSet\Control\DeviceGuard" /v RequirePlatformSecurityFeatures /t REG_DWORD /d 1 /f

# 启用 Credential Guard
reg add "HKLM\SYSTEM\CurrentControlSet\Control\Lsa" /v LsaCfgFlags /t REG_DWORD /d 1 /f

如果已启用 LSA 保护,则不需要此攻击面减少规则。为了更安全的态势,还建议在启用 LSA 保护的同时启用 Credential Guard。

3.3 禁用 WDigest 身份验证

WDigest 协议在 Windows XP 中引入,旨在通过 HTTP 协议进行身份验证,在 Windows XP 到 Windows 8.0 和 Windows Server 2003 到 Windows Server 2012 中默认启用。此默认设置导致明文密码存储在 LSASS(本地安全授权子系统服务)中。攻击者可以使用 Mimikatz 提取这些凭据。

# 禁用 WDigest(确保不以明文存储凭据)
Set-ItemProperty -Path "HKLM:\SYSTEM\CurrentControlSet\Control\SecurityProviders\WDigest" -Name "UseLogonCredential" -Value 0 -Type DWord
Set-ItemProperty -Path "HKLM:\SYSTEM\CurrentControlSet\Control\SecurityProviders\WDigest" -Name "Negotiate" -Value 0 -Type DWord

第四章:PowerShell 安全强化

4.1 启用 PowerShell 约束语言模式

PowerShell 约束语言是 PowerShell 的一种语言模式,旨在支持日常管理任务,同时限制对可用于调用任意 Windows API 的敏感语言元素的访问。

约束语言模式是 PowerShell 中的一种设置,大大限制了可以执行的命令。这可以潜在地减少对手的可用攻击面。默认情况下,PowerShell 以完整语言模式运行,所有函数都可用。这包括访问所有语言元素、cmdlet 和模块,以及文件系统和网络。

在本地计算机上严格执行约束语言模式需要使用软件执行限制,如 AppLocker 或 Windows Defender 应用程序控制。但在远程会话中,可以通过会话配置强制执行。从版本 5 开始,PowerShell 会根据脚本规则自动识别是否应切换到约束语言模式。

通过环境变量启用(系统范围):

# 设置 PSLockdownPolicy 环境变量
[Environment]::SetEnvironmentVariable('__PSLockdownPolicy', '4', 'Machine')

约束语言模式 (CLM) 是一项 PowerShell 安全功能,限制某些功能的执行,如自定义 .NET 方法、COM 对象和动态类型。AppLocker 或 Windows Defender 应用程序控制 (WDAC) 等安全策略通常强制执行 CLM,以限制未经授权或恶意脚本带来的风险。

重要提示: 无论你选择环境变量、AppLocker 还是软件限制策略,都需要从要强制执行约束语言模式的计算机上移除 PowerShell 2.0。PowerShell 2.0 从 Windows 8 和 Server 2012 开始是可选功能,默认启用。约束语言模式是在 PowerShell 3.0 中引入的,黑客可以通过切换到旧版本轻松绑过它。

# 禁用 PowerShell 2.0
Disable-WindowsOptionalFeature -Online -FeatureName MicrosoftWindowsPowerShellV2Root -NoRestart
Disable-WindowsOptionalFeature -Online -FeatureName MicrosoftWindowsPowerShellV2 -NoRestart

4.2 启用 PowerShell 脚本块日志记录

计算机配置 → 管理模板 → Windows 组件 → Windows PowerShell
启用:Turn on PowerShell Script Block Logging
启用:Turn on PowerShell Transcription(设置输出目录)
启用:Turn on Module Logging

或通过注册表:

# 启用脚本块日志记录
New-Item -Path "HKLM:\SOFTWARE\Wow6432Node\Policies\Microsoft\Windows\PowerShell\ScriptBlockLogging" -Force
Set-ItemProperty -Path "HKLM:\SOFTWARE\Wow6432Node\Policies\Microsoft\Windows\PowerShell\ScriptBlockLogging" -Name "EnableScriptBlockLogging" -Value 1

# 启用转录
New-Item -Path "HKLM:\SOFTWARE\Wow6432Node\Policies\Microsoft\Windows\PowerShell\Transcription" -Force
Set-ItemProperty -Path "HKLM:\SOFTWARE\Wow6432Node\Policies\Microsoft\Windows\PowerShell\Transcription" -Name "EnableTranscripting" -Value 1
Set-ItemProperty -Path "HKLM:\SOFTWARE\Wow6432Node\Policies\Microsoft\Windows\PowerShell\Transcription" -Name "OutputDirectory" -Value "C:\PSTranscripts"

第五章:核心隔离与内存完整性

5.1 启用内存完整性(HVCI)

内存完整性是基于虚拟化的安全 (VBS) 的关键组件:

# 通过注册表启用内存完整性
reg add "HKLM\SYSTEM\CurrentControlSet\Control\DeviceGuard\Scenarios\HypervisorEnforcedCodeIntegrity" /v Enabled /t REG_DWORD /d 1 /f

或通过 Windows 安全中心:

  • 设置 → 隐私和安全 → Windows 安全中心 → 设备安全 → 核心隔离详细信息 → 内存完整性:开启

5.2 启用内核 DMA 保护

在支持的硬件上,启用 Kernel DMA Protection 防止通过 Thunderbolt 等端口的 DMA 攻击:

# 检查 DMA 保护状态
Get-SystemDriver | Where {$_.DeviceType -eq "DMA"} | Select Name, Status

5.3 启用 Microsoft 易受攻击驱动程序阻止列表

对于 Windows 11 或更高版本以及 Windows Server core 1809 或更高版本或 Windows Server 2019 或更高版本,还应启用 Microsoft Windows 易受攻击驱动程序阻止列表。

# 启用易受攻击驱动程序阻止列表
reg add "HKLM\SYSTEM\CurrentControlSet\Control\CI\Config" /v VulnerableDriverBlocklistEnable /t REG_DWORD /d 1 /f

第六章:账户与权限强化

6.1 创建标准用户账户

创建不同的管理员账户,并将当前账户转换为受限/标准用户账户,可极大减少攻击面。不要使用管理员权限执行日常任务!

# 创建新管理员账户
net user SecureAdmin P@ssw0rd123! /add
net localgroup Administrators SecureAdmin /add

# 将现有账户降级为标准用户
net localgroup Administrators YourCurrentUsername /delete

6.2 配置本地管理员密码解决方案(LAPS)

即使内置管理员账户具有唯一名称和唯一密码,恶意行为者仍可以根据其安全标识符(即 S-1-5-21-domain-500)识别这些账户,并利用此信息在获得 SAM 数据库访问权限时集中暴力破解工作站上的凭据。为降低此风险,需要使用 Microsoft 的本地管理员密码解决方案 (LAPS) 确保每个工作站使用唯一密码。

Windows 11 22H2 及更高版本已内置 Windows LAPS:

# 检查 LAPS 状态
Get-Command *LAPS*

# 配置本地 LAPS(非域环境)
Set-ItemProperty -Path "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\LAPS\Config" -Name "BackupDirectory" -Value 1

6.3 提升 UAC 到最高级别

了解为什么 UAC 在最高级别(而不是默认级别)很重要。

# 设置 UAC 为最高级别(始终通知)
Set-ItemProperty -Path "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\System" -Name "ConsentPromptBehaviorAdmin" -Value 2
Set-ItemProperty -Path "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\System" -Name "PromptOnSecureDesktop" -Value 1
Set-ItemProperty -Path "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\System" -Name "EnableLUA" -Value 1

6.4 禁用内置 Administrator 账户

# 禁用内置 Administrator
net user Administrator /active:no

# 重命名 Guest 账户(如果存在)
wmic useraccount where "name='Guest'" rename "DisabledGuest"
net user DisabledGuest /active:no

第七章:远程访问安全

7.1 禁用远程桌面(如非必要)

# 禁用远程桌面
Set-ItemProperty -Path "HKLM:\SYSTEM\CurrentControlSet\Control\Terminal Server" -Name "fDenyTSConnections" -Value 1

# 禁用远程协助
Set-ItemProperty -Path "HKLM:\SYSTEM\CurrentControlSet\Control\Remote Assistance" -Name "fAllowToGetHelp" -Value 0

7.2 如果必须启用远程桌面

# 启用网络级别身份验证 (NLA)
Set-ItemProperty -Path "HKLM:\SYSTEM\CurrentControlSet\Control\Terminal Server\WinStations\RDP-Tcp" -Name "UserAuthentication" -Value 1

# 限制可远程登录的用户组
# 通过 gpedit.msc:
# 计算机配置 → Windows 设置 → 安全设置 → 本地策略 → 用户权限分配
# "允许通过远程桌面服务登录" - 仅添加必要的用户/组

7.3 禁用远程注册表服务

# 停止并禁用远程注册表服务
Stop-Service RemoteRegistry -Force
Set-Service RemoteRegistry -StartupType Disabled

7.4 配置 Windows 防火墙阻止入站连接

# 将所有配置文件设置为阻止入站连接
Set-NetFirewallProfile -Profile Domain,Public,Private -DefaultInboundAction Block -DefaultOutboundAction Allow

# 禁用不需要的入站规则
Get-NetFirewallRule -Direction Inbound | Where-Object {$_.Enabled -eq 'True' -and $_.Action -eq 'Allow'} | Select Name, DisplayName | Format-Table

# 禁用特定危险规则(根据需要)
Disable-NetFirewallRule -DisplayName "Windows Remote Management (HTTP-In)"
Disable-NetFirewallRule -DisplayName "Remote Desktop - User Mode (TCP-In)"

第八章:服务与功能精简

8.1 禁用不必要的服务

# 禁用 Xbox 相关服务
Stop-Service XblAuthManager -Force -ErrorAction SilentlyContinue
Stop-Service XblGameSave -Force -ErrorAction SilentlyContinue
Stop-Service XboxGipSvc -Force -ErrorAction SilentlyContinue
Stop-Service XboxNetApiSvc -Force -ErrorAction SilentlyContinue
Set-Service XblAuthManager -StartupType Disabled -ErrorAction SilentlyContinue
Set-Service XblGameSave -StartupType Disabled -ErrorAction SilentlyContinue
Set-Service XboxGipSvc -StartupType Disabled -ErrorAction SilentlyContinue
Set-Service XboxNetApiSvc -StartupType Disabled -ErrorAction SilentlyContinue

# 禁用打印后台处理程序(如不需要打印)
Stop-Service Spooler -Force
Set-Service Spooler -StartupType Disabled

# 禁用 Windows 搜索索引(可选,会影响搜索速度)
Stop-Service WSearch -Force
Set-Service WSearch -StartupType Disabled

# 禁用 Fax 服务
Stop-Service Fax -Force -ErrorAction SilentlyContinue
Set-Service Fax -StartupType Disabled -ErrorAction SilentlyContinue

8.2 移除不必要的 Windows 功能

# 列出可选功能
Get-WindowsOptionalFeature -Online | Select FeatureName, State | Sort FeatureName

# 禁用 Internet Explorer 模式(如不需要)
Disable-WindowsOptionalFeature -Online -FeatureName Internet-Explorer-Optional-amd64 -NoRestart

# 禁用 Windows Media Player
Disable-WindowsOptionalFeature -Online -FeatureName WindowsMediaPlayer -NoRestart

# 禁用工作文件夹客户端
Disable-WindowsOptionalFeature -Online -FeatureName WorkFolders-Client -NoRestart

8.3 禁用 Windows Sandbox 和 Hyper-V(如非必要)

如果不需要虚拟化功能:

# 禁用 Hyper-V
Disable-WindowsOptionalFeature -Online -FeatureName Microsoft-Hyper-V-All -NoRestart

# 禁用 Windows Sandbox
Disable-WindowsOptionalFeature -Online -FeatureName Containers-DisposableClientVM -NoRestart

注意: 禁用 Hyper-V 会影响 Credential Guard 和内存完整性等依赖 VBS 的安全功能。请根据实际安全需求权衡。


第九章:受控文件夹访问(勒索软件防护)

受控文件夹访问是 Microsoft Windows 11 的一项安全功能,属于 Microsoft Defender Exploit Guard 的一部分。它旨在对抗勒索软件威胁。为使用受控文件夹访问,必须将 Microsoft Defender Antivirus 配置为工作站上的主要实时杀毒扫描引擎。

9.1 启用受控文件夹访问

# 启用受控文件夹访问
Set-MpPreference -EnableControlledFolderAccess Enabled

# 添加受保护的文件夹
Add-MpPreference -ControlledFolderAccessProtectedFolders "D:\ImportantData"
Add-MpPreference -ControlledFolderAccessProtectedFolders "E:\WorkFiles"

# 允许特定应用访问受保护文件夹
Add-MpPreference -ControlledFolderAccessAllowedApplications "C:\Program Files\TrustedApp\app.exe"

9.2 通过组策略配置

计算机配置 → 管理模板 → Windows 组件 → Microsoft Defender 防病毒 → Microsoft Defender Exploit Guard → 受控文件夹访问
启用:配置受控文件夹访问 → 设为"启用"

第十章:BitLocker 全盘加密

启用 BitLocker 加密配合 TPM,可选配启动 PIN 码,并了解减少 DMA 威胁的对策。

10.1 启用 BitLocker 并配置启动 PIN

# 检查 TPM 状态
Get-Tpm

# 启用 BitLocker 并设置启动 PIN(更安全)
Enable-BitLocker -MountPoint "C:" -EncryptionMethod XtsAes256 -UsedSpaceOnly -Pin (ConvertTo-SecureString "YourPIN" -AsPlainText -Force) -TPMandPinProtector

# 或仅使用 TPM(较方便但略不安全)
Enable-BitLocker -MountPoint "C:" -EncryptionMethod XtsAes256 -UsedSpaceOnly -TpmProtector

# 备份恢复密钥到文件
(Get-BitLockerVolume -MountPoint "C:").KeyProtector | Where-Object {$_.KeyProtectorType -eq 'RecoveryPassword'} | Select -ExpandProperty RecoveryPassword | Out-File "D:\BitLockerRecoveryKey.txt"

10.2 为额外驱动器启用 BitLocker

# 为数据驱动器启用 BitLocker
Enable-BitLocker -MountPoint "D:" -EncryptionMethod XtsAes256 -UsedSpaceOnly -Password (ConvertTo-SecureString "YourStrongPassword" -AsPlainText -Force) -PasswordProtector

第十一章:高级组策略设置

11.1 禁用缓存登录凭据

计算机配置 → Windows 设置 → 安全设置 → 本地策略 → 安全选项
"交互式登录: 之前登录到缓存的次数" → 设为 0 或 1

11.2 配置账户锁定策略

计算机配置 → Windows 设置 → 安全设置 → 账户策略 → 账户锁定策略
"账户锁定阈值" → 5 次无效登录
"账户锁定时间" → 30 分钟
"重置账户锁定计数器" → 30 分钟

11.3 禁用 LAN Manager 哈希存储

如果运行较旧的林功能级别,LMhash 是一种较旧的哈希,容易被破解,存储 AD 凭据,可使用组策略关闭。在组策略中,展开计算机配置 → Windows 设置 → 安全设置 → 本地策略 → 安全选项 → 网络安全: 不存储下次密码更改时的 LAN Manager 哈希值。

计算机配置 → Windows 设置 → 安全设置 → 本地策略 → 安全选项
"网络安全: 不存储 LAN Manager 哈希值在下一次密码更改时" → 启用
"网络安全: LAN Manager 身份验证级别" → 仅发送 NTLMv2 响应,拒绝 LM & NTLM

11.4 启用 SMB 签名

“SMB 签名不是必需的”在大多数漏洞扫描中可能只显示为中等严重性发现,但在适当的情况下,它可能相当有影响力。

# 启用并要求 SMB 签名
Set-SmbServerConfiguration -RequireSecuritySignature $true -Force
Set-SmbClientConfiguration -RequireSecuritySignature $true -Force

第十二章:安全 DNS 配置

虽然 DNS 加密并不完美,但 Quad9 和 Cloudflare 都值得推荐。

12.1 配置 DoH(DNS over HTTPS)

# 为以太网适配器配置 DNS over HTTPS
Set-DnsClientServerAddress -InterfaceAlias "Ethernet" -ServerAddresses ("9.9.9.9", "149.112.112.112")

# 通过注册表启用 DoH
$dohServers = @{
    "9.9.9.9" = "https://dns.quad9.net/dns-query"
    "149.112.112.112" = "https://dns.quad9.net/dns-query"
    "1.1.1.1" = "https://cloudflare-dns.com/dns-query"
    "1.0.0.1" = "https://cloudflare-dns.com/dns-query"
}

# 配置 DoH 自动升级(Windows 11)
Set-DnsClientDohServerAddress -ServerAddress "9.9.9.9" -DohTemplate "https://dns.quad9.net/dns-query" -AllowFallbackToUdp $false -AutoUpgrade $true

第十三章:自动化强化脚本

Hard_Configurator 是一个 GUI 应用程序,用于配置各种 Windows 安全功能并应用推荐的默认值。Harden-Windows-Security 提供更多强化功能且维护更好。

使用官方支持的 Microsoft 方法和适当的解释安全地强化 Windows | 始终保持最新并与最新版本的 Windows 兼容 | 为个人、企业、政府和军事安全级别提供工具和指南 | SLSA Level 3 合规的安全开发和构建过程。

13.1 推荐的自动化工具

  1. Harden-Windows-Security(GitHub 项目)
  • 提供 PowerShell 模块自动应用微软官方推荐的安全设置
  • 支持多种安全级别配置
  1. Microsoft Security Compliance Toolkit
  • MS Security Guide 组策略设置作为 Microsoft Security Compliance Toolkit 的一部分提供。
  1. CIS Benchmarks
  • 系统强化有各种经过行业测试的标准,如 Microsoft Security Baselines、DISA STIGs 和 CIS Benchmarks。

13.2 综合强化脚本示例

以下脚本整合本文关键设置(以管理员权限运行):

#Requires -RunAsAdministrator

Write-Host "=== Windows 11 系统强化脚本 ===" -ForegroundColor Cyan

# 1. 禁用 SMBv1
Write-Host "[1] 禁用 SMBv1..." -ForegroundColor Yellow
Set-SmbServerConfiguration -EnableSMB1Protocol $false -Force

# 2. 禁用 LLMNR
Write-Host "[2] 禁用 LLMNR..." -ForegroundColor Yellow
New-Item -Path "HKLM:\SOFTWARE\Policies\Microsoft\Windows NT\DNSClient" -Force | Out-Null
Set-ItemProperty -Path "HKLM:\SOFTWARE\Policies\Microsoft\Windows NT\DNSClient" -Name "EnableMulticast" -Value 0 -Type DWord

# 3. 禁用 NetBIOS
Write-Host "[3] 禁用 NetBIOS..." -ForegroundColor Yellow
$key = 'HKLM:\SYSTEM\CurrentControlSet\services\NetBT\Parameters\Interfaces'
Get-ChildItem $key | ForEach-Object {
    Set-ItemProperty -Path "$key\$($_.PSChildName)" -Name NetbiosOptions -Value 2
}

# 4. 启用 LSA 保护
Write-Host "[4] 启用 LSA 保护..." -ForegroundColor Yellow
Set-ItemProperty -Path "HKLM:\SYSTEM\CurrentControlSet\Control\Lsa" -Name "RunAsPPL" -Value 1 -Type DWord

# 5. 禁用 WDigest
Write-Host "[5] 禁用 WDigest..." -ForegroundColor Yellow
Set-ItemProperty -Path "HKLM:\SYSTEM\CurrentControlSet\Control\SecurityProviders\WDigest" -Name "UseLogonCredential" -Value 0 -Type DWord

# 6. 启用 ASR 规则
Write-Host "[6] 启用关键 ASR 规则..." -ForegroundColor Yellow
$asrRules = @(
    "3b576869-a4ec-4529-8536-b80a7769e899",  # Block Office apps from creating executable content
    "75668c1f-73b5-4cf0-bb93-3ecf5cb7cc84",  # Block Office apps from injecting code
    "d3e037e1-3eb8-44c8-a917-57927947596d",  # Block JavaScript/VBScript from launching executables
    "5beb7efe-fd9a-4556-801d-275e5ffc04cc",  # Block obfuscated scripts
    "9e6c4e1f-7d60-472f-ba1a-a39ef669e4b2",  # Block credential stealing from LSASS
    "be9ba2d9-53ea-4cdc-84e5-9b1eeee46550",  # Block executable content from email
    "b2b3f03d-6a65-4f7b-a9c7-1c7ef74a9ba4",  # Block untrusted processes from USB
    "c1db55ab-c21a-4637-bb3f-a12568109d35"   # Advanced ransomware protection
)
foreach ($rule in $asrRules) {
    Add-MpPreference -AttackSurfaceReductionRules_Ids $rule -AttackSurfaceReductionRules_Actions Enabled
}

# 7. 启用受控文件夹访问
Write-Host "[7] 启用受控文件夹访问..." -ForegroundColor Yellow
Set-MpPreference -EnableControlledFolderAccess Enabled

# 8. 禁用远程桌面
Write-Host "[8] 禁用远程桌面..." -ForegroundColor Yellow
Set-ItemProperty -Path "HKLM:\SYSTEM\CurrentControlSet\Control\Terminal Server" -Name "fDenyTSConnections" -Value 1

# 9. 禁用远程注册表
Write-Host "[9] 禁用远程注册表服务..." -ForegroundColor Yellow
Stop-Service RemoteRegistry -Force -ErrorAction SilentlyContinue
Set-Service RemoteRegistry -StartupType Disabled

# 10. 提升 UAC 级别
Write-Host "[10] 提升 UAC 到最高级别..." -ForegroundColor Yellow
Set-ItemProperty -Path "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\System" -Name "ConsentPromptBehaviorAdmin" -Value 2
Set-ItemProperty -Path "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\System" -Name "PromptOnSecureDesktop" -Value 1

# 11. 禁用 PowerShell 2.0
Write-Host "[11] 禁用 PowerShell 2.0..." -ForegroundColor Yellow
Disable-WindowsOptionalFeature -Online -FeatureName MicrosoftWindowsPowerShellV2Root -NoRestart -ErrorAction SilentlyContinue

# 12. 配置防火墙
Write-Host "[12] 配置 Windows 防火墙..." -ForegroundColor Yellow
Set-NetFirewallProfile -Profile Domain,Public,Private -DefaultInboundAction Block -DefaultOutboundAction Allow

Write-Host ""
Write-Host "=== 强化完成 ===" -ForegroundColor Green
Write-Host "重要:请重启计算机以使所有更改生效。" -ForegroundColor Red
Write-Host "建议重启后验证所有设置是否正确应用。" -ForegroundColor Yellow

第十四章:验证与监控

14.1 验证安全配置

# 检查 ASR 规则状态
Get-MpPreference | Select-Object AttackSurfaceReductionRules_Ids, AttackSurfaceReductionRules_Actions

# 检查 LSA 保护状态
Get-ItemProperty -Path "HKLM:\SYSTEM\CurrentControlSet\Control\Lsa" -Name "RunAsPPL"

# 检查 Credential Guard 状态
Get-CimInstance -ClassName Win32_DeviceGuard -Namespace root\Microsoft\Windows\DeviceGuard

# 检查 SMBv1 状态
Get-SmbServerConfiguration | Select EnableSMB1Protocol

# 检查内存完整性状态
Get-CimInstance -Namespace root/Microsoft/Windows/DeviceGuard -ClassName Win32_DeviceGuard | Select VirtualizationBasedSecurityStatus

14.2 关键事件日志监控

监控以下事件日志检测潜在威胁:

# 查看安全相关事件
Get-WinEvent -LogName Security -MaxEvents 50 | Where-Object {$_.Id -in @(4624, 4625, 4648, 4672, 4688)} | Format-Table TimeCreated, Id, Message -Wrap

# 查看 PowerShell 脚本块日志
Get-WinEvent -LogName "Microsoft-Windows-PowerShell/Operational" -MaxEvents 50 | Format-Table TimeCreated, Message -Wrap

# 查看 ASR 规则触发事件
Get-WinEvent -LogName "Microsoft-Windows-Windows Defender/Operational" | Where-Object {$_.Id -in @(1121, 1122)} | Format-Table TimeCreated, Message -Wrap

结论

2025 年的 Windows 11 强化不是一次性任务,而是一个持续的过程。通过应用这些调整,可显著降低风险并符合行业最佳实践。

本文涵盖的配置远超普通安全指南,包括:

  1. 攻击面减少规则——企业级恶意行为防护
  2. 遗留协议禁用——消除 LLMNR/NetBIOS/SMBv1 攻击向量
  3. 凭据保护——LSA 保护、Credential Guard、WDigest 禁用
  4. PowerShell 强化——约束语言模式、日志记录、版本控制
  5. 内核级保护——内存完整性、DMA 保护、易受攻击驱动程序阻止
  6. 账户安全——最小权限、UAC 最高级别、LAPS
  7. 网络安全——防火墙强化、SMB 签名、远程服务禁用

然而,请始终铭记:没有任何配置能使闭源系统达到开源系统的可验证安全性。如果你的威胁模型包含国家级对手,应认真考虑迁移至经过强化的 Linux 发行版。Windows 强化应被视为缓解措施而非根本解决方案

为了你自身的安全,在考虑任何其他声称强化或修改 Windows OS 的第三方工具、程序或脚本时要谨慎。在使用前和每次发布后彻底验证其合法性。避免盲目信任第三方互联网来源。此外,如果它们不遵守与本指南相同的高标准,可能会导致系统损坏、未知问题和错误。