Module 14 · Advanced Penetration Testing · Lesson 40 of 75
Privilege escalation on Linux and Windows
Why attackers climb from a normal user to root or SYSTEM, the common misconfigurations that let them, how to enumerate for them, and how defenders close each gap.
In this lesson · about 45 minutes
- Enumerate a Linux host for privilege-escalation paths
- Recognise the main Windows escalation misconfigurations
- Recommend the fix for each path you find
Linux paths (and their fixes)
| Path | How to spot it | Fix |
|---|---|---|
| Sudo rules that allow a program which can run a shell (find, vim, less, python, tar) | sudo -l; check the program on GTFOBins | Grant only specific scripts, never editors or interpreters; avoid NOPASSWD |
| Unusual SUID binaries | find / -perm -4000 -type f 2>/dev/null | Remove the SUID bit from anything that does not need it |
| Writable scripts run by root's cron | cat /etc/crontab, ls -l on each script | Root's scripts must be owned and writable by root only |
| Credentials in files | Config files, .bash_history, backups, environment variables | Secrets manager; clean history; file permissions |
| Capabilities (e.g. cap_setuid on python) | getcap -r / 2>/dev/null | Remove unneeded capabilities |
Writable /etc/passwd or service files | ls -l | Correct ownership and permissions |
| Kernel exploits | uname -a vs known CVEs | Patch; reboot into new kernels |
| Docker group membership | id | The docker group is effectively root; restrict it |
Automated helpers: LinPEAS, linux-smart-enumeration. Read their output critically: they highlight candidates, you confirm.
Windows paths (and their fixes)
- Weak service permissions: a user can change a service's program path or replace its executable. Fix: correct ACLs on services and their folders.
- Unquoted service paths with spaces (
C:\Program Files\Acme App\svc.exe), where a user can write toC:\Program Files\Acme.exe. Fix: quote paths; lock down folders. - Stored credentials: unattended-install files, saved credentials (
cmdkey /list), scripts, browser stores. Fix: remove them; use LAPS and managed identities. - Dangerous privileges on service accounts (SeImpersonatePrivilege) abused by "potato" style techniques. Fix: patch, restrict service account rights.
- AlwaysInstallElevated policy: any MSI installs as SYSTEM. Fix: turn it off.
- Missing patches for local privilege-escalation CVEs.
Helpers: WinPEAS, PowerUp, Seatbelt. Defenders detect many of these with EDR and by monitoring service creation (event 7045) and privilege use.
Hands-on lab (simulated terminal)
Lab: from www-data to root on a training box
Authorised test. You already have a low-privilege shell as www-data on the training VM 10.10.40.35 (from Module 8). Everything is simulated.
Step 1 of 4. Type each command and press Enter. Nothing runs on your computer.
1. Check who you are and your groups.
Check your understanding0 of 4 correct
Quiz score: 0 of 4
Written by Noviq Academy in its own words. All labs are simulations: no real systems are touched, and every name, address, password and hash is made up. The offensive techniques taught here are for defending systems and for authorised testing only; never scan, access or test a system without the owner's written permission. Tool and product names belong to their owners, and command output may differ slightly from yours. Read-aloud uses your device's built-in voices.