La interfaz está localizada; las descripciones y documentos de las Skills se traducen automáticamente con IA a su idioma. El código, los comandos, rutas y términos técnicos se mantienen en el original, y prevalece el documento del autor.
Explorar Skills
Productividad · SKILL.md

detecting-fileless-attacks-on-endpoints

detecting-fileless-attacks-on-endpoints

检测完全在内存(RAM)中执行、不向磁盘写入持久文件的无文件恶意软件和内存攻击, 规避传统杀毒软件。适用于为 PowerShell 攻击、反射式 DLL 注入、WMI 持久化和注册表驻留恶意软件 构建检测规则的场景。

Independent GitHub snapshot · Automated classification · Original documentation governs

Documentación de la Skill

GitHub

name: detecting-fileless-attacks-on-endpoints description: > 检测完全在内存(RAM)中执行、不向磁盘写入持久文件的无文件恶意软件和内存攻击, 规避传统杀毒软件。适用于为 PowerShell 攻击、反射式 DLL 注入、WMI 持久化和注册表驻留恶意软件 构建检测规则的场景。 domain: cybersecurity subdomain: endpoint-security tags: [endpoint, fileless-malware, memory-attacks, PowerShell, detection-engineering] version: 1.0.0 author: mahipal license: Apache-2.0

检测端点上的无文件攻击

使用场景

在以下情况下使用本技能:

  • 为完全在内存中运行的无文件恶意软件构建检测规则
  • 狩猎基于 PowerShell 的攻击、反射式 DLL 注入和 WMI 滥用
  • 配置端点遥测(Sysmon、AMSI、PowerShell 日志记录)以捕获无文件攻击指标
  • 调查传统 AV 未发现恶意文件的事件

不适用于检测基于文件的恶意软件或进行恶意软件逆向工程。

前置条件

  • 已启用进程创建和 WMI 事件日志记录的 Sysmon
  • 已启用 PowerShell 脚本块日志记录和模块日志记录
  • 已启用 AMSI(反恶意软件扫描接口)用于脚本内容检查
  • 具有行为检测能力的 EDR(MDE、CrowdStrike、SentinelOne)

操作流程

步骤 1:启用所需遥测

# 启用 PowerShell 脚本块日志记录(GPO 或注册表)
New-ItemProperty -Path "HKLM:\SOFTWARE\Policies\Microsoft\Windows\PowerShell\ScriptBlockLogging" `
  -Name EnableScriptBlockLogging -Value 1 -PropertyType DWORD -Force

# 启用 PowerShell 模块日志记录
New-ItemProperty -Path "HKLM:\SOFTWARE\Policies\Microsoft\Windows\PowerShell\ModuleLogging" `
  -Name EnableModuleLogging -Value 1 -PropertyType DWORD -Force

