πCheatsheet
Windows - Privilege Escalation
Summary
Tools
Windows Version and Configuration
User Enumeration
Network Enumeration
Antivirus Enumeration
Default Writeable Folders
EoP - Looting for passwords
SAM and SYSTEM files
HiveNightmare
LAPS Settings
Search for file contents
Search for a file with a certain filename
Search the registry for key names and passwords
Passwords in unattend.xml
Wifi passwords
Sticky Notes passwords
Passwords stored in services
Passwords stored in Key Manager
Powershell History
Powershell Transcript
Password in Alternate Data Stream
EoP - Processes Enumeration and Tasks
EoP - Incorrect permissions in services
EoP - Windows Subsystem for Linux (WSL)
EoP - Unquoted Service Paths
EoP - $PATH Interception
EoP - Named Pipes
EoP - Kernel Exploitation
EoP - AlwaysInstallElevated
EoP - Insecure GUI apps
EoP - Evaluating Vulnerable Drivers
EoP - Printers
Universal Printer
Bring Your Own Vulnerability
EoP - Runas
EoP - Abusing Shadow Copies
EoP - From local administrator to NT SYSTEM
EoP - Living Off The Land Binaries and Scripts
EoP - Impersonation Privileges
Restore A Service Account's Privileges
Meterpreter getsystem and alternatives
RottenPotato (Token Impersonation)
Juicy Potato (Abusing the golden privileges)
Rogue Potato (Fake OXID Resolver))
EFSPotato (MS-EFSR EfsRpcOpenFileRaw))
EoP - Privileged File Write
DiagHub
UsoDLLLoader
WerTrigger
WerMgr
EoP - Common Vulnerabilities and Exposures
MS08-067 (NetAPI)
MS10-015 (KiTrap0D)
MS11-080 (adf.sys)
MS15-051 (Client Copy Image)
MS16-
MS17-010 (Eternal Blue)
CVE-2019-
EoP - $PATH Interception
References
To o l s
PowerSploit's PowerUp
Watson - Watson is a (.NET 2.0 compliant) C# implementation of Sherlock
(Deprecated) Sherlock - PowerShell script to quickly find missing software patches for local
privilege escalation vulnerabilities
BeRoot - Privilege Escalation Project - Windows / Linux / Mac
Windows-Exploit-Suggester
windows-privesc-check - Standalone Executable to Check for Simple Privilege Escalation
Vectors on Windows Systems
WindowsExploits - Windows exploits, mostly precompiled. Not being updated.
WindowsEnum - A Powershell Privilege Escalation Enumeration Script.
Seatbelt - A C# project that performs a number of security oriented host-survey "safety
checks" relevant from both offensive and defensive security perspectives.
Powerless - Windows privilege escalation (enumeration) script designed with OSCP labs
(legacy Windows) in mind
JAWS - Just Another Windows (Enum) Script
winPEAS - Windows Privilege Escalation Awesome Script
Windows Exploit Suggester - Next Generation (WES-NG)
PrivescCheck - Privilege Escalation Enumeration Script for Windows
Windows Version and Configuration
Extract patchs and updates
Architecture
List all env variables
List all drives
User Enumeration
Get current username
List user privilege
List all users
List logon requirements; useable for bruteforcing
Get details about a user (i.e. administrator, admin, current user)
List all local groups
Get details about a group (i.e. administrators)
Get Domain Controllers
Network Enumeration
List all network interfaces, IP, and DNS.
List current routing table
List the ARP table
List all current connections
List all network shares
SNMP Configuration
Antivirus Enumeration
Enumerate antivirus on a box with WMIC /Node:localhost
/Namespace:\root\SecurityCenter2 Path AntivirusProduct Get displayName
Default Writeable Folders
EoP - Looting for passwords
SAM and SYSTEM files
The Security Account Manager (SAM), often Security Accounts Manager, is a database file. The
user passwords are stored in a hashed format in a registry hive either as a LM hash or as a NTLM
hash. This file can be found in %SystemRoot%/system32/config/SAM and is mounted on
HKLM/SAM.
Generate a hash file for John using pwdump or samdump2.
Either crack it with john -format=NT /root/sam.txt, hashcat or use Pass-The-Hash.
HiveNightmare
CVE-2021β36934 allows you to retrieve all registry hives (SAM,SECURITY,SYSTEM) in
Windows 10 and 11 as a non-administrator user
Check for the vulnerability using icacls
Then exploit the CVE by requesting the shadowcopies on the filesystem and reading the hives
from it.
LAPS Settings
Extract HKLM\Software\Policies\Microsoft Services\AdmPwd from Windows Registry.
LAPS Enabled: AdmPwdEnabled
LAPS Admin Account Name: AdminAccountName
LAPS Password Complexity: PasswordComplexity
LAPS Password Length: PasswordLength
LAPS Expiration Protection Enabled: PwdExpirationProtectionEnabled
Search for file contents
Also search in remote places such as SMB Shares and SharePoint:
Search passwords in SharePoint: nheiniger/SnaffPoint (must be compiled first, for
referencing issue see: https://tinyurl.com/28xlvo33/pull/6)
Search passwords in SMB Shares: SnaffCon/Snaffler
Search for a file with a certain filename
Search the registry for key names and passwords
Passwords in unattend.xml
Location of the unattend.xml files.
Display the content of these files with dir /s *sysprep.inf *sysprep.xml *unattended.xml
*unattend.xml *unattend.txt 2>nul.
Example content
Unattend credentials are stored in base64 and can be decoded manually with base64.
The Metasploit module post/windows/gather/enum_unattend looks for these files.
IIS Web config
Other files
Wifi passwords
Find AP SSID
Get Cleartext Pass
Oneliner method to extract wifi passwords from all the access point.
Sticky Notes passwords
The sticky notes app stores it's content in a sqlite db located at C:\Users\
\AppData\Local\Packages\Microsoft.MicrosoftStickyNotes_8wekyb3d8bbwe\LocalSt
ate\plum.sqlite
Passwords stored in services
Saved session information for PuTTY, WinSCP, FileZilla, SuperPuTTY, and RDP using
SessionGopher
Passwords stored in Key Manager
β οΈ This software will display its output in a GUI
Powershell History
Disable Powershell history: Set-PSReadlineOption -HistorySaveStyle SaveNothing.
Powershell Transcript
Password in Alternate Data Stream
EoP - Processes Enumeration and Tasks
What processes are running?
Which processes are running as "system"
Do you have powershell magic?
List installed programs
List services
Enumerate scheduled tasks
Startup tasks
EoP - Incorrect permissions in services
A service running as Administrator/SYSTEM with incorrect file permissions might allow EoP.
You can replace the binar y, restar t the ser vice and get system.
Often, services are pointing to writeable locations:
Orphaned installs, not installed anymore but still exist in startup
DLL Hijacking
PATH directories with weak permissions
Alternatively you can use the Metasploit exploit :
Note to check file permissions you can use cacls and icacls
icacls (Windows Vista +)
Find-PathDLLHijack PowerUp.ps
Process Monitor : check for "Name Not Found"
For x64 compile with: "x86_64-w64-mingw32-gcc windows_dll.c -shared -o output.dll"
For x86 compile with: "i686-w64-mingw32-gcc windows_dll.c -shared -o output.dll"
cacls (Windows XP)
You are looking for BUILTIN\Users:(F)(Full access), BUILTIN\Users:(M)(Modify access) or
BUILTIN\Users:(W)(Write-only access) in the output.
Example with Windows 10 - CVE-2019-1322 UsoSvc
Prerequisite: Service account
Example with Windows XP SP1 - upnphost
If it fails because of a missing dependency, try the following commands.
Using accesschk from Sysinternals or accesschk-XP.exe - github.com/phackt
EoP - Windows Subsystem for Linux (WSL)
Te c h n i q u e b o r rowe d f ro m Warlockobama's tweet
With root privileges Windows Subsystem for Linux (WSL) allows users to create a bind shell
on any port (no elevation needed). Don't know the root password? No problem just set the
default user to root W/ .exe --default-user root. Now start your bind shell or reverse.
Binary bash.exe can also be found in C:\Windows\WinSxS\amd64_microsoft-windows-
lxssbash_[...]\bash.exe
Alternatively you can explore the WSL filesystem in the folder
9rhkp1fndgsc\LocalState\rootfs\
EoP - Unquoted Service Paths
The Microsoft Windows Unquoted Service Path Enumeration Vulnerability. All Windows services
have a Path to its executable. If that path is unquoted and contains whitespace or other
separators, then the service will attempt to access a resource in the parent path first.
Metasploit exploit : exploit/windows/local/trusted_service_path
PowerUp exploit
Example
For C:\Program Files\something\legit.exe, Windows will try the following paths first:
EoP - $PATH Interception
Requirements:
PATH contains a writeable folder with low privileges.
The writeable folder is before the folder that contains the legitimate binary.
EXAMPLE:
Because (in this example) "C:\Program Files\nodejs" is before "C:\WINDOWS\system32" on the
PATH variable, the next time the user runs "cmd.exe", our evil version in the nodejs folder will
run, instead of the legitimate one in the system32 folder.
EoP - Named Pipes
1. Find named pipes: [System.IO.Directory]::GetFiles("\.\pipe")
2. Check named pipes DACL: pipesec.exe <named_pipe>
3. Reverse engineering software
4. Send data throught the named pipe : program.exe >\.\pipe\StdOutPipe
EoP - Kernel Exploitation
List of exploits kernel : [https://tinyurl.com/24sucrsp)
#Security Bulletin #KB #Description #Operating System
MS17-017 [KB4013081] [GDI Palette Objects Local Privilege Escalation] (windows
7/8)
CVE-2017-8464 [LNK Remote Code Execution Vulnerability] (windows
10/8.1/7/2016/2010/2008)
CVE-2017-0213 [Windows COM Elevation of Privilege Vulnerability] (windows
10/8.1/7/2016/2010/2008)
CVE-2018-0833 [SMBv3 Null Pointer Dereference Denial of Service] (Windows 8.1/Server
2012 R2)
CVE-2018-8120 [Win32k Elevation of Privilege Vulnerability] (Windows 7 SP1/
SP2,2008 R2 SP1)
MS17-010 [KB4013389] [Windows Kernel Mode Drivers] (windows
7/2008/2003/XP)
MS16-135 [KB3199135] [Windows Kernel Mode Drivers] (2016)
MS16-111 [KB3186973] [kernel api] (Windows 10 10586 (32/64)/8.1)
MS16-098 [KB3178466] [Kernel Driver] (Win 8.1)
MS16-075 [KB3164038] [Hot Potato] (2003/2008/7/8/2012)
MS16-034 [KB3143145] [Kernel Driver] (2008/7/8/10/2012)
MS16-032 [KB3143141] [Secondary Logon Handle] (2008/7/8/10/2012)
MS16-016 [KB3136041] [WebDAV] (2008/Vista/7)
MS16-014 [K3134228] [remote code execution] (2008/Vista/7)
...
MS03-026 [KB823980] [Buffer Overrun In RPC Interface] (/NT/2000/XP/2003)
To c ro s s c o m p i l e a p ro g r a m f ro m K a l i , u s e t h e fo l l ow i n g c o m m a n d.
EoP - AlwaysInstallElevated
Check if these registry values are set to "1".
Then create an MSI package and install it.
Te c h n i q u e a l s o ava i l a b l e i n :
Metasploit : exploit/windows/local/always_install_elevated
PowerUp.ps1 : Get-RegistryAlwaysInstallElevated, Write-UserAddMSI
EoP - Insecure GUI apps
Application running as SYSTEM allowing an user to spawn a CMD, or browse directories.
Example: "Windows Help and Support" (Windows + F1), search for "command prompt", click on
"Click to open Command Prompt"
EoP - Evaluating Vulnerable Drivers
Look for vuln drivers loaded, we often don't spend enough time looking at this:
Living Off The Land Drivers is a curated list of Windows drivers used by adversaries to
bypass security controls and carry out attacks. The project helps security professionals stay
informed and mitigate potential threats.
Native binary: DriverQuery.exe
matterpreter/OffensiveCSharp/DriverQuery
EoP - Printers
Universal Printer
Create a Printer
Execute the driver
PrinterNightmare
Bring Your Own Vulnerability
Concealed Position : https://tinyurl.com/2bvl5yz3
ACIDDAMAGE - CVE-2021-35449 - Lexmark Universal Print Driver LPE
RADIANTDAMAGE - CVE-2021-38085 - Canon TR150 Print Driver LPE
POISONDAMAGE - CVE-2019-19363 - Ricoh PCL6 Print Driver LPE
SLASHINGDAMAGE - CVE-2020-1300 - Windows Print Spooler LPE
EoP - Runas
Use the cmdkey to list the stored credentials on the machine.
Then you can use runas with the /savecred options in order to use the saved credentials.
The following example is calling a remote binary via an SMB share.
Using runas with a provided set of credential.
EoP - Abusing Shadow Copies
If you have local administrator access on a machine try to list shadow copies, it's an easy way for
Privilege Escalation.
EoP - From local administrator to NT SYSTEM
EoP - Living Off The Land Binaries and Scripts
Living Off The Land Binaries and Scripts (and also Libraries) : https://tinyurl.com/y6ct9yf9
The goal of the LOLBAS project is to document every binary, script, and library that can be
used for Living Off The Land techniques.
A LOLBin/Lib/Script must:
Be a Microsoft-signed file, either native to the OS or downloaded from Microsoft. Have extra
"unexpected" functionality. It is not interesting to document intended use cases. Exceptions
are application whitelisting bypasses
Have functionality that would be useful to an APT or red team
EoP - Impersonation Privileges
Full privileges cheatsheet at https://tinyurl.com/2cv7an8v summary below will only list direct
ways to exploit the privilege to obtain an admin session or read sensitive files.
Privilege Impact To o l Execution path Remarks
SeAssignPrimaryToken Admin
3rd party
tool
"It would allow a user
to impersonate tokens
and privesc to nt
system using tools
such as potato.exe,
rottenpotato.exe and
juicypotato.exe"
Thank you AurΓ©lien Chalot
for the update. I will try to
re-phrase it to something
more recipe-like soon.
May be more interesting
if you can read
%WINDIR%\MEMORY.DMP
SeBackupPrivilege
SeBackup Threat Built-in
commands
Read sensitve files
with robocopy /b
(and robocopy) is not
helpful when it comes to
open files.
Robocopy requires both
SeBackup and SeRestore
to work with /b parameter.
SeCreateToken Admin
3rd party
tool
Create arbitrary token
including local admin
rights with
NtCreateToken.
SeDebug Admin PowerShell
Duplicate the
lsass.exe token.
Script to be found at
FuzzySecurity
SeLoadDriver Admin
3rd party
tool
1. Load buggy kernel
driver such as
szkg64.sys or
2. Exploit the driver
vulnerability
Alternatively, the
privilege may be used
to unload security-
related drivers with
ftlMC builtin
command. i.e.: fltMC
1. The szkg64
vulnerability is listed as
CVE-2018-15732
2. The szkg64
code was created by
Parvez Anwar
SeRestore Admin PowerShell
1. Launch
PowerShell/ISE with
the SeRestore
privilege present.
2. Enable the privilege
with Enable-
SeRestorePrivilege).
3. Rename utilman.exe
to utilman.old
4. Rename cmd.exe to
utilman.exe
Attack may be detected by
some AV software.
Alternative method relies
on replacing service
binaries stored in
"Program Files" using the
same privilege.
Restore A Service Account's Privileges
This tool should be executed as LOCAL SERVICE or NETWORK SERVICE only.
5. Lock the console
and press Win+U
SeTakeOwnership Admin
Built-in
commands
1. takeown.exe /f
2. icalcs.exe
3. Rename cmd.exe to
utilman.exe
4. Lock the console
and press Win+U
Attack may be detected by
some AV software.
Alternative method relies
on replacing service
binaries stored in
"Program Files" using the
same privilege.
SeTcb Admin
3rd party
tool
Manipulate tokens to
have local admin
rights included. May
require
SeImpersonate.
To b e ve r i f i e d.
Meterpreter getsystem and alternatives
RottenPotato (Token Impersonation)
Binary available at : foxglovesec/RottenPotato and breenmachine/RottenPotatoNG
Exploit using Metasploit with incognito mode loaded.
Juicy Potato (Abusing the golden privileges)
If the machine is >= Windows 10 1809 & Windows Server 2019 - Try Rogue Potato
If the machine is < Windows 10 1809 < Windows Server 2019 - Try Juicy Potato
Binary available at : ohpe/juicy-potato
1. Check the privileges of the service account, you should look for SeImpersonate and/or
SeAssignPrimaryToken (Impersonate a client after authentication)
2. Select a CLSID based on your Windows version, a CLSID is a globally unique identifier that
identifies a COM class object
Windows 7 Enterprise
Windows 8.1 Enterprise
Windows 10 Enterprise
Windows 10 Professional
Windows Server 2008 R2 Enterprise
Windows Server 2012 Datacenter
Windows Server 2016 Standard
3. Execute JuicyPotato to run a privileged command.
Rogue Potato (Fake OXID Resolver)
Binary available at antonioCoco/RoguePotato
EFSPotato (MS-EFSR EfsRpcOpenFileRaw)
Binary available at https://tinyurl.com/23dbbqvr
JuicyPotatoNG
antonioCoco/JuicyPotatoNG
EoP - Privileged File Write
DiagHub
β οΈ Starting with version 1903 and above, DiagHub can no longer be used to load arbitrary
DLLs.
The Microsoft Diagnostics Hub Standard Collector Service (DiagHub) is a service that collects
trace information and is programmatically exposed via DCOM. This DCOM object can be used to
load a DLL into a SYSTEM process, provided that this DLL exists in the C:\Windows\System32
directory.
Exploit
1. Create an evil DLL e.g: payload.dll and move it into C:\Windows\System32
2. Build https://tinyurl.com/2xlyyjuz
3. diaghub.exe c:\ProgramData\ payload.dll
The default payload will run C:\Windows\System32\spool\drivers\color\nc.exe -lvp 2000 -
e cmd.exe
Alternative tools:
https://tinyurl.com/2b7rwrc6
https://tinyurl.com/2dfj95aj
UsoDLLLoader
β οΈ 2020-06-06 Update: this trick no longer works on the latest builds of Windows 10
Insider Preview.
An alternative to the DiagHub DLL loading "exploit" found by James Forshaw (a.k.a.
@tiraniddo)
If we found a privileged file write vulnerability in Windows or in some third-party software, we
could copy our own version of windowscoredeviceinfo.dll into C:\Windows\Sytem32\ and
then have it loaded by the USO service to get arbitrary code execution as NT
AUTHORITY\System.
Exploit
1. Build https://tinyurl.com/29rz3v7r
Select Release config and x64 architecure.
Build solution.
DLL .\x64\Release\WindowsCoreDeviceInfo.dll
Loader .\x64\Release\UsoDllLoader.exe.
2. Copy WindowsCoreDeviceInfo.dll to C:\Windows\System32\
3. Use the loader and wait for the shell or run usoclient StartInteractiveScan and
connect to the bind shell on port 1337.
WerTrigger
Exploit Privileged File Writes bugs with Windows Problem Reporting
1. Clone https://tinyurl.com/269v4hov
2. Copy phoneinfo.dll to C:\Windows\System32\
3. Place Report.wer file and WerTrigger.exe in a same directory.
4. Then, run WerTrigger.exe.
5. Enjoy a shell as NT AUTHORITY\SYSTEM
WerMgr
Exploit Privileged Directory Creation Bugs with Windows Error Reporting
Metasploit modules to exploit EternalRomance/EternalSynergy/EternalChampion.
If you can't use Metasploit and only want a reverse shell.
CVE-2019-1388
Exploit : https://tinyurl.com/26vn372z
Requirement:
Windows 7
Windows 10 LTSC 10240
Failing on :
LT S C 2 0 1 9
1709
1803
Detailed information about the vulnerability : https://tinyurl.com/svj5y3v
References
icacls - Docs Microsoft
Privilege Escalation Windows - Philip Linghammar
Windows elevation of privileges - Guifre Ruiz
The Open Source Windows Privilege Escalation Cheat Sheet by amAK.xyz and @xxByte
Basic Linux Privilege Escalation
Windows Privilege Escalation Fundamentals
TOPβ10 ways to boost your privileges in Windows systems - hackmag
The SYSTEM Challenge
Windows Privilege Escalation Guide - absolomb's security blog
Chapter 4 - Windows Post-Exploitation - 2 Nov 2017 - dostoevskylabs
Remediation for Microsoft Windows Unquoted Service Path Enumeration Vulnerability -
September 18th, 2016 - Robert Russell
Pentestlab.blog - WPE-01 - Stored Credentials
Pentestlab.blog - WPE-02 - Windows Kernel
Pentestlab.blog - WPE-03 - DLL Injection
Pentestlab.blog - WPE-04 - Weak Service Permissions
Pentestlab.blog - WPE-05 - DLL Hijacking
Pentestlab.blog - WPE-06 - Hot Potato
Pentestlab.blog - WPE-07 - Group Policy Preferences
Pentestlab.blog - WPE-08 - Unquoted Service Path
Pentestlab.blog - WPE-09 - Always Install Elevated
Pentestlab.blog - WPE-10 - Token Manipulation
Pentestlab.blog - WPE-11 - Secondary Logon Handle
Pentestlab.blog - WPE-12 - Insecure Registry Permissions
Pentestlab.blog - WPE-13 - Intel SYSRET
Alternative methods of becoming SYSTEM - 20th November 2017 - Adam Chester @ xpn
Living Off The Land Binaries and Scripts (and now also Libraries)
Common Windows Misconfiguration: Services - 2018-09-23 - @am0nsec
Local Privilege Escalation Workshop - Slides.pdf - @sagishahar
Abusing Diaghub - xct - March 07, 2019
Windows Exploitation Tricks: Exploiting Arbitrary File Writes for Local Elevation of Privilege -
James Forshaw, Project Zero - Wednesday, April 18, 2018
Weaponizing Privileged File Writes with the USO Service - Part 2/2 - itm4n - August 19,
2019
Hacking Trick: Environment Variable $Path Interception y Escaladas de Privilegios para
Windows
Abusing SeLoadDriverPrivilege for privilege escalation - 14 JUN 2018 - OSCAR MALLO
Universal Privilege Escalation and Persistence β Printer - AUGUST 2, 2021)
ABUSING ARBITRARY FILE DELETES TO ESCALATE PRIVILEGE AND OTHER GREAT TRICKS
March 17, 2022 | Simon Zuckerbraun
Bypassing AppLocker by abusing HashInfo - 2022-08-19 - Ian
Giving JuicyPotato a second chance: JuicyPotatoNG - @decoder_it, @splinter_code
IN THE POTATO FAMILY, I WANT THEM ALL - @BlWasp_
Potatoes - Windows Privilege Escalation - Jorge Lajara - November 22, 2020
This is a offline tool, your data stays locally and is not send to any server!
Last updated