Goal
A cron job runs regularly. For this level you need to create your own first shell script.
Important note: the script is removed once executed.
Hints
- Find the cron runner and where it looks for scripts to execute.
- Put your script in that directory with executable permissions.
- Have your script copy the next password into a file you can read (typically under
/tmp/<unique>).
Solution (click to reveal)
- SSH in:
ssh bandit24@bandit.labs.overthewire.org -p 2220
- Inspect
/etc/cron.dto learn which directory is executed (often something like/var/spool/bandit24/):
cat /etc/cron.d/*
- Create a unique output file:
out=/tmp/bandit24_$RANDOM.txt
- Create a script that writes the next password into that file:
workdir=/var/spool/bandit24
script=$workdir/myjob.sh
cat > "$script" <<'EOF'
#!/bin/sh
cat /etc/bandit_pass/bandit24 > /tmp/bandit24_out.txt
EOF
chmod +x "$script"
- Wait ~1 minute for cron to run, then read the output:
cat /tmp/bandit24_out.txt
That output is the password for Level 25.
Notes
- Keep a copy of your script in your home dir if you want to iterate.
- Adjust paths based on what the cron script actually uses.