OverTheWire Bandit: Levels 0 to 5

I am currently learning Linux commands by playing the OverTheWire Bandit wargame. It is a fantastic way to get comfortable with the terminal. In this post, I will cover my notes, tips, and the commands I used to solve levels 0 through 5.


Level 0 -> Level 1

Login:

ssh bandit0@bandit.labs.overthewire.org -p 2220

Password: bandit0

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

What I learned:

  1. ls: Used to list files in the current directory.
  2. cat readme: Used to display the content of the file.

Level 1 -> Level 2

Login:

ssh bandit1@bandit.labs.overthewire.org -p 2220

Password: (Use password found in the readme file)

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

What I learned:

  1. Handling special filenames: In Linux, - is typically treated as an option flag. To cat a file named -, you can use standard input redirection:
cat < -

Alternatively, you can use the path cat ./- to avoid the ambiguity.


Level 2 -> Level 3

Login:

ssh bandit2@bandit.labs.overthewire.org -p 2220

Password: (Use password found in level 1)

Puzzle: The password for the next level is stored in a file called --spaces in this filename-- located in the home directory.

What I learned:

  1. Dealing with spaces: When filenames contain spaces, you must escape them or use quotes. Using the -- separator can help distinguish options from filenames.
cat -- "--spaces in this filename--"

Level 3 -> Level 4

Login:

ssh bandit3@bandit.labs.overthewire.org -p 2220

Password: (Use password found in level 2)

Puzzle: The password for the next level is stored in a hidden file in the inhere directory.

What I learned:

  1. ls -a: The -a flag is essential to see hidden files (files starting with a .).
  2. cd inhere: Navigation command to change the working directory.
  3. Accessing hidden files with spaces:
ls -a
cd inhere
ls -a
cat -- "...Hiding-From-You"

Level 4 -> Level 5

Login:

ssh bandit4@bandit.labs.overthewire.org -p 2220

Password: (Use password found in level 3)

Puzzle: The password for the next level is stored in the only human-readable file in the inhere directory. (Tip: If your terminal is messed up, try the reset command.)

What I learned:

  1. Identifying file types: Instead of checking every file manually with cat, I used a simple bash loop to check the file type of each item.
for i in {0..9}; do file ./-file0$i; done

This allows you to filter through the data and find the file labeled ASCII text. Once identified:

cat ./-file07

Happy coding! I am looking forward to tackling levels 6–10 next.