♧ Godown 安全知识树

MSI CustomAction 1026 LaunchFile:安装时用 rundll32 加载 %AppData% 下的 DLL

pentest/initial-access · verified

一句话结论

MSI 的 CustomAction 表里一行 LaunchFile 1026 viewer.exe C:/Windows/System32/rundll32.exe [AppDataFolder]aclui.dll, edit 会在安装阶段被 msiexec 执行:Type 1026 从 Binary 表拉起 viewer.exe(Advanced Installer 的合法组件,功能是按参数启动目标文件),再由它按 Target 启动 rundll32.exe,以 , edit 调用 %AppData%\aclui.dll 的 edit 导出;DLL 由 MSI 释放到用户可写目录,借 rundll32 这个签名 LOLBin 完成加载,进程链表现为 msiexec.exe → viewer.exe → rundll32.exe(viewer 可能很快退出),后续 loader 逻辑在该 DLL 内执行。

原理

  • LaunchFile (Type 1026):Type 1026 = 1024(msidbCustomActionTypeContinue,出错继续)+ 2(EXE from Binary,从 Binary 表执行 EXE);Action 名 LaunchFile 只是表项名称。Source=viewer.exe 是 Binary 表内 Advanced Installer 的合法组件(文件说明 “File that launches another file”),Target 是要它启动的命令行;msiexec 先拉起 viewer.exe,由 viewer.exe 按 Target 启动 rundll32.exe。本例 Target 写死 C:/Windows/System32/rundll32.exe [AppDataFolder]aclui.dll, edit,不需要脚本动作(PowerShell/VBScript),表里看起来像普通的“打开文件/查看器”动作。
  • 为什么用 rundll32:rundll32.exe 是微软签名、系统自带的 DLL 宿主,命令行形如 rundll32.dll,export;EDR/白名单常放行 rundll32.exe。把恶意 DLL 放进 %AppData%(用户可写)后,msiexec 以安装权限启动 rundll32,rundll32 加载该 DLL 并调用 edit 导出,执行流进入 DLL。
  • DLL 落点:[AppDataFolder]aclui.dll 由 MSI 的 File 表释放到当前用户的 AppData\Roaming;文件名与系统组件 aclui.dll(Access Control UI)同名,但位于用户目录,人工排查时容易误认为系统文件;Process Explorer 截图中签名者 Microsoft Windows 指的是宿主 rundll32.exe,被加载 DLL 的签名与 edit 导出需另行校验。
  • 为什么危险:整条执行链只使用 msiexec 与 rundll32 两个系统组件,初始 JS/MSI 可伪装成安装器;DLL 落地在用户目录,不需要写系统目录;若只监控“未知 EXE”或脚本动作,容易漏掉。
  • 与 Type 1 的区别:Type 1 CallFunctionFromDLL 由 msiexec 直接 LoadLibrary 随包 DLL 并调导出,不产生 rundll32 子进程;本卡的 1026 LaunchFile 是“msiexec 启动 rundll32,再由 rundll32 加载 DLL”,进程链与检测点不同。

触发条件

  • 受害者运行/安装该 MSI(钓鱼下载、仿冒安装器、压缩包内双击等)。
  • MSI 的 CustomAction 表存在 Type 1026 LaunchFile 动作,且 Target 指向系统 LOLBin(rundll32/regsvr32/mshta 等)。
  • MSI 已把恶意 DLL 释放到 %AppData%、%TEMP%、C:\Users\Public 等用户可写目录。
  • 系统未禁止 msiexec 启动 rundll32,或未对 %AppData% DLL 加载做限制。

利用步骤

  1. 制作 MSI:在 File 表加入恶意 DLL,释放目录选 [AppDataFolder](或 [TempFolder]/[Public]);DLL 导出 edit(或其他可被 rundll32 调用的导出名)。
  2. 加 LaunchFile 动作:把 Advanced Installer 的 viewer.exe 放入 Binary 表,CustomAction 表新增 LaunchFile(Type 1026,Source=viewer.exe),Target 写 C:/Windows/System32/rundll32.exe [AppDataFolder]aclui.dll, edit;在 InstallExecuteSequence 中排到文件释放之后。
  3. 投递:把 MSI 交给受害者执行;msiexec 释放 DLL 并启动 rundll32。
  4. 验证:Process Explorer/EDR 中看到 msiexec.exe 拉起 viewer.exe,后者启动 rundll32.exe(viewer 可能很快退出,需按进程审计/父链回溯确认),rundll32 命令行含 %AppData% DLL 与 , edit;DLL 被加载后进入后续 loader(见关联卡)。
  5. 分析侧复现:用 Orca 打开 MSI 查看 CustomAction/InstallExecuteSequence;msiexec /a 管理安装导出文件;对 DLL 做 dumpbin /exports 与签名校验。

PoC

MSI CustomAction 表关键行(原文截图):

Action       Type  Source      Target
LaunchFile   1026  viewer.exe  C:/Windows/System32/rundll32.exe [AppDataFolder]aclui.dll, edit

安装后的进程命令行(原文截图):

"C:\Windows\System32\rundll32.exe" C:\Users\<user>\AppData\Roaming\aclui.dll, edit

对应的 MSI 动作语义(示意,不是完整 MSI):

<CustomAction Id="LaunchFile" Execute="deferred" BinaryKey="..." />
<!-- 等价命令行:rundll32.exe [AppDataFolder]aclui.dll, edit -->

无完整 MSI/DLL 样本;原文为恶意样本分析,未公开附件。

变体与关联

  • 同类 CustomAction:Type 1 CallFunctionFromDLL 由 msiexec 直接调随包 DLL 导出,见 [[pentest-initial-access-msi-customaction-dll-export-loader-password-zip-av-evasion]];Type 50/51/脚本动作、MST 变换注入见关联 MSI 卡。
  • LOLBin 替换:Target 可换成 regsvr32 /s、mshta、wscript、powershell -w hidden 等;rundll32 只是最常见的一种。
  • DLL 命名伪装:本例直接使用与系统组件同名的 aclui.dll 落在用户目录;也可使用零宽字符/RTL 扩展名或近似名伪装;签名需校验有效性而非只看“有签名”。
  • 关联:[[pentest-initial-access-js-comment-hidden-msi-installer]](本样本的 JS 下载安装器)、[[pentest-c2-brc4-badger-embedded-pe-selfinject-loader]](rundll32 加载的 DLL 内 loader 链)。

检测与防御

  • 检测:MSI 结构审计——CustomAction 表出现 Type 1026/LaunchFile 且 Target 含 rundll32/regsvr32/mshta 及用户目录路径;InstallExecuteSequence 中该动作紧跟文件释放。
  • 检测:进程链 msiexec.exe → viewer.exe → rundll32.exe(viewer 可能已退出,需按进程审计/父进程回溯),尤其 rundll32 命令行指向 %AppData%/%TEMP%/C:\Users\Public 下的 DLL;DLL 无有效签名或签名者与文件名不匹配。
  • 防御:AppLocker/WDAC 限制从用户可写目录加载 DLL;禁止普通用户运行下载目录中的 MSI;对 MSI 做来源/哈希/签名校验与表结构审计;EDR 对 rundll32 的模块加载与父进程做关联告警。