A Repeatable Privesc Method
A shell is not root. Here is the order you check things in.
What you will learn
- -Stabilize a shell and establish your user context before anything else
- -Follow a fixed enumeration order instead of guessing at exploits
- -Prioritize cheap, safe wins over risky kernel exploits
You popped a as www-data through a file upload bug. The box is not yours
yet. www-data can read the web and not much else, and the flag you want
sits in /root. The gap between that shell and root is almost never a single
clever trick. It is a checklist you run every time, in the same order, so you
never miss the boring misconfiguration that hands you the box.
The first mistake people make is firing off a kernel they found on
Google before they even know what user they are. Slow down. Root is usually
sitting behind a sudo rule or a writable script, and those cost you nothing to
check. The exploit is the last thing you reach for, not the first.
Stabilize the shell first
A raw reverse shell has no job , no tab completion, and dies if you press Ctrl-C. Fix that before you do real work. The Python PTY trick upgrades you to a usable terminal.
$python3 -c 'import pty; pty.spawn("/bin/bash")'$export TERM=xterm$idKnow your context
Before you enumerate the , enumerate yourself. Your user, your groups, and
the OS version decide which whole categories of attack are even worth trying.
A user in the docker or lxd group is basically root already. A user with a
sudo entry might be one command away.
$id; whoami; hostname$sudo -l$uname -a; cat /etc/os-releaseThe order that works
Run these top to bottom. The list is sorted by effort and , cheapest and safest first. Stop the moment one pays off.
sudo -lrights, especially anyNOPASSWDentry.- SUID and SGID binaries you can abuse (next lesson).
- Cron jobs and scripts running as root that you can write to.
- Writable files that root reads or executes, and weak file permissions.
- in config files, history files, and environment variables.
- Group memberships like
docker,lxd,disk,adm. - Kernel and service version, checked against known exploits. Last.
Kernel exploits sit at the bottom for a reason. They can panic the box, and a crashed target on a real engagement means an angry and lost access. Try every misconfiguration first.
Everything here assumes a machine you own or have written permission to test. Running scripts or exploits against a system you are not authorized to touch is a crime in most places, full stop. Practice on your own VMs, Hack The Box, or an engagement with a signed .
Keep a scratch file of every finding: SUID paths, cron entries, cracked creds. Half of privesc is noticing that two boring facts combine into one root shell. You will not hold it all in your head.
You just landed a low-priv shell. Which check should you run first?