L’interface est localisée ; les présentations et documents des Skills sont traduits automatiquement par IA dans votre langue. Le code, les commandes, chemins et termes techniques restent en version originale, et le document de l’auteur fait foi.
Explorer les Skills
Productivité · SKILL.md

performing-lateral-movement-detection

performing-lateral-movement-detection

检测横向移动(Lateral Movement)技术,包括哈希传递(Pass-the-Hash)、PsExec、WMI 执行、 RDP 转移和基于 SMB 的传播,使用 SIEM 关联 Windows 事件日志、网络流数据和终端遥测, 映射到 MITRE ATT&CK 横向移动战术(TA0008)技术。

Independent GitHub snapshot · Automated classification · Original documentation governs

Documentation de la Skill

GitHub

name: performing-lateral-movement-detection description: > 检测横向移动(Lateral Movement)技术,包括哈希传递(Pass-the-Hash)、PsExec、WMI 执行、 RDP 转移和基于 SMB 的传播,使用 SIEM 关联 Windows 事件日志、网络流数据和终端遥测, 映射到 MITRE ATT&CK 横向移动战术(TA0008)技术。 domain: cybersecurity subdomain: soc-operations tags: [soc, lateral-movement, mitre-attack, pass-the-hash, psexec, wmi, rdp, smb, detection] version: "1.0" author: mahipal license: Apache-2.0

执行横向移动检测

适用场景

以下情况使用本技能:

  • 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):

index=wineventlog sourcetype="WinEventLog:Security" EventCode=4624 Logon_Type=3
AuthenticationPackageName="NTLM"
| where TargetUserName!="ANONYMOUS LOGON" AND TargetUserName!="quot;
| 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):

index=wineventlog sourcetype="WinEventLog:Security" EventCode=4769
 TicketEncryptionType="0x17"
| where ServiceName!="krbtgt" AND ServiceName!="quot;
| 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):

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):

--- 通过 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):

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):

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):

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 流量模式:

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$):

index=wineventlog sourcetype="WinEventLog:Security" EventCode=5140
ShareName IN ("\\\\*\\Cquot;, "\\\\*\\ADMINquot;, "\\\\*\\IPCquot;)
| where SubjectUserName!="SYSTEM" AND SubjectUserName!="quot;
| 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:构建横向移动图

可视化攻击路径:

--- 构建认证事件的源->目标图
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):

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):

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:将移动与杀伤链阶段关联

构建端到端攻击链检测:

--- 检测完整横向移动序列
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\quot;), "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 票据在域内进行认证
PsExecSysinternals 工具(及攻击技术),通过 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 已隔离
Skills enregistrées