Cron jobs are scheduled tasks that run automatically at specified times. When a cron job runs as root but has writable scripts or uses unsafe practices, it becomes a privilege escalation vector that executes on schedule.
Think of cron jobs as robots that wake up at set times and do tasks. If a root robot is running a script you can modify, you've just scheduled yourself a root shell. The tricky part is finding these jobs - some are hidden from regular enumeration.
Timing Matters
Unlike SUID or sudo exploits that work immediately, cron exploitation requires waiting for the job to run. Check the schedule - hourly, daily, or every minute?
Cron Job Locations
Crontab Syntax
Finding Cron Jobs
Direct Enumeration
Finding Hidden Cron Jobs with pspy
pspy is Essential
Some cron jobs aren't visible in crontab files (root's crontab, hidden files, etc.). pspy reveals them by watching process creation in real-time.
Analyzing Cron Jobs
Checking Script Security
Common Cron Vulnerabilities
Wait for Execution
After modifying a cron-related file, you must wait for the job to run. Check the schedule - if it's daily, you might wait hours. Consider the timing during engagements.
Process Monitoring Without pspy
Cron Enumeration Methodology
Cron Enumeration Flow
1
Check crontabcat /etc/crontab and /etc/cron.d/*
2
Cron directoriesls /etc/cron.hourly/, daily/, etc.
3
User crontabscrontab -l and spool directories
4
Systemd timerssystemctl list-timers
5
pspyRun to find hidden scheduled tasks
6
AnalyzeCheck script permissions and content
Knowledge Check
Challenges
Key Takeaways
- Check /etc/crontab, /etc/cron.d/, and cron.hourly/daily/weekly/
- User crontabs are in /var/spool/cron/crontabs/
- pspy reveals hidden cron jobs by monitoring processes
- Look for writable scripts and directories
- PATH manipulation works when scripts use relative commands
- Always check when jobs run - you may need to wait