NEWPractise supported commands in browser simulations, alongside the lesson.Try a browser practice exercise.Try a lab♥ Codelivly is 100% free, no paywall. If it helped you, chip in to keep it running.100% free. Help keep it so.Support us
Preview · 30 min
Master wildcard injection techniques using commands like tar to execute arbitrary code as root. Learn to schedule stealthy, one-off tasks using the at daemon.
The last lesson mentioned wildcard injection. Here you learn to detect and prevent it. You also meet cron's partner for one-time jobs: the at daemon. Attackers like at because it is often watched less closely than cron.
When a command contains a wildcard like *, the shell replaces it with the list of matching file names before the program starts. The program never sees the * — only the names. And a program cannot tell a file name that starts with - from an option you typed.
So if a root cron job runs
cd /var/www/html && /usr/bin/tar -czf /var/backups/www.tgz *
in a folder where another user (for example www-data after a web exploit) can create files, that user decides part of root's command line. GNU tar has options that run a command during the backup (its checkpoint options: --checkpoint and --checkpoint-action), so option-shaped file names can turn a backup into code running as root.
Create a free account to unlock the rest of this task, complete tasks, and earn Rep.
Sign in