Over The Wire - Bandit


OverTheWire offers online wargames to help users learn security concepts and Linux command line skills. Bandit is the entry-level game, focusing on basic Linux operations, file manipulation, and simple security tasks. Each level provides a challenge to retrieve a password, which is then used to access the next level.


Bandit Level Solutions

Below, each level is explained with its objective and the corresponding solution script.


Level 0

Objective:
Connect to the game using SSH. The password for the next level is stored in a file called readme in the home directory.

Solution:

# level_0.sh
ssh bandit0@bandit.labs.overthewire.org -p 2220
cat readme

Level 1

Objective:
The password for the next level is stored in a file called - located in the home directory.

Solution:

# level_1.sh
cat ./-

Level 2

Objective:
The password for the next level is stored in a file called spaces in this filename.

Solution:

# level_2.sh
cat "spaces in this filename"

Level 3

Objective:
The password for the next level is stored in a hidden file in the home directory.

Solution:

# level_3.sh
cat .hidden

Level 4

Objective:
The password for the next level is stored in the only human-readable file in the inhere directory.

Solution:

# level_4.sh
file inhere/*
cat inhere/-file07

Level 5

Objective:
The password for the next level is stored in a file somewhere under the inhere directory and has human-readable content.

Solution:

# level_5.sh
find inhere -type f -exec file {} \; | grep ASCII
cat inhere/maybehere07/.file2

Level 6

Objective:
The password for the next level is stored in a file somewhere on the server and has the following properties:

  • owned by user bandit7
  • owned by group bandit6
  • 33 bytes in size

Solution:

# level_6.sh
find / -user bandit7 -group bandit6 -size 33c 2>/dev/null
cat /var/lib/dpkg/info/bandit7.password

Level 7

Objective:
The password for the next level is stored in the file data.txt next to the word millionth.

Solution:

# level_7.sh
grep millionth data.txt

Level 8

Objective:
The password for the next level is stored in the file data.txt and is the only line that occurs only once.

Solution:

# level_8.sh
sort data.txt | uniq -u

Level 9

Objective:
The password for the next level is stored in the file data.txt in one of the few human-readable strings, preceded by several = characters.

Solution:

# level_9.sh
strings data.txt | grep '='

Level 10

Objective:
The password for the next level is stored in the file data.txt, which contains base64 encoded data.

Solution:

# level_10.sh
base64 -d data.txt

Level 11

Objective:
The password for the next level is stored in the file data.txt, which has been encrypted using a simple rot13 cipher.

Solution:

# level_11.sh
cat data.txt | tr 'A-Za-z' 'N-ZA-Mn-za-m'

Level 12

Objective:
The password for the next level is stored in the file data.txt, which is a hexdump of a file that has been repeatedly compressed.

Solution:

# level_12.sh
xxd -r data.txt > data.bin
# Then repeatedly decompress using `file` to check type and appropriate decompress command (gzip, bzip2, tar, etc.)

Level 13

Objective:
The password for the next level is stored in /etc/bandit_pass/bandit14 and can only be read by bandit14. Use the sshkey.private file.

Solution:

# level_13.sh
ssh -i sshkey.private bandit14@localhost -p 2220
cat /etc/bandit_pass/bandit14

Level 14

Objective:
The password for the next level is obtained by submitting the current password to a port on localhost using SSL encryption.

Solution:

# level_14.sh
cat /etc/bandit_pass/bandit14 | openssl s_client -connect localhost:30000

Level 15

Objective:
The password for the next level can be retrieved by submitting the current password to a specific port using nc.

Solution:

# level_15.sh
cat /etc/bandit_pass/bandit15 | nc localhost 30001

Level 16

Objective:
The password for the next level can be retrieved by connecting to a port using SSL and providing the current password.

Solution:

# level_16.sh
openssl s_client -connect localhost:30001
# Then paste the password when prompted

Level 17

Objective:
There are 2 files in the home directory: passwords.old and passwords.new. The password for the next level is the only line that has changed between the two files.

Solution:

# level_17.sh
diff passwords.old passwords.new

Level 18

Objective:
The password for the next level is stored in a file called readme in the home directory. However, you are logged out immediately after logging in via SSH.

Solution:

# level_18.sh
ssh bandit18@bandit.labs.overthewire.org -p 2220 "cat readme"

Level 19

Objective:
The password for the next level is stored in a file called bandit20.do in the home directory. You must set the execute permission and run it to retrieve the password.

Solution:

# level_19.sh
chmod +x bandit20-do
./bandit20-do cat /etc/bandit_pass/bandit20

Level 20

Objective:
The password for the next level is stored on the server and can be retrieved by submitting the current password to a specific port.

Solution:

# level_20.sh
./suconnect 30020
# Then enter the password when prompted

Level 21

Objective:
The password for the next level is stored in the /etc/bandit_pass/bandit21 file and can be retrieved by using a setuid binary.

Solution:

# level_21.sh
./suconnect 30021
# Then enter the password when prompted

More Information

For detailed descriptions of each level and the Bandit wargame, visit the OverTheWire Bandit page.

License

This project is for educational use only.