Bandit 21 → 22
Goal: find the password that a scheduled job copies into a file in /tmp.
Approach
Section titled “Approach”bandit21@bandit:~$ cat /etc/cron.d/cronjob_bandit22@reboot bandit22 /usr/bin/cronjob_bandit22.sh &> /dev/null* * * * * bandit22 /usr/bin/cronjob_bandit22.sh &> /dev/nullbandit21@bandit:~$ cat /usr/bin/cronjob_bandit22.sh#!/bin/bashchmod 644 /tmp/t7O6lds9S0RqQh9aMcz6ShpAoZKF7fgvcat /etc/bandit_pass/bandit22 > /tmp/t7O6lds9S0RqQh9aMcz6ShpAoZKF7fgvbandit21@bandit:~$ cat /tmp/t7O6lds9S0RqQh9aMcz6ShpAoZKF7fgvThe password you are looking for is: <password>Password
tRae0UfB9v0UzbCdn9cY0gQnds9GF58QWhy it works
Section titled “Why it works”Files in /etc/cron.d declare a job and the user it runs as. This one runs as bandit22 every minute and writes that user’s password to a fixed /tmp path with mode 644 (world-readable), so reading the leaked output takes no privileges at all.