Bandit 22 → 23
Goal: read the password the bandit23 cron job writes to a file named from its own username.
Approach
Section titled “Approach”bandit22@bandit:~$ cat /usr/bin/cronjob_bandit23.sh#!/bin/bashmyname=$(whoami)mytarget=$(echo I am user $myname | md5sum | cut -d ' ' -f 1)echo "Copying passwordfile /etc/bandit_pass/$myname to /tmp/$mytarget"cat /etc/bandit_pass/$myname > /tmp/$mytargetbandit22@bandit:~$ echo I am user bandit23 | md5sum | cut -d ' ' -f 18ca319486bfbbc3663ea0fbe81326349bandit22@bandit:~$ cat /tmp/8ca319486bfbbc3663ea0fbe81326349The password you are looking for is: <password>Password
0Zf11ioIjMVN551jX3CmStKLYqjk54GaWhy it works
Section titled “Why it works”The job runs as bandit23 and stores its password under /tmp in a file named by the MD5 hash of a fixed string. MD5 is deterministic, so the same input always yields the same name. Recomputing it locally tells you exactly where to look. A predictable filename is not a secret one.