# 启用 PowerShell 转录
New-ItemProperty -Path "HKLM:\SOFTWARE\Policies\Microsoft\Windows\PowerShell\Transcription" `
  -Name EnableTranscripting -Value 1 -PropertyType DWORD -Force

# 用于无文件检测的 Sysmon 配置(关键事件):
# 事件 ID 1:进程创建(捕获 CommandLine)
# 事件 ID 7:镜像加载(DLL 加载)
# 事件 ID 8:CreateRemoteThread(注入)
# 事件 ID 10:进程访问(LSASS 访问)
# 事件 ID 19/20/21:WMI 事件

步骤 2:检测基于 PowerShell 的攻击

# 恶意 PowerShell 的指标:

# 编码命令执行
EventID: 1
CommandLine 包含:"powershell" 且 ("-enc" 或 "-e " 或 "-encodedcommand" 或 "FromBase64String")

# 下载摇篮(Download Cradle)模式
CommandLine 包含:"IEX" 且 ("Net.WebClient" 或 "DownloadString" 或 "Invoke-WebRequest")
CommandLine 包含:"Invoke-Expression" 且 "New-Object"

# AMSI 绕过尝试(事件 ID 4104 - 脚本块)
ScriptBlock 包含:"AmsiUtils" 或 "amsiInitFailed" 或 "SetValue.*amsi"

# 可疑 PowerShell 的 Splunk 查询:
index=windows source="WinEventLog:Microsoft-Windows-PowerShell/Operational" EventCode=4104
| where match(ScriptBlockText, "(?i)(iex|invoke-expression|downloadstring|net\.webclient|frombase64|bypass|amsiutils)")
| table _time host ScriptBlockText

步骤 3:检测进程注入技术

# 反射式 DLL 注入 - 从内存加载 DLL 而不接触磁盘
# 检测:Sysmon 事件 7(ImageLoaded)其中镜像路径异常
EventID: 7
ImageLoaded 不以 "C:\Windows\" 开头 且不以 "C:\Program Files" 开头

# 进程空洞 - 创建挂起状态的进程,替换内存
# 检测:进程创建后紧接着内存写入
EventID: 1 + 10 关联
# 进程被创建然后以 PROCESS_VM_WRITE 访问

# APC 注入 - 将代码排队到线程的异步过程调用队列
# 检测:来自非系统进程的 Sysmon CreateRemoteThread
EventID: 8
SourceImage 不在 (已知合法来源) 中

# MDE KQL:
DeviceEvents
| where ActionType in ("CreateRemoteThreadApiCall", "NtAllocateVirtualMemoryApiCall")
| where InitiatingProcessFileName !in ("MsMpEng.exe", "svchost.exe")
| project Timestamp, DeviceName, ActionType, InitiatingProcessFileName,
    InitiatingProcessCommandLine, FileName

步骤 4:检测基于 WMI 的持久化

# WMI 事件的 Sysmon 事件 ID 19/20/21
EventID: 19  # 检测到 WmiEventFilter 活动
EventID: 20  # 检测到 WmiEventConsumer 活动
EventID: 21  # 检测到 WmiEventConsumerToFilter 活动

# 除非预期,否则任何 WMI 事件订阅创建都是可疑的
# 常见恶意 WMI 持久化:
Consumer 包含:"CommandLineEventConsumer" 或 "ActiveScriptEventConsumer"

# 通过 osquery 或 PowerShell 查询 WMI 订阅:
Get-WMIObject -Namespace root\Subscription -Class __EventFilter
Get-WMIObject -Namespace root\Subscription -Class __EventConsumer
Get-WMIObject -Namespace root\Subscription -Class __FilterToConsumerBinding

步骤 5:检测基于注册表的执行

# 存储在注册表值中并通过 PowerShell 执行的恶意软件
# Sysmon 事件 13 - 设置了含编码内容的注册表值
EventID: 13
TargetObject 包含:"CurrentVersion\Run"
Details:异常长的值或 Base64 编码内容

# 检测查询:
index=sysmon EventCode=13
| where match(Details, "[A-Za-z0-9+/=]{100,}")
| table _time host TargetObject Details Image

关键概念

术语定义
无文件恶意软件完全在内存中运行、不向磁盘写入可执行文件的恶意软件
AMSI反恶意软件扫描接口(Antimalware Scan Interface),允许安全产品在执行前检查脚本内容的 Windows API
反射式 DLL 注入从内存而非磁盘加载 DLL,避免基于文件的检测
进程空洞(Process Hollowing)创建合法进程的挂起状态,并用恶意代码替换其内存
脚本块日志记录捕获反混淆脚本内容的 PowerShell 日志功能(事件 ID 4104)

工具与系统

  • Sysmon:内核级进程、DLL 和 WMI 监控
  • AMSI:Windows 脚本内容检查 API
  • PowerShell 日志记录:脚本块、模块和转录日志记录
  • Microsoft Defender for Endpoint:无文件技术的行为检测
  • Volatility 3:用于事后无文件恶意软件分析的内存取证

常见误区

  • 依赖基于文件的 AV:扫描磁盘文件的传统 AV 完全无法检测无文件攻击。需要行为检测和 AMSI。
  • 禁用了 PowerShell 日志记录:没有脚本块日志记录,防御者将无法看到反混淆的 PowerShell 命令。
  • 未检测 AMSI 绕过:复杂攻击者在执行载荷前会绕过 AMSI。应将 AMSI 绕过尝试检测设为高优先级告警。
  • 未监控 WMI 事件:WMI 持久化是 APT 组织的常用技术。必须启用 Sysmon 事件 19-21。
Skills guardadas