#Why this matters
Initial access on a server or workstation usually lands you inside a restricted account such as www-data or a low-privilege domain user. Privilege escalation determines whether an attacker stays boxed inside that account or gains full administrative control over the host, credentials in memory, and trusted lateral paths.
Rushing to launch kernel exploits is dangerous and unreliable: a mismatched kernel exploit can crash a target system outright. An effective tester or defender uses a disciplined workflow that evaluates deterministic misconfigurations first, verifies impact safely, and translates every finding into a concrete hardening step.
#The privilege escalation workflow
Privilege escalation is a funnel, not a guessing game. You begin with the situational awareness data you already collected, test low-risk configuration flaws first, and resort to riskier techniques only when authorised and strictly necessary.
- Review contextCheck user, groups, OS & running services
- Quick winsInspect sudo -l, whoami /priv & credential stores
- Permissions auditCheck SUID, capabilities, cron, service ACLs & paths
- Safe verificationRun minimal PoC (id / whoami) via misconfigured binary
- Document & fixRecord exact rule or ACL and recommend least privilege
Why does order matter? Configuration weaknesses (an overly broad sudo rule, a writable service binary, or an unquoted service path) are predictable, reversible, and safe to prove. Kernel exploits are fragile, noisy, and often out of scope unless explicitly permitted.
#Linux escalation vectors: sudo, SUID, capabilities and jobs
On Linux systems, four categories account for the vast majority of practical privilege escalation paths:
sudodelegation rules (sudo -l): Administrators sometimes grantNOPASSWDaccess to a utility such asless,vim,find,awk, orpython3so a service user can inspect logs or run a helper script. Many standard Unix tools include built-in shell escapes or command-execution flags. GTFOBins documents these behaviors so testers and defenders can recognise when allowing a binary throughsudoeffectively grants a root shell.- SUID and SGID binaries: When an executable owned by
roothas the SUID bit (4000) set, any user who runs it temporarily inheritsrooteffective permissions. Custom SUID scripts or misconfigured standard binaries on GTFOBins can expose a direct escalation path. - Linux capabilities: Instead of full SUID
root, modern Linux uses fine-grained capabilities (man 7 capabilities). However, grantingcap_setuid+epto an interpreter likepython3lets a caller change their UID to0just as effectively as SUIDroot. - Scheduled jobs and writable services: A
rootcron job orsystemdunit that executes a world-writable script, or references an unqualified binary name when a writable directory sits early inPATH, allows a local user to influence what runs asroot.
$ id
uid=1001(analyst) gid=1001(analyst) groups=1001(analyst)
$ sudo -l
Matching Defaults entries for analyst on web01:
env_reset, mail_badpass, secure_path=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
User analyst may run the following commands on web01:
(root) NOPASSWD: /usr/bin/find
$ find / -perm -4000 -type f 2>/dev/null | grep -E "local|custom|vim"
/usr/local/bin/backup-helper
$ getcap -r / 2>/dev/null
/usr/bin/ping = cap_net_raw+epIn this lab output, sudo -l immediately stands out: user analyst can run /usr/bin/find as root without a password. Checking the GTFOBins entry for find confirms that -exec spawns a command in the elevated context. A safe, non-destructive proof of concept simply checks the resulting identity without modifying any files:
$ sudo /usr/bin/find . -exec /usr/bin/id \; -quit
uid=0(root) gid=0(root) euid=0(root) groups=0(root)Notice how clean that proof is: one line of output confirms uid=0(root) without adding backdoor accounts, editing /etc/sudoers, or leaving artifacts behind.
#Windows escalation vectors: tokens, services and LOLBAS
Windows privilege escalation follows the same structured logic, adapted to Windows access tokens, the Service Control Manager (SCM), and registry permissions.
| Vector class | What to inspect | Typical indicator |
|---|---|---|
| Token privileges | whoami /priv |
SeImpersonatePrivilege or SeAssignPrimaryTokenPrivilege enabled on a service account |
| Service permissions | sc qc <svc> and ACL checks |
Standard user holds write rights to a service binary or service configuration |
| Unquoted service paths | Service BINARY_PATH_NAME |
Path contains spaces without quotes, e.g., C:\Program Files\App\svc.exe with writable parent folder |
| Scheduled tasks & registry | schtasks /query, AlwaysInstallElevated |
Task runs as SYSTEM from a user-writable directory, or AlwaysInstallElevated enabled in both HKLM and HKCU |
Just as GTFOBins catalogs Unix binaries, the LOLBAS project catalogs legitimate, Microsoft-signed Windows binaries, scripts, and libraries (certutil.exe, msbuild.exe, rundll32.exe, and others). When an overly permissive AppLocker policy, scheduled task, or service wrapper allows a user to control arguments passed to a LOLBAS binary, that trusted binary can execute arbitrary code or proxy execution inside a higher-integrity context while blending in with normal system activity.
Look closely at whoami /priv on Windows targets:
C:\> whoami /priv
PRIVILEGES INFORMATION
----------------------
Privilege Name Description State
============================= ========================================= ========
SeAssignPrimaryTokenPrivilege Replace a process level token Disabled
SeIncreaseQuotaPrivilege Adjust memory quotas for a process Disabled
SeImpersonatePrivilege Impersonate a client after authentication Enabled
SeChangeNotifyPrivilege Bypass traverse checking EnabledSeeing SeImpersonatePrivilege set to Enabled is normal for IIS or SQL service accounts, because services legitimately impersonate client tokens. However, if a tester already has code execution under that service account, SeImpersonatePrivilege signals a high-probability path toward NT AUTHORITY\SYSTEM via token impersonation mechanics in a lab.
#Defending and common mistakes
Testers frequently undermine their own findings by skipping fundamentals:
- Jumping straight to kernel exploits before checking
sudo -l, SUID/capabilities, or service ACLs. - Assuming a
sudorule is safe because it points to a "read-only" tool likeless,more,tail(with certain wrappers), orfind. - Reporting theoretical
SeImpersonatePrivilegefindings without distinguishing whether the compromised account already holds service-level rights or is a plain unprivileged user.
Defenders can eliminate most local privilege escalation paths through disciplined configuration management:
- Harden
sudoers: Avoid grantingsudoto interactive tools, pagers, editors, or interpreters. Where a command must be delegated, pin exact arguments, useNOEXECwhen shell escapes are unnecessary, and review rules withvisudo. - Audit SUID and capabilities regularly: Strip unnecessary SUID bits and verify that no scripting language holds
cap_setuid. - Fix Windows service hygiene: Always quote service binary paths, restrict folder and service ACLs so non-admins cannot modify binaries or registry keys, and avoid enabling
AlwaysInstallElevated. - Monitor unexpected child processes: Alert when service accounts or GTFOBins/LOLBAS binaries spawn interactive shells (
sh,bash,cmd.exe,powershell.exe) or when processes perform rapid SUID/ACL discovery sweeps.
#Summary
- An applied privilege escalation workflow prioritizes deterministic misconfigurations (
sudo, SUID, capabilities, token privileges, service ACLs) over risky kernel exploits. - GTFOBins (Linux) and LOLBAS (Windows) document how legitimate, trusted binaries become escalation or execution vectors when exposed through loose permissions.
- Safe proof of concept relies on minimal, read-only verification such as
idorwhoamiand never modifies system accounts or production files. - Remediation focuses on strict least privilege: minimal
sudoersrules, clean SUID/capability baselines, quoted and ACL-protected Windows services, and behavioral monitoring of trusted binaries.