Previous Level: Level 22
Login
SSH: ssh bandit22@bandit.labs.overthewire.org -p 2220
Password: Yk7owGAcWjwMVRwrTesJEwB7WVOiILLI
Task
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.
A little bit of Theory
In the previous level I already explained the theory of cronjobs.
The new thing in this task is variables in bash scripting. A variable is like a container for a value. To declare a variable in bash scripting use the following syntax: var_name=var_value
. It is possible to save the output of a command in a variable with the following syntax: var_name=$(command)
. Access the value of an existing variable like this: $var_name
Solution
We will start the same way as in level 22:
|
|
Looking at the ‘/usr/bin/cronjob_bandit23.sh’ script, the last line is similar to level 22. This script just introduces variables. The first variable is ‘myname’ and saves the output from the whoami
command. Because this script will be run as bandit23, the whoami
command will print ‘bandit23’. So the last line tells us that the password from bandit23 will be written into a file in the ‘/tmp’ folder. The filename is created by the line echo I am user $myname | md5sum | cut -d ' ' -f 1
. We only need to substitute $myname
with bandit23
, execute it and the result is the filename.
|
|
The line to create the filename inputs the string “I am user bandit23” into md5sum, which will return the md5 hash from the string. The last instruction removes everything after the space. You can test out for yourself what it would look like without this line.
https://overthewire.org/wargames/bandit/bandit23.html
Next Level: Level 24