Skip to main content
Applied Privilege Escalation Workflow (Linux & Windows)
Lesson 23 of 26

Applied Privilege Escalation Workflow (Linux & Windows)

Follow a repeatable privilege escalation workflow across Linux and Windows, evaluate misconfigurations such as sudo, SUID, capabilities, and token privileges before kernel exploits, and validate and remediate findings safely.

Advanced 34 min Pentesting
Authorised environments only — The techniques described here are used only in training labs and on systems you own or have written permission to test.

Learning objectives

  • Apply a structured triage workflow that prioritizes configuration flaws over unstable kernel exploits
  • Identify Linux privilege escalation paths involving sudo rules, SUID binaries, capabilities, and scheduled jobs
  • Identify Windows privilege escalation vectors including token privileges, weak service permissions, and LOLBAS abuse
  • Validate privilege boundaries safely in a lab using GTFOBins and LOLBAS references and recommend targeted fixes

Recommended first: Exploitation Basics, Payloads & Reverse/Bind ShellsCredential Reuse, Spraying Limits & Service MisconfigsPost-Exploitation Enumeration & Safe Artifact Handling

#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.

  1. Review contextCheck user, groups, OS & running services
  2. Quick winsInspect sudo -l, whoami /priv & credential stores
  3. Permissions auditCheck SUID, capabilities, cron, service ACLs & paths
  4. Safe verificationRun minimal PoC (id / whoami) via misconfigured binary
  5. 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:

  1. sudo delegation rules (sudo -l): Administrators sometimes grant NOPASSWD access to a utility such as less, vim, find, awk, or python3 so 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 through sudo effectively grants a root shell.
  2. SUID and SGID binaries: When an executable owned by root has the SUID bit (4000) set, any user who runs it temporarily inherits root effective permissions. Custom SUID scripts or misconfigured standard binaries on GTFOBins can expose a direct escalation path.
  3. Linux capabilities: Instead of full SUID root, modern Linux uses fine-grained capabilities (man 7 capabilities). However, granting cap_setuid+ep to an interpreter like python3 lets a caller change their UID to 0 just as effectively as SUID root.
  4. Scheduled jobs and writable services: A root cron job or systemd unit that executes a world-writable script, or references an unqualified binary name when a writable directory sits early in PATH, allows a local user to influence what runs as root.
Inspecting Linux privilege boundaries in a lab (lab.local)
$ 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+ep

In 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:

Safe lab verification of the sudo rule
$ 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:

Checking Windows token privileges in a lab
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                  Enabled

Seeing 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 sudo rule is safe because it points to a "read-only" tool like less, more, tail (with certain wrappers), or find.
  • Reporting theoretical SeImpersonatePrivilege findings 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 granting sudo to interactive tools, pagers, editors, or interpreters. Where a command must be delegated, pin exact arguments, use NOEXEC when shell escapes are unnecessary, and review rules with visudo.
  • 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 id or whoami and never modifies system accounts or production files.
  • Remediation focuses on strict least privilege: minimal sudoers rules, clean SUID/capability baselines, quoted and ACL-protected Windows services, and behavioral monitoring of trusted binaries.

Knowledge check

Sign in to take the test, complete lessons and save your progress. Log in

Practice: test your knowledge