performing-lateral-movement-detection
检测横向移动(Lateral Movement)技术,包括哈希传递(Pass-the-Hash)、PsExec、WMI 执行、 RDP 转移和基于 SMB 的传播,使用 SIEM 关联 Windows 事件日志、网络流数据和终端遥测, 映射到 MITRE ATT&CK 横向移动战术(TA0008)技术。
Best use case
performing-lateral-movement-detection is best used when you need a repeatable AI agent workflow instead of a one-off prompt.
检测横向移动(Lateral Movement)技术,包括哈希传递(Pass-the-Hash)、PsExec、WMI 执行、 RDP 转移和基于 SMB 的传播,使用 SIEM 关联 Windows 事件日志、网络流数据和终端遥测, 映射到 MITRE ATT&CK 横向移动战术(TA0008)技术。
Teams using performing-lateral-movement-detection should expect a more consistent output, faster repeated execution, less prompt rewriting.
When to use this skill
- You want a reusable workflow that can be run more than once with consistent structure.
When not to use this skill
- You only need a quick one-off answer and do not need a reusable workflow.
- You cannot install or maintain the underlying files, dependencies, or repository context.
Installation
Claude Code / Cursor / Codex
Manual Installation
- Download SKILL.md from GitHub
- Place it in
.claude/skills/performing-lateral-movement-detection/SKILL.mdinside your project - Restart your AI agent — it will auto-discover the skill
How performing-lateral-movement-detection Compares
| Feature / Agent | performing-lateral-movement-detection | Standard Approach |
|---|---|---|
| Platform Support | Not specified | Limited / Varies |
| Context Awareness | High | Baseline |
| Installation Complexity | Unknown | N/A |
Frequently Asked Questions
What does this skill do?
检测横向移动(Lateral Movement)技术,包括哈希传递(Pass-the-Hash)、PsExec、WMI 执行、 RDP 转移和基于 SMB 的传播,使用 SIEM 关联 Windows 事件日志、网络流数据和终端遥测, 映射到 MITRE ATT&CK 横向移动战术(TA0008)技术。
Where can I find the source code?
You can find the source code on GitHub using the link provided at the top of the page.
SKILL.md Source
# 执行横向移动检测
## 适用场景
以下情况使用本技能:
- SOC 团队需要检测攻击者在初始入侵后在系统间横向移动
- 事件调查需要追踪攻击者在网络中的移动路径
- 检测工程需要映射到 ATT&CK TA0008 技术的横向移动规则
- 红队/紫队演练识别出横向移动检测缺口
**不适用于**检测初始访问或外部攻击——横向移动检测专注于内部主机到主机的转移活动。
## 前置条件
- 来自所有终端和服务器的 Windows 安全事件日志(EventCode 4624、4625、4648、4672)
- 部署了进程创建(EventCode 1)、网络连接(EventCode 3)和命名管道(EventCode 17/18)的 Sysmon
- 网络流数据(NetFlow/sFlow、Zeek 连接日志)用于内部流量分析
- 具有跨源关联能力的 SIEM
- 正常内部认证模式的基线
## 工作流程
### 步骤 1:检测哈希传递/票据传递(T1550)
**哈希传递(Pass-the-Hash)检测(EventCode 4624 含 NTLM):**
```spl
index=wineventlog sourcetype="WinEventLog:Security" EventCode=4624 Logon_Type=3
AuthenticationPackageName="NTLM"
| where TargetUserName!="ANONYMOUS LOGON" AND TargetUserName!="$"
| stats count, dc(ComputerName) AS unique_targets, values(ComputerName) AS targets
by src_ip, TargetUserName
| where unique_targets > 3
| eval alert = "可能的哈希传递:NTLM 网络登录到 ".unique_targets." 台主机"
| sort - unique_targets
| table src_ip, TargetUserName, unique_targets, count, targets, alert
```
**越过哈希(Overpass-the-Hash)检测(使用 RC4 的 Kerberos):**
```spl
index=wineventlog sourcetype="WinEventLog:Security" EventCode=4769
TicketEncryptionType="0x17"
| where ServiceName!="krbtgt" AND ServiceName!="$"
| stats count, dc(ServiceName) AS unique_services by src_ip, TargetUserName
| where count > 5
| eval alert = "可能的越过哈希:来自 ".src_ip." 的 RC4 Kerberos 票据"
| table _time, src_ip, TargetUserName, unique_services, count, alert
```
**黄金票/白银票检测(T1558):**
```spl
index=wineventlog sourcetype="WinEventLog:Security" EventCode=4769
| where TicketOptions="0x40810000" OR TicketOptions="0x40800000"
| eval ticket_lifetime = TicketExpireTime - TicketIssueTime
| where ticket_lifetime > 36000 --- >10 小时(异常)
| stats count by src_ip, TargetUserName, ServiceName, TicketEncryptionType, TicketOptions
| eval alert = "可能的黄金/白银票:异常票据属性"
```
### 步骤 2:检测远程服务利用(T1021)
**PsExec 检测(T1021.002):**
```spl
--- 通过 Sysmon 进程创建
index=sysmon EventCode=1
(Image="*\\psexec.exe" OR Image="*\\psexesvc.exe"
OR OriginalFileName="psexec.c" OR OriginalFileName="psexesvc.exe"
OR ParentImage="*\\psexesvc.exe")
| table _time, Computer, User, ParentImage, Image, CommandLine, Hashes
--- 通过命名管道创建(Sysmon EventCode 17)
index=sysmon EventCode=17
PipeName IN ("\\PSEXESVC*", "\\RemCom*", "\\csexec*")
| table _time, Computer, User, Image, PipeName
--- 通过 Windows 服务创建(EventCode 7045)
index=wineventlog sourcetype="WinEventLog:System" EventCode=7045
ServiceName="PSEXESVC" OR ServiceFileName="*PSEXESVC*"
| table _time, Computer, ServiceName, ServiceFileName, AccountName
```
**WMI 远程执行(T1047):**
```spl
index=sysmon EventCode=1
(Image="*\\wmic.exe" AND CommandLine="*/node:*")
OR (ParentImage="*\\WmiPrvSE.exe" AND Image IN ("*\\cmd.exe", "*\\powershell.exe"))
| eval execution_type = case(
match(Image, "wmic"), "WMI 命令行",
match(ParentImage, "WmiPrvSE"), "WMI 提供程序主机(远程执行)"
)
| table _time, Computer, User, execution_type, ParentImage, Image, CommandLine
```
**WinRM/PowerShell 远程(T1021.006):**
```spl
index=wineventlog sourcetype="WinEventLog:Security" EventCode=4624
Logon_Type=3 AuthenticationPackageName="Kerberos"
| where ProcessName="*\\wsmprovhost.exe" OR ProcessName="*\\powershell.exe"
| stats count, dc(ComputerName) AS unique_targets by src_ip, TargetUserName
| where unique_targets > 2
| eval alert = "PowerShell 远程连接到来自 ".src_ip." 的 ".unique_targets." 台主机"
--- Sysmon 变体
index=sysmon EventCode=1
ParentImage="*\\wsmprovhost.exe"
Image IN ("*\\cmd.exe", "*\\powershell.exe", "*\\csc.exe")
| table _time, Computer, User, Image, CommandLine
```
**RDP 横向移动(T1021.001):**
```spl
index=wineventlog sourcetype="WinEventLog:Security" EventCode=4624 Logon_Type=10
| stats count, dc(ComputerName) AS rdp_targets, values(ComputerName) AS destinations,
earliest(_time) AS first_rdp, latest(_time) AS last_rdp
by src_ip, TargetUserName
| where rdp_targets > 2
| eval duration_hours = round((last_rdp - first_rdp) / 3600, 1)
| eval alert = TargetUserName." 在 ".duration_hours." 小时内 RDP 连接到 ".rdp_targets." 台主机"
| sort - rdp_targets
```
### 步骤 3:检测基于 SMB 的横向移动
**异常 SMB 流量模式:**
```spl
index=firewall OR index=zeek sourcetype IN ("pan:traffic", "bro:conn:json")
dest_port=445 action=allowed
| where src_ip!=dest_ip
| stats count AS smb_sessions, dc(dest_ip) AS unique_targets,
sum(bytes_out) AS total_bytes
by src_ip
| where unique_targets > 10
| eval alert = case(
unique_targets > 50, "严重:来自 ".src_ip." 的大量 SMB 枚举",
unique_targets > 20, "高:显著的 SMB 横向移动",
unique_targets > 10, "中:SMB 连接次数偏高"
)
| sort - unique_targets
```
**管理共享访问(C$、ADMIN$):**
```spl
index=wineventlog sourcetype="WinEventLog:Security" EventCode=5140
ShareName IN ("\\\\*\\C$", "\\\\*\\ADMIN$", "\\\\*\\IPC$")
| where SubjectUserName!="SYSTEM" AND SubjectUserName!="$"
| stats count, dc(ComputerName) AS unique_hosts by SubjectUserName, ShareName, src_ip
| where unique_hosts > 3
| eval alert = SubjectUserName." 访问了 ".unique_hosts." 台主机的管理共享"
| sort - unique_hosts
```
### 步骤 4:构建横向移动图
可视化攻击路径:
```spl
--- 构建认证事件的源->目标图
index=wineventlog EventCode=4624 Logon_Type IN (3, 10)
earliest=-24h
| stats count AS connections, latest(_time) AS last_connection
by src_ip, ComputerName, TargetUserName, Logon_Type
| eval edge = src_ip." -> ".ComputerName." (用户:".TargetUserName.",类型:".Logon_Type.")"
| sort - connections
| table edge, connections, last_connection
--- 网络流关联
index=netflow earliest=-24h
dest_port IN (445, 135, 3389, 5985, 5986)
| stats sum(bytes) AS total_bytes, count AS flow_count,
dc(dest_ip) AS targets by src_ip, dest_port
| where targets > 5
| eval service = case(
dest_port=445, "SMB",
dest_port=135, "RPC/WMI",
dest_port=3389, "RDP",
dest_port IN (5985, 5986), "WinRM"
)
| sort - targets
| table src_ip, service, targets, flow_count, total_bytes
```
### 步骤 5:检测 DCOM 和计划任务横向移动
**DCOM 远程执行(T1021.003):**
```spl
index=sysmon EventCode=1
ParentImage IN ("*\\mmc.exe", "*\\excel.exe", "*\\outlook.exe")
Image IN ("*\\cmd.exe", "*\\powershell.exe", "*\\mshta.exe")
| where ParentCommandLine="*-Embedding*"
| eval alert = "基于 DCOM 的横向移动:".ParentImage." 生成了 ".Image
| table _time, Computer, User, ParentImage, Image, CommandLine, alert
```
**远程计划任务创建(T1053.005):**
```spl
index=wineventlog EventCode=4698
| where SubjectUserName!="SYSTEM"
| eval task_xml = TaskContent
| search task_xml="*http*" OR task_xml="*powershell*" OR task_xml="*cmd*" OR task_xml="*\\Temp\\*"
| table _time, Computer, SubjectUserName, TaskName, task_xml
```
### 步骤 6:将移动与杀伤链阶段关联
构建端到端攻击链检测:
```spl
--- 检测完整横向移动序列
index=wineventlog OR index=sysmon
(EventCode=4625 OR EventCode=4624 OR EventCode=1 OR EventCode=4698 OR EventCode=5140)
| eval phase = case(
EventCode=4625, "1-侦察/暴力破解",
EventCode=4624 AND Logon_Type=3, "2-横向移动",
EventCode=5140 AND match(ShareName, "C\$|ADMIN\$"), "3-管理共享访问",
EventCode=1 AND match(ParentImage, "psexesvc|WmiPrvSE|wsmprovhost"), "4-远程执行",
EventCode=4698, "5-持久化(计划任务)",
1=1, "other"
)
| where phase!="other"
| stats count by phase, src_ip, ComputerName, TargetUserName
| sort phase, _time
| table phase, src_ip, ComputerName, TargetUserName, count
```
## 核心概念
| 术语 | 定义 |
|------|------|
| **横向移动(Lateral Movement)** | 入侵后攻击者在系统间横向转移以到达目标的技术 |
| **哈希传递(Pass-the-Hash)** | 使用盗取的 NTLM 哈希进行认证,无需知道明文密码 |
| **票据传递(Pass-the-Ticket)** | 使用盗取的 Kerberos TGT/TGS 票据在域内进行认证 |
| **PsExec** | Sysinternals 工具(及攻击技术),通过 SMB 和命名管道进行远程进程执行 |
| **WMI 执行(WMI Execution)** | 通过 DCOM 或 WinRM 使用 Windows 管理规范(WMI)进行远程命令执行 |
| **管理共享(Admin Share)** | 默认 Windows 管理共享(C$、ADMIN$、IPC$),用于远程系统管理 |
## 工具与系统
- **Splunk Enterprise Security**:用于关联 Windows 事件、Sysmon 和网络流的 SIEM 平台
- **Microsoft Defender for Identity**:通过域控制器监控检测横向移动的云服务
- **BloodHound**:Active Directory 攻击路径分析工具,用于识别横向移动机会
- **CrowdStrike Falcon**:具有横向移动检测和自动遏制功能的 EDR 平台
- **Zeek(Bro)**:网络监控器,为 SMB、RDP 和 WinRM 流量分析生成连接日志
## 常见场景
- **PsExec 传播**:攻击者使用 PsExec 在 20 台工作站上执行恶意软件——通过服务创建事件检测
- **RDP 转移**:被入侵的 VPN 账号用于通过多台内部主机进行 RDP 转移——通过 Logon_Type 10 链检测
- **WMI 侦察和执行**:攻击者使用 WMI 进行发现然后执行——通过 WmiPrvSE 子进程检测
- **哈希传递活动**:盗取的本地管理员哈希在子网范围内使用——通过 NTLM Logon_Type 3 到多台主机检测
- **计划任务持久化**:在域控制器上远程创建计划任务——通过来自非管理员来源的 EventCode 4698 检测
## 输出格式
```
横向移动检测报告
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
时段: 2024-03-15 14:00 至 18:00 UTC
来源: 192.168.1.105(WORKSTATION-042)
移动路径:
14:23 192.168.1.105 → 10.0.5.20(DC-PRIMARY) — 通过 NTLM Type 3 哈希传递
14:25 10.0.5.20 → 10.0.5.21(DC-BACKUP) — Kerberos 票据复用
14:28 10.0.5.20 → 10.0.10.15(FILESERVER-01) — PsExec 服务创建
14:32 10.0.10.15 → 10.0.10.20(DB-PRIMARY) — WMI 远程执行
14:35 10.0.10.20 → 10.0.10.25(DB-BACKUP) — SMB 管理共享访问
检测到的技术:
T1550.002 — 哈希传递(NTLM 认证到 DC)
T1021.002 — PsExec(远程服务安装)
T1047 — WMI 执行(WmiPrvSE 子进程)
T1021.002 — SMB 管理共享(DB-BACKUP 上的 C$ 访问)
受影响系统: 跨 2 个网络分段的 5 台主机
用户账号: admin_compromised(域管理员)
遏制措施: 5 台主机在 14:45 UTC 已隔离
```Related Skills
performing-yara-rule-development-for-detection
通过识别可执行文件中的唯一字节模式、字符串和行为指标,开发精准的 YARA 恶意软件检测规则,同时将误报率降至最低。
performing-wireless-security-assessment-with-kismet
使用 Kismet 通过被动射频监控进行无线网络安全评估,检测流氓接入点(Rogue AP)、隐藏 SSID、弱加密和未授权客户端。
performing-wireless-network-penetration-test
执行无线网络渗透测试,通过捕获握手包、破解 WPA2/WPA3 密钥、检测流氓接入点以及使用 Aircrack-ng 和相关工具测试无线网络分段,评估 WiFi 安全性。
performing-windows-artifact-analysis-with-eric-zimmerman-tools
使用 Eric Zimmerman 的开源 EZ Tools 套件(包括 KAPE、MFTECmd、PECmd、LECmd、JLECmd 和 Timeline Explorer)执行全面的 Windows 取证制品分析,解析注册表 hive、预取文件、事件日志和文件系统元数据。
performing-wifi-password-cracking-with-aircrack
在授权无线安全评估中捕获 WPA/WPA2 握手包,并使用 aircrack-ng、hashcat 和字典攻击进行离线密码破解, 以评估密码短语强度和无线网络安全状况。
performing-web-cache-poisoning-attack
在授权安全测试期间,通过未纳入缓存键的头部和参数毒化缓存响应,利用 Web 缓存机制向其他用户投递恶意内容。
performing-web-cache-deception-attack
通过利用 CDN 缓存层与源服务器之间的路径规范化差异,执行 Web 缓存欺骗攻击,从而缓存并获取敏感的已认证内容。
performing-web-application-vulnerability-triage
使用 OWASP 风险评级方法论对 DAST/SAST 扫描器的 Web 应用程序漏洞发现进行分类,区分真阳性和假阳性,并确定修复优先级。
performing-web-application-scanning-with-nikto
Nikto 是一款开源 Web 服务器和 Web 应用程序扫描器,可针对超过 7,000 个潜在危险文件/程序进行测试,检查超过 1,250 个服务器的过期版本,并识别超过 270 个服务器的版本特定问题。
performing-web-application-penetration-test
遵循 OWASP Web 安全测试指南(WSTG)方法论,对 Web 应用程序执行系统化安全测试,识别认证、授权、 输入验证、会话管理和业务逻辑中的漏洞。测试人员以 Burp Suite 作为主要拦截代理,结合手动测试技术 发现自动化扫描器遗漏的缺陷。适用于 Web 应用渗透测试、OWASP 测试、应用安全评估或 Web 漏洞测试等请求场景。
performing-web-application-firewall-bypass
使用编码技术、HTTP 方法操控、参数污染和载荷混淆绕过 Web 应用防火墙保护,将 SQL 注入、XSS 及其他攻击载荷穿透 WAF 检测规则。
performing-vulnerability-scanning-with-nessus
使用 Tenable Nessus 执行认证和未认证漏洞扫描,识别网络基础设施、服务器和应用程序中的已知漏洞、 错误配置、默认凭据和缺失补丁。扫描器将发现与 CVE 数据库和 CVSS 评分关联,生成优先级修复指导。 适用于漏洞扫描、Nessus 评估、补丁合规检查或自动化漏洞检测等请求场景。