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)

PathHow to spot itFix
Sudo rules that allow a program which can run a shell (find, vim, less, python, tar)sudo -l; check the program on GTFOBinsGrant only specific scripts, never editors or interpreters; avoid NOPASSWD
Unusual SUID binariesfind / -perm -4000 -type f 2>/dev/nullRemove the SUID bit from anything that does not need it
Writable scripts run by root's croncat /etc/crontab, ls -l on each scriptRoot's scripts must be owned and writable by root only
Credentials in filesConfig files, .bash_history, backups, environment variablesSecrets manager; clean history; file permissions
Capabilities (e.g. cap_setuid on python)getcap -r / 2>/dev/nullRemove unneeded capabilities
Writable /etc/passwd or service filesls -lCorrect ownership and permissions
Kernel exploitsuname -a vs known CVEsPatch; reboot into new kernels
Docker group membershipidThe 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 to C:\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.

Lab: from www-data to root on a training box

1. Check who you are and your groups.

www-data@training:/var/www/html$

Check your understanding0 of 4 correct

Question 1

1.Why is 'NOPASSWD: /usr/bin/vim' in sudoers dangerous?

Question 2

2.A root cron job runs /opt/cleanup.sh, which is world-writable. What can an attacker do?

Question 3

3.Which Windows weakness involves C:\Program Files\Acme App\svc.exe without quotes?

Question 4

4.Membership of which Linux group is effectively root?

Quiz score: 0 of 4

Tip: answer every quiz question correctly first.

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.