威胁狩猎:利用MSC文件的新型免杀手法分析
概述
随着Microsoft默认禁用来自互联网文档中的Office宏,攻击者转向使用JavaScript、MSI文件、LNK对象和ISO等其他感染手段。然而,这些方法已被安全专家广泛关注。近期,朝鲜背景的攻击者开发了一种利用MSC文件的新型命令执行技术,Elastic安全研究人员将其命名为"GrimResource"。
GrimResource技术核心
技术原理
-
利用apds.dll的XSS漏洞:通过在特制MSC文件的StringTable部分引用apds.dll中易受攻击的APDS资源,攻击者可以在mmc.exe上下文中执行任意JavaScript。
-
结合DotNetToJScript:攻击者可将此技术与DotNetToJScript结合,获得任意代码执行能力。
攻击流程
-
初始阶段:使用transformNode混淆技术规避ActiveX安全警告。
-
VBScript执行:通过混淆的嵌入式VBScript设置攻击目标环境变量。
-
DotNetToJs技术:执行内嵌的.NET加载程序(PASTALOADER)。
-
有效载荷注入:PASTALOADER从环境变量检索有效载荷,注入到dllhost.exe进程。
检测方法
1. 可疑的MMC执行行为
检测规则:
process where event.action == "start"
and process.parent.executable : "?:\\Windows\\System32\\mmc.exe"
and process.parent.args : "*.msc"
and not process.parent.args : (
"?:\\Windows\\System32\\*.msc",
"?:\\Windows\\SysWOW64\\*.msc",
"?:\\Program files\\*.msc",
"?:\\Program Files (x86)\\*.msc"
)
and not process.executable : (
"?:\\Windows\\System32\\mmc.exe",
"?:\\Windows\\System32\\wermgr.exe",
"?:\\Windows\\System32\\WerFault.exe",
"?:\\Windows\\SysWOW64\\mmc.exe",
"?:\\Program Files\\*.exe",
"?:\\Program Files (x86)\\*.exe",
"?:\\Windows\\System32\\spool\\drivers\\x64\\3\\*.EXE",
"?:\\Program Files (x86)\\Microsoft\\Edge\\Application\\msedge.exe"
)
2. 非标准脚本解释器中创建.NET COM对象
检测DotNetToJScript技术的规则:
api where not process.name : ("cscript.exe", "wscript.exe")
and process.code_signature.trusted == true
and process.code_signature.subject_name : "Microsoft*"
and process.Ext.api.name == "VirtualAlloc"
and process.Ext.api.parameters.allocation_type == "RESERVE"
and process.Ext.api.parameters.protection == "RWX"
and process.thread.Ext.call_stack_summary : (
"*|mscoree.dll|combase.dll|jscript.dll|*",
"*|mscoree.dll|combase.dll|vbscript.dll|*",
"*|mscoree.dll|combase.dll|jscript9.dll|*",
"*|mscoree.dll|combase.dll|chakra.dll|*"
)
3. 通过MMC控制台文件执行脚本
检测规则:
sequence by process.entity_id with maxspan = 1m [
process where event.action == "start"
and process.executable : "?:\\Windows\\System32\\mmc.exe"
and process.args : "*.msc"
] [
file where event.action == "open"
and file.path : "?:\\Windows\\System32\\apds.dll"
]
4. 检测临时HTML文件创建
检测规则:
sequence by process.entity_id with maxspan = 1m [
process where event.action == "start"
and process.executable : "?:\\Windows\\System32\\mmc.exe"
and process.args : "*.msc"
] [
file where event.action in ("creation", "overwrite")
and process.executable : "?:\\Windows\\System32\\mmc.exe"
and file.name : "redirect[?]"
and file.path : "?:\\Users\\*\\AppData\\Local\\Microsoft\\Windows\\INetCache\\IE\\*\\redirect[?]"
]
YARA检测规则
rule Windows_GrimResource_MMC {
meta:
author = "Elastic Security"
reference = "https://www.elastic.co/security-labs/GrimResource"
reference_sample = "14bcb7196143fd2b800385e9b32cfacd837007b0face71a73b546b53310258bb"
arch_context = "x86"
scan_context = "file, memory"
license = "Elastic License v2"
os = "windows"
strings:
$xml = "<?xml"
$a = "MMC_ConsoleFile"
$b1 = "apds.dll"
$b2 = "res://"
$b3 = "javascript:eval("
$b4 = ".loadXML("
condition:
$xml at 0 and $a and 2 of ($b*)
}
攻击指标(IoC)
| SHA-256哈希 | 类型 | 名称 | 描述 |
|---|---|---|---|
| 14bcb7196143fd2b800385e9b32cfacd837007b0face71a73b546b53310258bb | MSC文件 | sccm-updater.msc | 被滥用的MSC文件 |
| 4cb575bc114d39f8f1e66d6e7c453987639289a28cd83a7d802744cd99087fd7 | - | N/A | PASTALOADER |
| c1bba723f79282dceed4b8c40123c72a5dfcf4e3ff7dd48db8cb6c8772b60b88 | - | N/A | Cobalt Strike有效载荷 |
防御建议
-
监控MMC异常行为:特别关注mmc.exe加载非标准库或创建异常子进程的情况。
-
检测apds.dll访问:监控mmc.exe进程对apds.dll的访问行为。
-
关注临时文件创建:注意INetCache文件夹中redirect[*].html文件的创建。
-
实施多层防御:结合行为检测和静态分析,提高检测覆盖率。
-
更新检测规则:部署提供的EQL和YARA规则,增强检测能力。
结论
GrimResource技术展示了攻击者如何利用特制MSC文件在微软管理控制台中执行任意代码。通过多层安全策略和针对性检测规则,防御者可以有效应对这种新型威胁。