Privilege Escalation (PrivEsc)
NOTE: scripts are noisy for any sort of monitoring software, so manual checks may be preferred
Key Details
Versions of:
- OS
- Kernel
- Services
- Installed packages
- Logged-in users
- User Directories
- Command/Shell History
- Configuration Files
- Scheduled Jobs
- Extra File Systems/Drives
- File Permissions
- Writeable Files and Directories
🐧 Linux
- https://book.hacktricks.wiki/en/linux-hardening/linux-privilege-escalation-checklist.html
- https://swisskyrepo.github.io/InternalAllTheThings/redteam/escalation/linux-privilege-escalation/
- https://github.com/peass-ng/PEASS-ng/blob/master/linPEAS/README.md
- https://gtfobins.github.io/
+file download+file upload
linPEAS
Manual Survey
File Permissions
Standard Permission Bits
| Permission | Octal | Symbol | Meaning on File | Meaning on Directory |
|---|---|---|---|---|
| Read | 4 | r | Can read file contents (cat). | Can list contents (ls). |
| Write | 2 | w | Can modify file contents. | Can add/delete files inside. |
| Execute | 1 | x | Can run the file as a process. | Can enter the directory (cd). |
Special Permission Bits
| Special Bit | Octal | Symbol | Location | Offensive Value (PrivEsc / Persistence) |
|---|---|---|---|---|
| SUID (Set-User-ID) | 4000 | s / S | Owner (-rwS------) | High: Process runs with the privileges of the file Owner (usually root), regardless of who launched it. |
| SGID (Set-Group-ID) | 2000 | s / S | Group (----rws---) | Medium: Process runs with privileges of the file Group. Used for lateral movement (e.g., accessing adm or shadow group files). |
| Sticky Bit | 1000 | t / T | Other (-------rwt) | None: Prevents users from deleting other users’ files in shared directories (like /tmp). |
NOTE:
The Lowercase s vs. Uppercase S
- Lowercase
s(Active): The SUID bit is set AND the underlying execute (x) bit is set. The file will execute properly. - Uppercase
S(Broken): The SUID bit is set, BUT the underlying execute (x) bit is missing. The file cannot be executed. The admin made a mistake.
The Linux Kernel natively ignores SUID/SGID bits on interpreted scripts (.sh, .py, .pl).
- If you find
-rwsr-xr-x root root backup.sh, running./backup.shwill execute as YOUR user, not root. - The Exception: SUID only works automatically on Compiled ELF Binaries (C, C++, Go, Rust).
Groups
Certain groups for a user’s id output could give greater access:
disk: can mount any disk withdebugfsto read the file systemadm: reads logs in/var/log/docker: priv esclxd/lxc: can mount filesystems in LXC containersshadow: allows read access of password hashesstaff: grants perms to/usr/local/bin/and/usr/local/sbin/wireshark/pcap: capture network traffic (creds sniffing)video: can screenshot user’s desktopwheel: Red Hat/CentOS equivalent tosudo
Capabilities
The following especially can lead to root:
| Capability | Description |
|---|---|
cap_setuid | Allows a process to set its effective user ID, which can be used to gain the privileges of another user, including the root user. |
cap_setgid | Allows to set its effective group ID, which can be used to gain the privileges of another group, including the root group. |
cap_sys_admin | This capability provides a broad range of administrative privileges, including the ability to perform many actions reserved for the root user, such as modifying system settings and mounting and unmounting file systems. |
cap_dac_override | Allows bypassing of file read, write, and execute permission checks. |
Mitigation
A straightforward tool to assess the security posture of UNIX devices is:
Kubernetes
Control Plane
The Control Plane serves as the management layer. It consists of several crucial components, including:
| Service | TCP Ports |
|---|---|
etcd | 2379, 2380 |
API server | 6443 |
Scheduler | 10251 |
Controller Manager | 10252 |
Kubelet API | 10250 |
Read-Only Kubelet API | 10255 |
privesc.yaml
This mount the host’s root file system
🪟 Windows
Check [[active-directory]] for a whole host of domain-related priv escs. Check [[security-products]] for bypasses for UAC and more. Check [[finding-creds]] for searching for credentials.
- https://book.hacktricks.wiki/en/windows-hardening/checklist-windows-privilege-escalation.html
- https://swisskyrepo.github.io/InternalAllTheThings/redteam/escalation/windows-privilege-escalation/
- SysInternals: https://learn.microsoft.com/en-us/sysinternals/downloads/sysinternals-suite
- Exploit Suggester:
systeminfoparser: https://github.com/bitsadmin/wesng- WinPEAS (Priv Esc Checker): https://github.com/peass-ng/PEASS-ng/tree/master/winPEAS
- Seatbelt: https://github.com/GhostPack/Seatbelt
- PowerShell Scripts: https://github.com/samratashok/nishang
- Living Off the Land: https://lolbas-project.github.io/
/upload/download
- Windows Commands: https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/windows-commands
- End-of-Life for Updates: https://michaelspice.net/windows/end-of-life-microsoft-windows-and-office/
systeminfo wesng.py Analyzer
SharpUp
winPEAS
Manual Survey
Normal processes:
- Session Manager Subsystem (smss.exe)
- Client Server Runtime Subsystem (csrss.exe)
- WinLogon (winlogon.exe)
- Local Security Authority Subsystem Service (LSASS)
- Service Host (svchost.exe)
Privileges vs. Access Rights
https://blog.palantir.com/windows-privilege-abuse-auditing-detection-and-defense-3078a403d74e
Privileges are tied to WHO/the user’s access token (assigned on logon, can differ local and domain), which are essentially overrides to bypass the normal rules (access rights)
- SeTakeOwnershipPrivilege: Allows you to change the Owner of any object. Once you are the Owner, Windows automatically grants you the Access Right to rewrite the DACL (known as
WRITE_DAC). You can then grant yourselfGenericAllAccess Rights. - SeImpersonatePrivilege: Allows you to copy a higher-privileged Token (e.g.,
NT AUTHORITY\SYSTEMvia tools like SweetPotato/PrintSpoofer), instantly granting you all System Privileges and Universal Access Rights.
- SeTakeOwnershipPrivilege: Allows you to change the Owner of any object. Once you are the Owner, Windows automatically grants you the Access Right to rewrite the DACL (known as
Access Rights (permissions) are tied to WHAT/the object (File, Folder, Registry Key, Service, Named Pipe) via “Security Descriptors”
Security Principals are the WHO/users, machines, or groups** that have their own SIDs
- **groups cannot login but have Access Rights
When a Security Principal (e.g. user) wants to access a resource (e.g. file), the OS will perform an authorization check of the user against the resource’s Security Descriptor (e.g. access rights). The Security Descriptor might have multiple Access Control Entries, which will grant access if there is at least 1 match.

Good Privileges
| Setting Constant | Setting Name | Standard Assignment | Description |
|---|---|---|---|
| SeNetworkLogonRight | Access this computer from the network | Administrators, Authenticated Users | Determines which users can connect to the device from the network. This is required by network protocols such as SMB, NetBIOS, CIFS, and COM+. |
| SeRemoteInteractiveLogonRight | Allow log on through Remote Desktop Services | Administrators, Remote Desktop Users | This policy setting determines which users or groups can access the login screen of a remote device through a Remote Desktop Services connection. A user can establish a Remote Desktop Services connection to a particular server but not be able to log on to the console of that same server. |
| SeBackupPrivilege | Back up files and directories | Administrators | This user right determines which users can bypass file and directory, registry, and other persistent object permissions for the purposes of backing up the system. |
| SeSecurityPrivilege | Manage auditing and security log | Administrators | This policy setting determines which users can specify object access audit options for individual resources such as files, Active Directory objects, and registry keys. These objects specify their system access control lists (SACL). A user assigned this user right can also view and clear the Security log in Event Viewer. |
| SeTakeOwnershipPrivilege | Take ownership of files or other objects | Administrators | This policy setting determines which users can take ownership of any securable object in the device, including Active Directory objects, NTFS files and folders, printers, registry keys, services, processes, and threads. |
| SeDebugPrivilege | Debug programs | Administrators | This policy setting determines which users can attach to or open any process, even a process they do not own. Developers who are debugging their applications do not need this user right. Developers who are debugging new system components need this user right. This user right provides access to sensitive and critical operating system components. |
| SeImpersonatePrivilege | Impersonate a client after authentication | Administrators, Local Service, Network Service, Service | This policy setting determines which programs are allowed to impersonate a user or another specified account and act on behalf of the user. |
| SeLoadDriverPrivilege | Load and unload device drivers | Administrators | This policy setting determines which users can dynamically load and unload device drivers. This user right is not required if a signed driver for the new hardware already exists in the driver.cab file on the device. Device drivers run as highly privileged code. |
| SeRestorePrivilege | Restore files and directories | Administrators | This security setting determines which users can bypass file, directory, registry, and other persistent object permissions when they restore backed up files and directories. It determines which users can set valid security principals as the owner of an object. |
| SeTcbPrivilege | Act as part of the operating system | Administrators, Local Service, Network Service, Service | This security setting determines whether a process can assume the identity of any user and, through this, obtain access to resources that the targeted user is permitted to access (impersonation). This may be assigned to antivirus or backup tools that need the ability to access all system files for scans or backups. This privilege should be reserved for service accounts requiring this access for legitimate activities. |
Good Accounts
| Account | Description |
|---|---|
NT AUTHORITY\SYSTEM / LocalSystem | A highly privileged account with more privileges than a local administrator; used to run most Windows services. See LocalSystem account. |
Built-in local Administrator | The built-in local administrator account. Some organizations disable this account, but many do not. It is not uncommon to see this account reused across multiple systems in a client environment. |
Local member of Administrators | Another local account in the local Administrators group. Any account in this group has the same privileges as the built-in Administrator account. |
Domain user in local Administrators | A standard (non-privileged) domain user who is part of the local Administrators group. |
Domain admin in local Administrators | A domain admin (highly privileged in Active Directory) that is part of the local Administrators group. |
Good Groups
| Group | Description |
|---|---|
| Default Administrators | Domain Admins and Enterprise Admins are “super” groups. |
| Server Operators | Members can modify services, access SMB shares, and backup files. |
| Backup Operators | Members are allowed to log onto DCs locally and should be considered Domain Admins. They can make shadow copies of the SAM/NTDS database, read the registry remotely, and access the file system on the DC via SMB. This group is sometimes added to the local Backup Operators group on non-DCs. |
| Print Operators | Members can log on to DCs locally and “trick” Windows into loading a malicious driver. |
| Hyper-V Administrators | If there are virtual DCs, any virtualization admins, such as members of Hyper-V Administrators, should be considered Domain Admins. |
| Account Operators | Members can modify non-protected accounts and groups in the domain. |
| Remote Desktop Users | Members are not given any useful permissions by default but are often granted additional rights such as Allow Login Through Remote Desktop Services and can move laterally using the RDP protocol. |
| Remote Management Users | Members can log on to DCs with PSRemoting (This group is sometimes added to the local remote management group on non-DCs). |
| Group Policy Creator Owners | Members can create new GPOs but would need to be delegated additional permissions to link GPOs to a container such as a domain or OU. |
| Schema Admins | Members can modify the Active Directory schema structure and backdoor any to-be-created Group/GPO by adding a compromised account to the default object ACL. |
| DNS Admins | Members can load a DLL on a DC, but do not have the necessary permissions to restart the DNS server. They can load a malicious DLL and wait for a reboot as a persistence mechanism. Loading a DLL will often result in the service crashing. A more reliable way to exploit this group is to create a WPAD record. |
File/Folder Permissions
Look for F, M, or W assigned to unprivileged groups.
| Code | Meaning | Offensive Value |
|---|---|---|
| F | Full Control | Jackpot. You can overwrite the file, read it, delete it, or change its permissions. |
| M | Modify | High. You can read, write, and delete the file. (Functionally identical to F for hijacking). |
| W | Write | High. You can overwrite the file with a malicious payload (e.g., a reverse shell .exe). |
| RX | Read & Execute | None (Usually). You can read the file and run it, but you cannot alter it. |
| R | Read | Low. Useful only for stealing configuration files or hardcoded credentials. |
| Code | Meaning | Context |
|---|---|---|
| (I) | Inherited | This permission wasn’t set on the file itself; it was passed down from the parent folder (e.g., C:\Program Files). |
| (OI) | Object Inherit | Applied to a folder: All files inside will inherit this permission. |
| (CI) | Container Inherit | Applied to a folder: All sub-folders inside will inherit this permission. |
| (IO) | Inherit Only | This permission applies only to children, not the current folder itself. |
Exploits
via Meterpreter session:
via SeImpersonate
SeImpersonate: https://learn.microsoft.com/en-us/troubleshoot/windows-server/windows-security/seimpersonateprivilege-secreateglobalprivilege
JuicyPotato
- https://github.com/ohpe/juicy-potato
- Windows 7, 8.1, 10 (Versions prior to 1809)
- Windows Server 2008 & 2008 R2
- Windows Server 2012 & 2012 R2
- Windows Server 2016
Needs SeImpersonate or SeAssignPrimaryToken
RoguePotato/GodPotato/PrintSpoofer/PrintNightmare
- https://github.com/antonioCoco/RoguePotato
- Windows 10 (1809+)
- Windows Server 2019, 2022
- https://github.com/BeichenDream/GodPotato
- Windows 8 - 11
- Windows Server 2012 - 2022
- https://github.com/itm4n/PrintSpoofer
- Windows 8.1, 10
- Windows Server 2012, 2016, 2019
- https://github.com/calebstewart/CVE-2021-1675
- Tested on Windows Server 2016, 2019
Needs SeImpersonate (or equivalent for the tool chain). Upload the chosen binary and nc.exe (or use built-in shells where documented).
RoguePotato (usage): -r is the redirector (usually your attacker host); -e is the full command line; -l runs RogueOxidResolver locally on that port (all-in-one). Optional: -c {clsid}, -p / -z pipe name.
GodPotato (example): only -cmd is required; the tool supplies CLSID behavior internally.
PrintSpoofer (usage): -c runs the command as SYSTEM; -i attaches an interactive SYSTEM process to the current console (bind/reverse/psexec-style shells).
PrintNightmare (usage): PowerShell via the Print Spooler (Invoke-Nightmare). By default, it creates local admin adm1n with password P@ssw0rd; use parameters to set custom credentials or load a custom DLL payload.
via SeDebug
via SeTakeOwnership
NOTE: this is considered dangerous and destructive since not only can it be hard to revert but also could have unintended consequences and breakages for services that use the file
Python
The following logic can be placed under a particular module’s function (ideally at the beginning of the function) to achieve a priv esc: