Hunting For Anomalous Powershell Execution

通过分析脚本块日志(事件 4104)、模块日志(事件 4103)和进程创建事件,狩猎恶意 PowerShell 活动。 分析员解析 Windows 事件日志 EVTX 文件,检测混淆命令、AMSI 绕过尝试、编码 payload、 凭据转储关键词和可疑下载器(download cradles)。适用于涉及 PowerShell 威胁狩猎、脚本块分析、 编码命令检测或 AMSI 绕过识别的场景。

killvxk bd5adfe 4 files · 25.2 KB Updated

File contents

狩猎异常 PowerShell 执行

概述

PowerShell 脚本块日志记录(事件 ID 4104)会记录在 Windows 终端上执行的完整去混淆脚本文本,使其成为狩猎恶意 PowerShell 的主要数据源。结合模块日志(4103)和进程创建事件,分析员即使在攻击者使用混淆层的情况下,也能检测编码命令、AMSI 绕过模式、下载器(download cradles)、凭据窃取工具和无文件攻击技术。

前置条件

  • 来自 Microsoft-Windows-PowerShell/Operational 的 Windows 事件日志导出(.evtx)
  • Python 3.8+ 及 python-evtx 和 lxml 库
  • 通过组策略启用的脚本块日志记录
  • 了解常见的 PowerShell 攻击技术

步骤

  1. 解析 EVTX 文件,提取事件 4104 的脚本块文本和元数据
  2. 使用 ScriptBlock ID 关联重组多部分脚本块
  3. 扫描脚本文本中的 AMSI 绕过指标和混淆模式
  4. 检测编码命令执行和 Base64 payload
  5. 识别下载器(download cradles)、凭据转储和横向移动命令
  6. 按威胁严重程度对发现结果评分并排序

预期输出

{
  "total_events": 1247,
  "suspicious_events": 23,
  "amsi_bypass_attempts": 2,
  "encoded_commands": 8,
  "download_cradles": 5,
  "credential_access": 3
}

killvxk/cybersecurity-skills-zh/tree/main/skills/hunting-for-anomalous-powershell-execution commit bd5adfef2a

Frequently asked questions

npx skillmds@latest add killvxk/hunting-for-anomalous-powershell-execution