sudo (Super User DO) allows users to run commands as other users (usually root). It's the gatekeeper between regular users and root power. Misconfigured sudo is one of the EASIEST privilege escalation vectors in CTFs and real environments.
Think of sudo as a very specific security guard. They check a list (sudoers) to see what you're allowed to do. If the list says "webuser can run vim as root" - that's it, you're root. The guard doesn't know vim can spawn shells.
First Thing to Check
"sudo -l" should be one of the FIRST commands you run after getting a shell. Many privilege escalations come directly from sudo misconfigurations.
Understanding Sudo
Sudoers Syntax
NOPASSWD is Key
Entries with NOPASSWD don't require the user's password. Without it, you need to know the user's password to use sudo. NOPASSWD entries are instant wins.
Sudo Enumeration
Understanding the Output
Sudo Version Check
Common Misconfigurations
ALL Permissions
NOPASSWD Entries
Script Permissions
Environment Preservation
GTFOBins for Sudo
GTFOBins has a sudo section for each binary. If sudo allows a binary, check there first.Related
Always Check GTFOBins
Even if a command seems restricted, GTFOBins often has creative exploitation methods. sudo -l + GTFOBins = frequent easy wins.
Bypassing Restrictions
Sudo Enumeration Methodology
Sudo Attack Flow
1
Check Permissionssudo -l (ALWAYS first)
2
Versionsudo --version (check for CVEs)
3
GTFOBinsLook up each allowed command
4
NOPASSWDPrioritize NOPASSWD entries
5
ScriptsCheck if allowed scripts are writable
6
ExploitUse appropriate technique
Knowledge Check
Challenges
Key Takeaways
- Always run "sudo -l" first during enumeration
- NOPASSWD entries don't require password - easiest wins
- Check each allowed binary on GTFOBins
- Even restricted commands often have shell escapes
- Check sudo version for known CVEs
- Writable scripts in sudo = immediate escalation