Bandit Level 23
Bandit Level 23 — read a shell script run by cron and work out what it computes and for whom.
Source: This content is aggregated from overthewire (MIT). Visit the original repository for the latest version.
Level Goal
A program is running automatically at regular intervals from cron, the time-based job scheduler. Look in /etc/cron.d/ for the configuration and see what command is being executed.
NOTE: Looking at shell scripts written by other people is a very useful skill. The script for this level is intentionally made easy to read. If you are having problems understanding what it does, try executing it to see the debug information it prints.
Commands you may need to solve this level
cron, crontab, crontab(5) (use “man 5 crontab” to access this)
Study guide
Level map: logged in as bandit22, find the password for bandit23.
What this level teaches
Reading shell scripts critically, including who a script runs as.
Key ideas
- Command substitution.
$(command)replaces itself with that command’s output, so scripts can build names or values on the fly. - Identity.
whoamiprints the current user. A script run by cron reports the cron entry’s user, not yours. - Hashing.
md5sumturns any text into a fixed-length fingerprint. A script can use it to derive an unguessable-looking filename from a known string. - Debugging. The Level Goal suggests running the script to see its debug output; try each piece in the terminal individually.
How to approach it
- Read the script slowly and write in your notes what each line does.
- Ask: what value does
whoamireturn when cron runs it, and what string gets hashed? - Reproduce that computation yourself, then look where the script saved its result.
Why it matters
“Security through an obscure filename” fails once the algorithm is visible. Auditing scripts and spotting such patterns is routine code-review work.