一、漏洞描述
微软披露最新的远程代码执行超高危漏洞CVE-2024-38077, CVSS评分高达9.8 ,可导致开启了远程桌面许可服务的Windwos服务器完全沦陷。漏洞影响Windows Server 2000到Windows Server 2025所有版本,已存在近30年。该漏洞可稳定利用、可远控、可勒索、可蠕虫等,破坏力极大,攻击者无须任何权限即可实现远程代码执行。
漏洞编码:CVE-2024-38077、CVE-2024-38077、Windows 内核权限提升漏洞:CVE-2024-38153、CNVD
漏洞类型:远程代码执行
影响范围:开启Windows Remote Desktop Licensing(RDL)Service 的Windows服务器,Windows Server 2000 - Windows Server 2025,具体如下:
Windows Serversion 2008 6.0.0 < version < 6.0.6003.22769
Windows Serversion 2008 R2 6.1.0 < version < 6.1.7601.27219
Windows Serversion 2012 6.2.0 < version < 6.2.9200.24975
Windows Serversion 2012 R2 6.3.0 < version < 6.3.9600.22074
Windows Serversion 2016 10.0.0 < version <10.0.14393.7159
Windows Serversion 2022 10.0.0 < version <10.0.20348.2582
开启该服务(Windows 远程桌面授权服务)并且操作系统版本在受影响范围的 Windows Server 受影响,没有开启该服务但是操作系统版本在受影响范围的Windows Server 不受影响,Windows 10、Windows 11 等非 Server 版本的操作系统,不论是否开启Windows 远程桌面(RDS),均不受影响。
综合风险评价:<利用难度>:容易;<威胁等级>:严重;高危漏洞
这一漏洞存在于Windows远程桌面许可管理服务(RDL)中,该服务被广泛部署于开启Windows远程桌面(3389端口)的服务器,用于管理远程桌面连接许可。攻击者无需任何前置条件,无需用户交互(零点击)便可直接获取服务器最高权限,执行任意操作。建议尽快通过官网公告更新安全补丁。深信服已率先提供解决方案,可通过相应产品进行防护。
二、漏洞复现及处理
2.1 漏洞复现
利用过程:Windows远程桌面许可服务在解码用户输入的许可密钥包时,会将用户输入的编码后的许可密钥包解码并存储到缓冲区上,但是在存储前没有正确地检验解码后数据长度与缓冲区大小之间的关系,导致缓冲区可以被超长的解码后数据溢出。攻击者可以利用这个漏洞进一步实现远程命令执行攻击。
2.2 漏洞排查
1)”Win+R”组合键调出“运行”,输入winver/systeminfo
后执行确定,检查对应系统版本是否在上文中提到的漏洞影响范围内。
2)在服务器管理-角色管理里确认如下远程桌面授权服务(Remote Desktop License
Service/RDL)没有被安装使用,且未启用即可,启用时RDL会监听随机高位
端口;安装完成后,服务 Name为“TermServLicensing”,Display Name 为“Remote Desktop Licensing”,如非必要可禁用该服务。
或者通过命令行powershell来查看:Get-WindowsFeature -Name RDS-Licensing
看到的状态为非installed且前面显示未选中,即当前未启用该功能,如下所示:
3)在“设置”-“更新与安全”-”Windows更新”-“更新历史”中检查是否存在以下表格中对应的系统补丁。现场为windows server2012 R2,如果存在以下补丁(KB5040569,内包括了 2024 年 6 月 11 日发布的更新KB5039294),则证明漏洞已修复。
漏洞补丁参考:
没有的手动下载KB5040569补丁包:
上述补丁包可替换如下:
2023-适用于 Windows Server 2012 R2 的 02 服务堆栈更新,适合基于 x64 的系统 (KB5022922)
Windows Server 2012 R2 更新程序 (KB3021910)
2022-适用于 Windows Server 2012 R2 的 05 服务堆栈更新,适合基于 x64 的系统 (KB5014025)
2022-适用于 Windows Server 2012 R2 的 04 服务堆栈更新,适合基于 x64 的系统 (KB5012672)
2022-适用于 Windows Server 2012 R2 的 07 服务堆栈更新,适合基于 x64 的系统 (KB5016264)
2020-适用于 Windows Server 2012 R2 的 07 服务堆栈更新,适合基于 x64 的系统 (KB4566425)
2022-适用于 Windows Server 2012 R2 的 10 服务堆栈更新,适合基于 x64 的系统 (KB5018922)
2021-适用于 Windows Server 2012 R2 的 04 服务堆栈更新,适合基于 x64 的系统 (KB5001403)
2023-适用于 Windows Server 2012 R2 的 03 服务堆栈更新,适合基于 x64 的系统 (KB5023790)
2023-适用于 Windows Server 2012 R2 的 08 服务堆栈更新,适合基于 x64 的系统 (KB5029368)
2023-适用于 Windows Server 2012 R2 的 09 服务堆栈更新,适合基于 x64 的系统 (KB5030329)
2024-适用于 Windows Server 2012 R2 的 02 服务堆栈更新,适合基于 x64 的系统 (KB5034866)
2024-适用于 Windows Server 2012 R2 的 03 服务堆栈更新,适合基于 x64 的系统 (KB5035968)
2024-适用于 Windows Server 2012 R2 的 01 服务堆栈更新,适合基于 x64 的系统 (KB5034587)
2023-适用于 Windows Server 2012 R2 的 06 服务堆栈更新,适合基于 x64 的系统 (KB5027574)
2023-适用于 Windows Server 2012 R2 的 11 服务堆栈更新,适合基于 x64 的系统 (KB5032308)
2024-适用于 Windows Server 2012 R2 的 06 服务堆栈更新,适合基于 x64 的系统 (KB5039340)
2019-适用于 Windows Server 2012 R2 的 09 服务堆栈更新,适合基于 x64 的系统 (KB4512938)
2024-适用于 Windows Server 2012 R2 的 04 服务堆栈更新,适合基于 x64 的系统 (KB5037021)
2019-适用于 Windows Server 2012 R2 的 11 服务堆栈更新,适合基于 x64 的系统 (KB4524445)
2020-适用于 Windows Server 2012 R2 的 03 服务堆栈更新,适合基于 x64 的系统 (KB4540725)
2019-适用于 Windows Server 2012 R2 的 10 服务堆栈更新,适合基于 x64 的系统 (KB4521864)
2020-适用于 Windows Server 2012 R2 的 06 服务堆栈更新,适合基于 x64 的系统 (KB4562253)
2019-适用于 Windows Server 2012 R2 的 07 服务堆栈更新,适合基于 x64 的系统 (KB4504418)
2022-适用于 Windows Server 2012 R2 的 09 服务堆栈更新,适合基于 x64 的系统 (KB5017398)
Windows Server 2012 R2 更新程序 (KB3173424)
安装此更新后,Windows Server 可能会影响整个组织的远程桌面连接。 如果在远程桌面网关中使用旧协议 (通过 HTTP) 进行远程过程调用,则可能会发生此问题。 因此,远程桌面连接可能会中断。此问题可能会间歇性发生,例如每 30 分钟重复一次。 在此时间间隔内,登录会话会丢失,用户需要重新连接到服务器。 IT 管理员可以将此跟踪为 TSGateway 服务的终止,该服务因异常代码 0xc0000005而无响应。可禁止通过管道进行连接,以及通过 RD 网关的端口 \pipe\RpcProxy\3388。或者,编辑客户端设备的注册表(HKEY_CURRENT_USER\Software\Microsoft\Terminal Server Client),并将 RDGClientTransport 的值设置为 0x00000000 (0)
现场看最新的是KB3118401,从官网查询确认后并非最新:
有小伙伴反馈,上述2012 R2更新会出现重启后回退安装失败的情况,请参照:Windows 更新挂起,重启后卸载新更新的方法排查,或查看windowsupdate。log
三、2024年8月近期其他windows漏洞
3.1、Windows TCP/IP 协议栈远程执行代码漏洞(CVE-2024-38063)
漏洞等级:高危
漏洞描述:Windows TCP/IP 协议栈存在整数溢出漏洞,该漏洞会影响 Windows TCP/IP 堆栈,允许未经身份验证的攻击者通过发送特制的 IPv6 数据包在目标系统上执行任意代码。对于启用了 IPv6 的 Windows 系统均受影响,由于 Windows 默认启用了 IPv6 协议栈支持;对于拥有公网 IPv6 地址的 Windows 系统受此漏洞影响,对于无公网 IPv6 地址但是拥有 IPv6 本地链接地址(以fe80::开头)也受影响。禁用 IPv6 的系统不受此漏洞的影响。
修复,官方已补发补丁,参看CVE-2024-38063,一般会出现在你的windows更新里,直接更新就行;安装此更新后,可能无法更改用户帐户个人资料图片,错误代码为 0x80070520。
3.2、windows更新补丁安装失败: Windows 安装下列更新失败,错误为 0x800F0840
0x800F0840错误代码,表示安装Windows更新时出现问题。这通常意味着更新包已损坏或与你的系统不兼容。此错误的一些可能原因是:
A faulty or outdated device driver
A malware infection or a virus
A damaged or missing system file
A network or firewall issue
A low disk space or memory
处理,更多参看::
- Run the Windows Update troubleshooter to diagnose and fix common problems with Windows Update1
- Download and install the update manually from the Microsoft Update Catalog
- Run the System File Checker (SFC) and the Deployment Image Servicing and Management (DISM) tools to scan and repair system files
- Update your device drivers to the latest version using Device Manager or a third-party tool
- Perform a clean boot to start Windows with a minimal set of drivers and services.
- Free up some disk space by deleting temporary files, uninstalling unused programs, or using Disk Cleanup.
- Increase your virtual memory by adjusting the paging file size.
升级完成效果如下,出现OS 内部版本 17763.6189即可:
3.3、对于windows server2012 R2修复漏洞CVE-2024-38153时报错不适用该版本
需要更新官方补丁之前,先更新你的操作系统安装最新的服务堆栈更新 (SSU) 。 因SU 提高了更新过程的可靠性,以缓解安装每月汇总并应用Microsoft安全修补程序时的潜在问题。下载 2024-适用于 Windows Server 2012 R2 的 08 服务堆栈更新,适合基于 x64 的系统 (KB5041588)
之后再安装补丁KB5041828就可以了,此累积安全更新包括 2024 年 7 月 9 日发布的更新KB5040456 的改进,同时修复 CVE-2024-37968漏洞,如下所示:
现场测试未通过,更新卡在升级后重启的用户界面进入配置过程中,超时自动回退,无法完成更新,报错Error 0x800f0922 (CBS_E_INSTALLERS_FAILED)
,该代码表示:当安装 Windows 更新时计划任务中断导致报出错误 0x800f0922,相关错误信息回写入到 CBS.log( C:\WINDOWS\Logs\CBS)文件,;待进一步调试。
Windows update getting rolled back on windows server 2012 R2 Servers;Error detail: Code 800F0922;错误代码800F0922表示Windows Update在安装更新时遇到了问题,这可能是由于网络连接问题、安全软件阻止更新、系统文件损坏或其他问题造成的。有时,安全软件可能会阻止Windows Update的安装。运行Windows Update故障排除工具。Windows Update疑难解答工具可以自动检测并修复与Windows Update相关的问题。BIOS里DISABLE SECURE BOOT重启后尝试;
#Run as administrator运行如下命令,重置windows升级组件
net stop bits
net stop wuauserv
net stop appidsvc
net stop cryptsvc
taskkill /im wuauclt.exe /f
del /s /q /f "%ALLUSERSPROFILE%\ApplicationData\Microsoft\Network\Downloader\qmgr*.dat"
del /s /q /f "%ALLUSERSPROFILE%\Microsoft\Network\Downloader\qmgr*.dat"
del /s /q /f "%SYSTEMROOT%\winsxs\pending.xml.bak"
rmdir /s /q "%SYSTEMROOT%\SoftwareDistribution.bak"
rmdir /s /q "%SYSTEMROOT%\system32\Catroot2.bak"
del /s /q /f "%SYSTEMROOT%\WindowsUpdate.log.bak"
takeown /f "%SYSTEMROOT%\winsxs\pending.xml"
attrib -r -s -h /s /d "%SYSTEMROOT%\winsxs\pending.xml"
ren "%SYSTEMROOT%\winsxs\pending.xml" pending.xml.bak
attrib -r -s -h /s /d "%SYSTEMROOT%\SoftwareDistribution"
ren "%SYSTEMROOT%\SoftwareDistribution" SoftwareDistribution.bak
attrib -r -s -h /s /d "%SYSTEMROOT%\system32\Catroot2"
ren "%SYSTEMROOT%\system32\Catroot2" Catroot2.bak
attrib -r -s -h /s /d "%SYSTEMROOT%\WindowsUpdate.log"
ren "%SYSTEMROOT%\WindowsUpdate.log" WindowsUpdate.log.bak
sc.exe sdset wuauserv D:(A;CI;CCLCSWRPLORC;;;AU)(A;;CCDCLCSWRPWPDTLOCRSDRCWDWO;;;BA)(A;;CCDCLCSWRPWPDTLOCRSDRCWDWO;;;SY)S:(AU;FA;CCDCLCSWRPWPDTLOSDRCWDWO;;;WD)
sc.exe sdset bits D:(A;CI;CCDCLCSWRPWPDTLOCRSDRCWDWO;;;SY)(A;;CCDCLCSWRPWPDTLOCRSDRCWDWO;;;BA)(A;;CCLCSWLOCRRC;;;IU)(A;;CCLCSWLOCRRC;;;SU)S:(AU;SAFA;WDWO;;;BA)
sc.exe sdset cryptsvc D:(A;;CCLCSWRPWPDTLOCRRC;;;SY)(A;;CCDCLCSWRPWPDTLOCRSDRCWDWO;;;BA)(A;;CCLCSWLOCRRC;;;IU)(A;;CCLCSWLOCRRC;;;SU)(A;;CCLCSWRPWPDTLOCRRC;;;SO)(A;;CCLCSWLORC;;;AC)(A;;CCLCSWLORC;;;S-1-15-3-1024-3203351429-2120443784-2872670797-1918958302-2829055647-4275794519-765664414-2751773334)
sc.exe sdset trustedinstaller D:(A;CI;CCDCLCSWRPWPDTLOCRSDRCWDWO;;;SY)(A;;CCDCLCSWRPWPDTLOCRRC;;;BA)(A;;CCLCSWLOCRRC;;;IU)(A;;CCLCSWLOCRRC;;;SU)S:(AU;SAFA;WDWO;;;BA)
cd /d %SYSTEMROOT%\system32
regsvr32.exe /s atl.dll
regsvr32.exe /s urlmon.dll
regsvr32.exe /s mshtml.dll
regsvr32.exe /s shdocvw.dll
regsvr32.exe /s browseui.dll
regsvr32.exe /s jscript.dll
regsvr32.exe /s vbscript.dll
regsvr32.exe /s scrrun.dll
regsvr32.exe /s msxml.dll
regsvr32.exe /s msxml3.dll
regsvr32.exe /s msxml6.dll
regsvr32.exe /s actxprxy.dll
regsvr32.exe /s softpub.dll
regsvr32.exe /s wintrust.dll
regsvr32.exe /s dssenh.dll
regsvr32.exe /s rsaenh.dll
regsvr32.exe /s gpkcsp.dll
regsvr32.exe /s sccbase.dll
regsvr32.exe /s slbcsp.dll
regsvr32.exe /s cryptdlg.dll
regsvr32.exe /s oleaut32.dll
regsvr32.exe /s ole32.dll
regsvr32.exe /s shell32.dll
regsvr32.exe /s initpki.dll
regsvr32.exe /s wuapi.dll
regsvr32.exe /s wuaueng.dll
regsvr32.exe /s wuaueng1.dll
regsvr32.exe /s wucltui.dll
regsvr32.exe /s wups.dll
regsvr32.exe /s wups2.dll
regsvr32.exe /s wuweb.dll
regsvr32.exe /s qmgr.dll
regsvr32.exe /s qmgrprxy.dll
regsvr32.exe /s wucltux.dll
regsvr32.exe /s muweb.dll
regsvr32.exe /s wuwebv.dll
netsh winsock reset
proxycfg.exe -d
sc.exe config wuauserv start= auto
sc.exe config bits start= delayed-auto
sc.exe config cryptsvc start= auto
sc.exe config TrustedInstaller start= demand
sc.exe config DcomLaunch start= auto
net start bits
net start wuauserv
net start appidsvc
net start cryptsvc
net start DcomLaunch
del /s /f /q "%TEMP%\*.*"
del /s /f /q "%SYSTEMROOT%\Temp\*.*"
参考链接:How to fix Windows Update Error 0x800f0922
现场验证即使关闭防火墙也无效,且CBS日志里无明显错误,定位困难,未不必要的时间浪费,故将2012 R2升级到windows server 2019,之后就可以直接在“系统更新”里看到该漏洞的补丁包,不需要再手动打补丁了,如下所示:
3.4、CVE-2019-0708(高危)远程桌面服务远程代码执行漏洞
漏洞描述 :当未经身份验证的攻击者使用 RDP 连接到目标系统并发送经特殊设计的请求时,远程桌面服务中存在远程执行代码漏洞。此漏洞是预身份验证,无需用户交互。成功利用此漏洞的攻击者可以在目标系统上执行任意代码。攻击者可随后安装程序;查看、更改或删除数据;或者拥有完全用户权限的新账户。
漏洞复现环境:攻击机可使用 kali 或者 windows 上安装 Metasploit;
漏洞影响范围:CVE-2019-0708 漏洞影响了多个版本的 Windows 操作系统,包括但不限于:
Windows XP SP3 x86
Windows XP 专业 x64 版 SP2
Windows XP Embedded SP3 x86
Windows 7 for 32-bit Systems Service Pack 1
Windows 7 for x64-based Systems Service Pack 1
Windows Server 2003 SP2 x86
Windows Server 2003 x64 版本 SP2
Windows Server 2008 的多个版本(包括 32 位、64 位
和基于 Itanium 的系统)
Windows Server 2008 R2 的多个版本(包括 64 位和基
于 Itanium 的系统)
检测和修复工具:CVE-2019-0708,运行后出现如下,则表示没有漏洞,现场版本Windows Server 2012 R2。否则,请执行修复补丁工具。
注:windows server 2008开始的远程桌面连接引入了网络级身份验证(NLA,network level authentication),NLA可用于通过要求在创建会话之前对用户进行RD会话主机服务器的身份验证来增强RD会话主机的安全性。它主要实现了两个功能,一是服务器身份的验证,二是验证客户端向服务器提交的用户和密码信息的验证;如果要限制谁可以访问你的电脑,请选择仅允许使用网络级别身份验证 (NLA) 进行访问。 启用此选项后,用户必须先向网络验证身份,然后才能连接到你的电脑。 仅允许使用 NLA 从运行远程桌面的计算机进行连接是一种更安全的身份验证方法,可以帮助保护计算机免受恶意用户和软件的侵害;
3.5、CVE-2024-43582 :远程桌面协议(RDP)服务器远程代码执行漏洞
Windows远程桌面(RDP)服务中存在一个Use-After-Free高危安全漏洞,该漏洞的CVSS评分为8.1,未经身份认证的远程攻击者可以向RDP服务发送特定的数据来利用此漏洞,可能导致在服务器端以与RPC服务相同的权限执行远程代码,成功利用此漏洞可以以RDP的服务权限执行任意命令。微软的可利用性评估为 “被利用的可能性较小”。
3.6、CVE-2024-43583:Winlogon 特权提升漏洞
Winlogon存在特权提升漏洞,该漏洞的CVSS评分为7.8,成功利用该漏洞可获得Windows 中的SYSTEM 权限。目前该漏洞已经公开披露,微软的可利用性评估为 “被利用的可能性较高”。
3.7、 CVE-2024-43502:Windows 内核特权提升漏洞
高危;
点击“开始菜单”或按Windows快捷键,点击进入“设置”—选择“更新和安全”,进入“Windows更新”;或控制面板”->“系统和安全”->“Windows更新”–>查看更新历史记录”,查看是否成功安装了更新;对于没有成功安装的更新,可以点击该更新名称进入微软官方更新描述链接,点击最新的SSU名称并在新链接中点击“Microsoft 更新目录”,然后在新链接中选择适用于目标系统的补丁进行下载并安装。手动更新补丁,参看微软官方安全通告。
3.8、CVE-2025-26633:Windows MMC安全功能绕过漏洞
高危:Windows MMC(微软管理控制台)是 Windows系统内置核心组件,主要用于集中管理系统配置、服务、性能等资源。由于该组件对用户输入验证不足,攻击者可绕过文件信誉保护功能,在目标系统中执行恶意代码。
受影响的产品型号包括:Windows 10/11,Windows Server2008/2019/2022/2025,现场使用:Windows Server 2019 10.0.17763 6189 Build 17763;受影响版本:Windows Server 2019 <10.0.17763.7009;
处理:CVE-2025-26633官方修复,安装补丁:KB5053596
3.9、2024 年 10 月 22 日 - KB5045594(OS 内部版本 19045.5073)更新失败
2025-适用于 Windows 10 Version 22H2 的 04 累积更新,适合基于 x64 的系统 (KB5055518)
2025-适用于 Windows 10 Version 22H2 的 01 累积更新,适合基于 x64 的系统 (KB5049981)
2024-适用于 Windows 10 Version 22H2 的 12 累积更新,适合基于 x64 的系统 (KB5048652)
2025-适用于 Windows 10 Version 22H2 的 05 累积更新,适合基于 x64 的系统 (KB5058379)
2024-适用于 Windows 10 Version 22H2 的 11 累积更新,适合基于 x64 的系统 (KB5046714)
2025-适用于 Windows 10 Version 22H2 的 01 累积更新,适合基于 x64 的系统 (KB5050081)
2025-适用于 Windows 10 Version 22H2 的 02 累积更新,适合基于 x64 的系统 (KB5052077)
2025-适用于 Windows 10 Version 22H2 的 05 累积更新,适合基于 x64 的系统 (KB5061768)
2025-适用于 Windows 10 Version 22H2 的 03 累积更新,适合基于 x64 的系统 (KB5053606)
2025-适用于 Windows 10 Version 22H2 的 02 累积更新,适合基于 x64 的系统 (KB5051974)
2025-适用于 Windows 10 Version 22H2 的 03 累积更新,适合基于 x64 的系统 (KB5053643)
2025-适用于 Windows 10 Version 22H2 的 04 累积更新,适合基于 x64 的系统 (KB5055612)
#检测已安装更新,检查是否已安装更高版本更新
Get-Hotfix | Sort-InstalledOn -Descending | Select -First 10
Get-WindowsUpdateLog -LogPath "$env:USERPROFILE\Desktop\update.log"
#系统组件存储检查,组件存储损坏会导致更新无法应用
DISM /Online /Cleanup-Image /AnalyzeComponentStore
DISM /Online /Cleanup-Image /CheckHealth
#SKU兼容性问题要求:企业版/专业版/教育版的更新包不可混用,检查映像版本:
DISM /Online /Get-CurrentEdition
#手动展开你的更新包分析,收集CBS.log和setupapi.dev.log进行深入分析,更新元数据中的适用条件
expand -F:* <更新包>.msu C:\temp\update
findstr /i /c:"<processorArchitecture>" C:\temp\update\*.xml
#WSUS服务器冲突(企业环境)
wuauclt /detectnow /reportnow
gpresult /H gpreport.html #检查组策略设置
#语言包版本不匹配可能导致拒绝安装,检查已安装语言包:
DISM /Online /Get-Packages | findstr Language
#强制安装(仅限紧急情况)
wusa.exe <更新包>.msu /extract:C:\temp\update
regedit里:创建更新兼容性日志,安装失败后检查C:\Windows\Logs\WindowsUpdate日志[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\WindowsUpdate\Tracing]
"EnableTracing"=dword:00000001
dism /online /add-package /packagepath:C:\temp\update\<cab文件>.cab /ignorecheck /norestart #/ignorecheck参数会跳过兼容性检查,但可能导致系统不稳定
#触发Windows系统内置维护任务,自动清理WinSxS(Windows Side-by-Side)目录中的过期组件版本,删除已被新版本替换的旧版系统文件冗余副本;删除已被新版本替换的旧版系统文件冗余副本(需配合/ResetBase参数);修复因更新残留导致的组件存储损坏问题,为后续更新安装释放必要的存储空间;实际执行:DISM.exe /Online /Cleanup-Image /StartComponentCleanup
Start-ScheduledTask -TaskPath "\Microsoft\Windows\Servicing\" -TaskName "StartComponentCleanup"
usoclient StartInteractiveScan #使用Windows Update合规性检查工具
#更新失败后的修复,先清理再检查
DISM /Online /Cleanup-Image /AnalyzeComponentStore # 清理前查看空间占用
Get-WsusServer | Invoke-WsusServerCleanup -CleanupObsoleteUpdates #想WSUS服务器管理更新,需先同步删除它的旧更新,建议在每月补丁日前后定期执行,可有效预防更新失败问题。
Start-ScheduledTask -TaskPath "\Microsoft\Windows\Servicing\" -TaskName "StartComponentCleanup"
DISM /Online /Cleanup-Image /RestoreHealth
# 激进清理模式(需重启)
Start-ScheduledTask -TaskPath "\Microsoft\Windows\Servicing\" -TaskName "StartComponentCleanup" -Argument "/ResetBase"
#综合
# 检查任务状态
$task = Get-ScheduledTask -TaskName "StartComponentCleanup"
if($task.State -eq "Ready") {
Start-ScheduledTask -TaskPath "\Microsoft\Windows\Servicing\" -TaskName "StartComponentCleanup"
}
#用于修复Windows UWP(Universal Windows Platform)应用问题,强制重新注册系统中所有已安装的Microsoft Store应用(包括系统内置应用如计算器、照片等),重建应用与系统注册表的关联关系,修复损坏的AppX部署,当系统更新后出现:系统重大更新后出现应用问题;用户配置文件损坏导致应用异常;准备系统映像前的标准化处理,可使用该命令
Get-AppXPackage -AllUsers | Foreach {Add-AppxPackage -DisableDevelopmentMode -Register "$($_.InstallLocation)/AppXManifest.xml"}
#安装失败后查看失败事件
Get-AppPackageLo g -ActivityID 72c8ab20-cee1-0002-bf6b-d772e1cedb01
#三板斧
DISM /Online /Cleanup-Image /scanhealth
DISM /Online /Cleanup-Image /checkhealth
DISM /Online /Cleanup-Image /restorehealth
sfc /scannow
#查看已安装的 Windows 更新
DISM /Online /Get-Packages | findstr "Package_for_kb"
#列出所有已安装的补丁(按安装时间倒序排列)
Get-HotFix | sort InstalledOn -Descending | Format-Table HotFixID,InstalledOn,Description
HotFixID InstalledOn Description
-------- ----------- -----------
KB5045594 2024/10/28 星期一 0:00:00 Update
KB5046823 2024/10/24 星期四 0:00:00 Update
KB5044029 2024/10/16 星期三 0:00:00 Update
KB5043130 2024/9/26 星期四 0:00:00 Update
KB5043935 2024/9/13 星期五 0:00:00 Security Update
KB5041581 2024/9/2 星期一 0:00:00 Update
KB5041579 2024/8/15 星期四 0:00:00 Security Update
KB5040565 2024/7/25 星期四 0:00:00 Update
KB5039336 2024/7/2 星期二 0:00:00 Update
KB5037995 2024/5/30 星期四 0:00:00 Update
KB5037240 2024/4/26 星期五 0:00:00 Update
KB5037018 2024/4/11 星期四 0:00:00 Security Update
KB5036447 2024/3/14 星期四 0:00:00 Update
KB5034224 2024/2/17 星期六 0:00:00 Update
KB5032907 2023/12/13 星期三 0:00:00 Update
KB5032392 2023/11/18 星期六 0:00:00 Update
KB5031539 2023/10/13 星期五 0:00:00 Update
KB5029709 2023/9/26 星期二 0:00:00 Update
KB5011050 2023/9/6 星期三 0:00:00 Update
KB5011048 2023/9/6 星期三 0:00:00 Update
KB5028951 2023/8/10 星期四 0:00:00 Update
KB5028380 2023/8/10 星期四 0:00:00 Update
KB5028318 2023/7/18 星期二 0:00:00 Update
KB5026879 2023/6/15 星期四 0:00:00 Update
KB5015684 2023/5/20 星期六 0:00:00 Update
KB5025315 2023/5/11 星期四 0:00:00 Update
KB5023794 2023/4/13 星期四 0:00:00 Update
KB5022924 2023/3/16 星期四 0:00:00 Update
KB5020372 2022/12/14 星期三 0:00:00 Update
KB5018506 2022/11/10 星期四 0:00:00 Update
KB5016705 2022/9/14 星期三 0:00:00 Update
KB5012170 2022/8/11 星期四 0:00:00 Security Update
KB5015895 2022/8/11 星期四 0:00:00 Update
KB5014671 2022/7/15 星期五 0:00:00 Update
KB5014035 2022/6/15 星期三 0:00:00 Update
KB5014032 2022/5/12 星期四 0:00:00 Security Update
KB5003791 2022/4/16 星期六 0:00:00 Update
KB5011651 2022/4/13 星期三 0:00:00 Update
KB5011352 2022/2/9 星期三 0:00:00 Security Update
KB5007273 2021/12/15 星期三 0:00:00 Update
KB5006753 2021/11/13 星期六 0:00:00 Update
KB5005699 2021/9/17 星期五 0:00:00 Security Update
KB4580325 2021/6/4 星期五 0:00:00 Security Update
KB4562830 2021/6/2 星期三 0:00:00 Update
#某些更新可能不会显示在 DISM 列表中(如驱动程序更新)
wmic qfe list brief /format:table
#卸载
wusa /uninstall /kb:5034441
#重置 Windows Update 服务
net stop wuauserv
net stop cryptSvc
net stop bits
net stop msiserver
ren C:\Windows\SoftwareDistribution SoftwareDistribution.old
ren C:\Windows\System32\catroot2 catroot2.old
net start wuauserv
net start cryptSvc
net start bits
net start msiserver
更新报错:你的设备中缺少重要的安全和质量修复。(0x800f0805),参看:服务器管理器和 DISM 无法列出可用功能时出现错误0x800f0805:特定包无效的 Windows 包
过使用 DISM 工具列出可用功能,你会收到以下错误:
错误:0x800f0805
特定包无效的 Windows 包
DISM 日志文件中的错误0x800f0805:, Error DISM DISM Package Manager: PID=10396 TID=12656 Failed opening package @Foundation. - CDISMPackageManager::Internal_CreatePackageByName(hr:0x800f0805)
现场:
2025-05-28 10:47:15, Info CBS InternalOpenPackage failed for Package_for_KB302509631bf3856ad364e35amd64~~6.4.1.0 [HRESULT = 0x800f0805 - CBS_E_INVALID_PACKAGE]
2025-05-28 10:47:15, Info CBS Failed to internally open package. [HRESULT = 0x800f0805 - CBS_E_INVALID_PACKAGE]
2025-05-28 10:47:15, Info CBS Failed to create open package. [HRESULT = 0x800f0805 - CBS_E_INVALID_PACKAGE]
2025-05-28 10:47:15, Info CBS Failed to OpenPackage using worker session [HRESULT = 0x800f0805]
……
2025-05-28 10:48:03, Info CBS Not able to find an installed package package from moniker: @Product [HRESULT = 0x800f0805 - CBS_E_INVALID_PACKAGE]
2025-05-28 10:48:03, Info CBS Failed to resolve package from moniker [HRESULT = 0x800f0805 - CBS_E_INVALID_PACKAGE]
2025-05-28 10:48:03, Info CBS Failed to create open package. [HRESULT = 0x800f0805 - CBS_E_INVALID_PACKAGE]
2025-05-28 10:48:03, Info CBS Failed to OpenPackage using worker session [HRESULT = 0x800f0805]
在注册表编辑器中检查注册表路径 HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\ComponentBasedServicing\PackageIndex\System 时, Microsoft-Windows-Foundation-Package 31bf3856ad364e35amd64~~ 注册表值缺失,手动创建: Microsoft-Windows-Foundation-Package31bf3856ad364e35amd64~~10.0.14393.0 使用值数据 0x00000000,现场报错非该问题。
从上述日志来看,系统在尝试处理 Windows 更新包 KB3025096 时失败,错误代码 0x800f0805 (CBS_E_INVALID_PACKAGE) 表示 更新包已损坏或与当前系统不兼容。手动安装KB3025096时又遇到报错:0x800b0101,根据当前系统时钟或签名文件中的时间戳验证时要求的证书不在有效期内。
DISM /Online /Get-Packages | findstr "Package_for_KB3025096" #现场并未找到
#如果存在损坏的包,强制删除:
DISM /Online /Remove-Package /PackageName:Package_for_KB3025096~31bf3856ad364e35~amd64~~6.4.1.0 /NoRestart
#清理 CBS 日志和缓存
del /q /f %windir%\logs\cbs\*
del /q /f %windir%\servicing\packages\* #都是拒绝访问
#以管理员身份运行
wusa.exe ./windows6.4-kb3025096-x64_b18971964e8480df545aa2f1828629aa19033983.msu /quiet /norestart
#终极修复方案
#1、强制重置组件存储
net stop trustedinstaller
net stop cbs
net stop wuauserv
:: 完全重置组件存储
takeown /f %windir%\winsxs\* /r /d y
icacls %windir%\winsxs\* /grant administrators:F /t
dism /online /cleanup-image /startcomponentcleanup /resetbase
:: 重建缓存
rd /s /q %windir%\CbsTemp
md %windir%\CbsTemp
#手动修复CBS数据库
# 重置CBS数据库
Stop-Service -Name TrustedInstaller -Force
Remove-Item -Path "$env:windir\winsxs\pending.xml" -Force -ErrorAction SilentlyContinue
Remove-Item -Path "$env:windir\winsxs\Temp\*.tmp" -Force -ErrorAction SilentlyContinue
Start-Service -Name TrustedInstaller
# 强制重建,X:替换为Windows安装介质盘符
dism /online /cleanup-image /restorehealth /source:wim:X:\sources\install.wim:1 /limitaccess
重置CbsTemp权限
icacls "%windir%\CbsTemp" /reset /T /C
icacls "%windir%\winsxs" /reset /T /C
#重置TrustedInstaller权限
sc.exe sidtype trustedinstaller unrestricted
## 检查损坏的组件
Get-WindowsUpdateLog -Etw | Out-File "$env:USERPROFILE\Desktop\CBS_DEEP_DIAG.log"
# 强制验证所有系统文件
sfc /scannow /offbootdir=C:\ /offwindir=C:\windows
dism /online /cleanup-image /scanhealth
#如果仍显示该更新,/resetbase参数会永久合并所有已安装的更新,可能影响后续卸载,手动修改CBS数据库存在风险,建议先创建系统还原点,执行:
reg add "HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Component Based Servicing\SessionManager" /v PendingXmlIdentifier /t REG_DWORD /d 0 /f
#若所有方法失败,修复安装(保留应用和数据)
Mount-DiskImage -ImagePath "Win10_22H2.iso"
Start-Process -FilePath "E:\setup.exe" -ArgumentList "/auto upgrade /quiet /noreboot"
3.10 C++运行库:Microsoft Visual C++2015-2022(x64)
3.11 远程桌面拒绝连接
上图显示:第一次 TCP 连接尝试链路服务器,但目标主机拒绝了连接请求(RST + ACK),窗口大小(Win=65535)表示初始缓冲区大小,目标主机直接回复 RST(复位) + ACK,并设置 Win=0,表示 拒绝连接。完整的应如下:
#在目标主机上检查防火墙是否放行端口
netsh advfirewall firewall show rule name=all | findstr "3389"
netsh advfirewall firewall add rule name="Open Port 3389" dir=in action=allow protocol=TCP localport=3389
#即使防火墙关闭,Windows 的 IP 安全策略(IPSec) 或 TCP/IP 筛选 可能阻止连接
# 检查 IPSec 策略
netsh ipsec static show all
# 检查 TCP/IP 筛选(较旧系统)
netsh interface ipv4 show excludedportrange protocol=tcp
netsh interface ipv4 reset #调整策略或关闭 IP 过滤
# 检查 TCP 动态端口范围(可能影响连接)
netsh int ipv4 show dynamicport tcp
# 检查 SYN 攻击保护(默认一般不启用)
netsh int tcp show global
netsh int ipv4 set dynamicport tcp start=49152 num=16384 #调整动态端口范围,知名端口(1-1023),注册端口(1025-49151),动态端口(49152-65535)临时通信
## 检查远程桌面服务是否启用,虽然端口可能被监听(如 svchost.exe 占用),但 远程桌面功能未启用。返回值 1:远程桌面已禁用(拒绝连接),返回值 0:远程桌面已启用
Get-ItemProperty -Path "HKLM:\SYSTEM\CurrentControlSet\Control\Terminal Server" -Name "fDenyTSConnections"
Set-ItemProperty -Path "HKLM:\SYSTEM\CurrentControlSet\Control\Terminal Server" -Name "fDenyTSConnections" -Value 0 #启用远程桌面
# 检查组策略是否限制连接
gpresult /z | findstr "RemoteDesktop"#或
Get-ItemProperty -Path "HKLM:\SOFTWARE\Policies\Microsoft\Windows NT\Terminal Services" -Name "UserAuthentication" -ErrorAction SilentlyContinue
#如果客户端不支持 NLA(仅允许网络级认证),Windows 默认要求 NLA,如果客户端不支持(如旧版 Linux RDP 工具),服务端会直接返回 RST
# 检查 NLA 是否启用,返回值 1:NLA 已启用(严格模式),返回值 0:NLA 已禁用
Get-ItemProperty -Path "HKLM:\SYSTEM\CurrentControlSet\Control\Terminal Server\WinStations\RDP-Tcp" -Name "UserAuthentication" -ErrorAction SilentlyContinue
#临时关闭 NLA 测试
Set-ItemProperty -Path "HKLM:\SYSTEM\CurrentControlSet\Control\Terminal Server\WinStations\RDP-Tcp" -Name "UserAuthentication" -Value 0
# 检查服务状态
Get-Service TermService
# 查看系统日志中的 RDP 错误
Get-WinEvent -LogName "System" -MaxEvents 20 | Where-Object { $_.ProviderName -eq "TermDD" } | Format-List
#重启服务
Restart-Service TermService -Force
#如果服务端证书损坏或加密方式不匹配,可能直接断开连接
# 检查 RDP 证书绑定
Get-ChildItem -Path "Cert:\LocalMachine\Remote Desktop" -ErrorAction SilentlyContinue
# 重置 RDP 证书(会生成新自签名证书)
Get-ChildItem -Path "Cert:\LocalMachine\Remote Desktop" | Remove-Item
Restart-Service TermService -Force
#在客户端和服务端同时抓包,确认 SYN 是否到达服务端;ETL(Event Trace Log)文件是 Windows 操作系统使用的一种二进制日志文件格式,通常由 Windows Performance Recorder (WPR) 或其他 ETW(Event Tracing for Windows)工具生成;WPA专用于分析 Windows 性能数据的工具,可以读取和解析 ETL 文件,提供图形化的数据展示
# Windows(管理员运行)
netsh trace start capture=yes scenario=NetConnection tracefile=C:\trace.etl
跟踪配置:
-------------------------------------------------------------------
状态: 正在运行
跟踪文件: C:\Users\Administrator\AppData\Local\Temp\NetTraces\NetTrace.etl
附加: 关闭
循环: 启用
最大大小: 250 MB
报告: 关闭
# 停止抓包
netsh trace stop
正在合并跟踪 ... 完成
正在生成数据集合... 完成
跟踪文件和其他疑难解答信息已编译为“C:\Users\Administrator\AppData\Local\Temp\NetTraces\NetTrace.cab”。
文件位置 = C:\Users\Administrator\AppData\Local\Temp\NetTraces\NetTrace.etl
跟踪会话已成功停止。
tracerpt.exe C:\Users\Administrator\AppData\Local\Temp\NetTraces\NetTrace.etl -lr -o C:\Users\Administrator\AppData\Local\Temp\NetTraces\NetTrace.xml
输入
----------------
文件:
C:\Users\Administrator\AppData\Local\Temp\NetTraces\NetTrace.etl
100.00%
输出
----------------
转储文件: C:\Users\Administrator\AppData\Local\Temp\NetTraces\NetTrace.xml
命令成功结束。
#最后手段,卸载重装
Disable-WindowsOptionalFeature -Online -FeatureName "Microsoft-Windows-TerminalServices" -NoRestart
Enable-WindowsOptionalFeature -Online -FeatureName "Microsoft-Windows-TerminalServices" -All