OverTheWire.org Walkthrough: Bandit

~ Level 21→22 ~

Level Description

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.

Commands that we may need to solve this level include: cron, crontab, and crontab(5) (use “man 5 crontab” to access this)


Research Before Solving

cron is a time-based job scheduler. It allows someone to write a script and then set intervals for when the script should be ran. This tool makes repetive work, such as backing up files, much easier.


Solution Walkthrough

Log in as bandit21. The level description tells us to navigate to the /etc/cron.d/ directory where we can find a command being executed. After navigating to the directory we will use ls to list all files.

files in cron.d directory

Next, we will cat the file named cronjob_bandit22 as that is the next level.

contents of cronjob_bandit22

Here we see a script file by the name of cronjob_bandit22.sh. Next, we will use cat on the script file to see its contents.

contents of cronjob_bandit22.sh

The script first sets the permissions of a file. Next, the password to bandit24 is read and the results are put into the same file where permissions were set. With this being said, we should be able to cat the contents of the /tmp/t7O6lds9S0RqQh9aMcz6ShpAoZKF7fgv file.

password for bandit22

We are indeed shown the password for bandit22: Yk7owGAcWjwMVRwrTesJEwB7WVOiILLI. Record it, exit the session, and continue to the next level!