~ Level 23→24 ~
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.
NOTE: This level requires you to create your own first shell-script. This is a very big step and you should be proud of yourself when you beat this level!
NOTE 2: Keep in mind that your shell script is removed once executed, so you may want to keep a copy around…
Commands that may be used: cron, crontab, and crontab(5) (use “man 5 crontab” to access this)
Research Before Solving
Research will once again be done during the solution walkthrough.
Solution Walkthrough
Log in as bandit23. Navigate to the /etc/cron.d directory and list all contents with ls

Next we will view the contents of the cronjob_bandit24 file with cat.

Next, we must view the contents of the script file with cat /usr/bin/cronjob_bandit24.sh

The script starts by navigating to the /var/spool/$myname directory. A statement is then printed to the screen using echo. The next portion creates a loop. For each file within the directory, except for . (current directory) and .. (previous directory), each file will be executed as bandit24 at the top of every minute. The file will then be deleted from the system. Long story short, we need to write a script that can read the password in the /etc/bandit_pass/ directory and then send the output to a file within the /tmp/user directory where we can access it.
To start this process we will create a directory of /tmp/user and then set it's permissions with chmod 777 /tmp/user. This allows all users the ability to write changes to the directory. Navigate to this directory and create two files using touch . Mine are called meow.sh and password.txt respectively. We must use the .sh extension in order for the file to be ran as a script! We must also set permissions here so that the files can be executed or written to by any user, we do this with chmod 777 filename. Next, use vim meow.sh to edit the script file. Hit i to insert and then write a script as follows:

To exit vim, hit esc then type :wq to write the changes and quit. We now need to use cp to copy the shell script to the /var/spool/bandit24 directory so that it may be ran for us! After that is done, simply wait for a minute or two and check the password file we created inside of the /tmp/user directory.

BOOM! The password is there for us as expected: UoMYTrfrBFHyQXmg6gzctqAwOmw1IohZ
Before moving to the next level, use rm meow.sh password.txt to remove the files we created. Then, move up one directory with cd .. and remove the /user directory with rmdir /tmp/user. You may now move on to the next level!