Bait A Phish
Bait A Phish
Security Pulse
tutorial · bandit

Bandit Level 24

Write your first cron-triggered shell script and exfiltrate the next password to /tmp.
banditcronbashchmod
Narration (cached)
Marks this level complete in your browser.

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

Solution (click to reveal)
  1. SSH in:
ssh bandit24@bandit.labs.overthewire.org -p 2220
  1. Inspect /etc/cron.d to learn which directory is executed (often something like /var/spool/bandit24/):
cat /etc/cron.d/*
  1. Create a unique output file:
out=/tmp/bandit24_$RANDOM.txt
  1. 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"
  1. 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

Bandit Level 23Bandit Level 25