You've found cron jobs - now let's exploit them. From writable scripts to wildcard injection, cron jobs offer multiple privilege escalation vectors that execute on schedule without any user interaction.Related
The beauty of cron exploitation is its persistence. Once you've modified a cron script, your payload executes repeatedly. Set up a reverse shell, and it reconnects every time the job runs - even if your initial access is lost.
Timing Your Attack
Plan your exploitation around the cron schedule. A daily job at 3 AM means waiting hours. Consider adjusting payloads to immediately execute or choosing more frequent jobs first.
Writable Script Exploitation
Non-Destructive Payloads
Prefer payloads that don't break the original script functionality. Append to the end rather than replacing content to avoid detection.
Writable Directory Exploitation
PATH Manipulation in Cron
Cron PATH
Cron jobs often have a limited PATH. Check /etc/crontab for the PATH setting. The first writable directory in PATH is your target.
Wildcard Injection
When cron scripts use wildcards (*), you can create files that become malicious command arguments. This is especially powerful with tar, rsync, and chmod.
Tar Wildcard Injection
Rsync Wildcard Injection
Chmod Wildcard Injection
Filename as Argument
The key insight: when wildcards expand, filenames become command-line arguments. A file named "--checkpoint=1" becomes the argument --checkpoint=1 to tar.
Environment Variable Abuse
Creating Persistence
Complete Payload Examples
Cron Exploitation Methodology
Cron Attack Flow
1
IdentifyFind cron jobs running as root
2
AnalyzeCheck script content and permissions
3
VectorChoose: writable script, PATH, wildcard
4
PayloadPrepare appropriate exploit payload
5
DeployInject payload and wait for execution
6
VerifyConfirm root access when cron runs
Knowledge Check
Challenges
Key Takeaways
- Writable cron scripts = immediate root code execution
- PATH manipulation works when scripts use relative commands
- Wildcard injection: filenames become command arguments
- tar --checkpoint-action is the classic wildcard exploit
- Append payloads to maintain stealth and functionality
- SUID bash backdoor provides persistent access