By Davy Rogers. Use these techniques only in environments you own or have explicit permission to test.

OverTheWire: Bandit Walkthrough

OverTheWire Bandit is a wargame designed to teach Linux command-line skills through practical challenges. It's the perfect hands-on practice for everything you've learned in the Bash series. This walkthrough covers Levels 0-15 with detailed explanations and alternative solutions.

What You'll Learn

  • Practical command-line problem solving
  • SSH connections and file navigation
  • Finding hidden files and data
  • Working with file types and encodings
  • Using pipes and redirection
  • Practical application of grep, find, and more

Getting Started

About OverTheWire Bandit

Website: https://overthewire.org/wargames/bandit/
Goal: Learn Linux commands through progressive challenges
Each level: Find password for next level
Connect via: SSH

General Connection Format

ssh bandit<level>@bandit.labs.overthewire.org -p 2220

Level 0: Connect via SSH

Goal

Log in to the game using SSH.

Connection

ssh [email protected] -p 2220

Password: bandit0

Solution

# Simply connect with SSH
ssh [email protected] -p 2220

# When prompted, enter password: bandit0

What you learned: Basic SSH connection


Level 0 → 1: Read a File

Goal

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

Solution

# List files
ls

# Read the file
cat readme

Password: NH2SXQwcBdpmTEzi3bvBHMM9H66vVXjL

What you learned: ls and cat commands


Level 1 → 2: Dashed Filename

Goal

The password is stored in a file called - in the home directory.

Problem

cat -
# This doesn't work! - means stdin

Solution

# Method 1: Use ./
cat ./-

# Method 2: Use full path
cat /home/bandit1/-

# Method 3: Use redirection
cat < -

Password: rRGizSaX8Mk1RTb1CNQoXTcYZWU6lgzi

What you learned: Handling special filenames


Level 2 → 3: Spaces in Filename

Goal

The password is stored in a file called spaces in this filename.

Solution

# Method 1: Use quotes
cat "spaces in this filename"

# Method 2: Escape spaces
cat spaces\ in\ this\ filename

# Method 3: Tab completion (easiest!)
cat spaces[TAB]

Password: aBZ0W5EmUfAf7kHTQeOwd8bauFJ2lAiG

What you learned: Handling spaces in filenames


Level 3 → 4: Hidden Files

Goal

The password is stored in a hidden file in the inhere directory.

Solution

# Go to directory
cd inhere

# List all files (including hidden)
ls -la

# You'll see: .hidden

# Read it
cat .hidden

Alternative:

# One-liner
cat inhere/.hidden

Password: 2EW7BBsr6aMMoJ2HjW067dm8EgX26xNe

What you learned: Hidden files (start with .), ls -la


Level 4 → 5: Find Human-Readable File

Goal

The password is stored in the only human-readable file in the inhere directory.

Solution

cd inhere

# List files
ls
# You'll see: -file00 through -file09

# Method 1: Check file types
file ./*

# Method 2: Check each file
cat ./-file0*

# Method 3: Find human-readable (ASCII text)
file ./* | grep "ASCII text"
# Output: ./-file07: ASCII text

# Read it
cat ./-file07

Password: lrIWWI6bB37kxfiCQZqUdOIYfr6eEeqR

What you learned: file command to check file types


Level 5 → 6: Find File by Properties

Goal

The password is stored somewhere in the inhere directory with these properties:

  • Human-readable
  • 1033 bytes in size
  • Not executable

Solution

cd inhere

# Use find with multiple conditions
find . -type f -size 1033c ! -executable

# Output: ./maybehere07/.file2

# Read it
cat ./maybehere07/.file2

Alternative:

# Chain with cat
find . -type f -size 1033c ! -executable -exec cat {} \;

Password: P4L4vucdmLnm8I7Vl7jG1ApGSfjYKqJU

What you learned: find with size and executable filters


Level 6 → 7: Find File on Server

Goal

The password is stored somewhere on the server with these properties:

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

Solution

# Search entire server
find / -user bandit7 -group bandit6 -size 33c 2>/dev/null

# Output: /var/lib/dpkg/info/bandit7.password

# Read it
cat /var/lib/dpkg/info/bandit7.password

Why 2>/dev/null?: Suppress "Permission denied" errors

Password: z7WtoNQU2XfjmMtWA8u5rN4vzqu4v99S

What you learned: System-wide find, error redirection


Level 7 → 8: Find Word in File

Goal

The password is stored in data.txt next to the word millionth.

Solution

# Method 1: grep
grep "millionth" data.txt

# Method 2: awk
awk '/millionth/ {print $2}' data.txt

# Method 3: grep with only password
grep "millionth" data.txt | cut -f2

Password: TESKZC0XvTetK0S9xNwm25STk5iWrBvP

What you learned: Searching with grep


Level 8 → 9: Find Unique Line

Goal

The password is stored in data.txt and is the only line that occurs once.

Solution

# Sort then find unique
sort data.txt | uniq -u

Why sort first?: uniq only detects adjacent duplicates

Alternative with count:

# Show count of each line
sort data.txt | uniq -c | grep "1 "

Password: EN632PlfYiZbn3PhVK3XOGSlNInNE00t

What you learned: sort, uniq, pipe combination


Level 9 → 10: Find Human-Readable Strings

Goal

The password is stored in data.txt in one of the few human-readable strings, preceded by several = characters.

Solution

# Extract printable strings
strings data.txt | grep "=="

Output includes:

========== the
========== password
========== is
========== <PASSWORD>

Password: G7w8LIi6J3kTb8A7j9LgrywtEUlyyp6s

What you learned: strings command for binary files


Level 10 → 11: Base64 Decoding

Goal

The password is stored in data.txt which contains base64 encoded data.

Solution

# Check file
cat data.txt
# Output: VGhlIHBhc3N3b3JkIGlzIDZ...

# Decode base64
base64 -d data.txt

Alternative:

# One-liner with piping
cat data.txt | base64 -d

Password: 6zPeziLdR2RKNdNYFNb6nVCKzphlXHBM

What you learned: Base64 encoding/decoding


Level 11 → 12: ROT13 Decoding

Goal

The password is stored in data.txt where all lowercase (a-z) and uppercase (A-Z) letters have been rotated by 13 positions.

ROT13 Explanation

ROT13 = Rotate by 13
A → N, B → O, C → P ... Z → M
N → A, O → B, P → C ... M → Z

Solution

# Use tr (translate) to decode ROT13
cat data.txt | tr 'A-Za-z' 'N-ZA-Mn-za-m'

How it works:

  • A-Za-z → N-ZA-Mn-za-m
  • A→N, B→O, ..., N→A, O→B, etc.

Password: JVNBBFSmZwKKOP0XbFXOoW8chDz5yVRv

What you learned: tr (translate) command, ROT13


Level 12 → 13: Hexdump Reverse

Goal

The password is stored in data.txt, which is a hexdump of a file that has been repeatedly compressed.

Solution

# Create working directory
mkdir /tmp/mywork
cd /tmp/mywork

# Copy file
cp ~/data.txt .

# Reverse hexdump
xxd -r data.txt > data

# Check file type
file data
# Output: data: gzip compressed data

# Rename and decompress
mv data data.gz
gzip -d data.gz

# Check again
file data
# Output: data: bzip2 compressed data

# Decompress bzip2
mv data data.bz2
bzip2 -d data.bz2

# Check again
file data
# Output: data: gzip compressed data

# Continue this process...
# The file is compressed multiple times with different algorithms
# Keep checking file type and decompressing until you get ASCII text

# Eventually you'll get:
# data: ASCII text
cat data

Full decompression sequence:

  1. gzip → gzip -d
  2. bzip2 → bzip2 -d
  3. gzip → gzip -d
  4. tar → tar -xf
  5. tar → tar -xf
  6. bzip2 → bzip2 -d
  7. tar → tar -xf
  8. gzip → gzip -d
  9. ASCII text!

Password: wbWdlBxEir4CaE8LaPhauuOo6pwRmrDw

What you learned: xxd, compression formats (gzip, bzip2, tar), file command


Level 13 → 14: SSH Private Key

Goal

The password for the next level is stored in /etc/bandit_pass/bandit14 but can only be read by user bandit14. For this level, you get an SSH private key instead of a password.

Solution

# List files
ls
# Output: sshkey.private

# View key (optional)
cat sshkey.private

# Use private key to connect as bandit14
ssh -i sshkey.private bandit14@localhost -p 2220

# Now you're bandit14!
# Read the password
cat /etc/bandit_pass/bandit14

Password: fGrHPx402xGC7U7rXKDaxiWFTOiF0ENq

What you learned: SSH private key authentication (ssh -i)


Level 14 → 15: Submit Password to Port

Goal

The password for the next level can be retrieved by submitting the current level's password to port 30000 on localhost.

Solution

# Method 1: Use netcat (nc)
echo "fGrHPx402xGC7U7rXKDaxiWFTOiF0ENq" | nc localhost 30000

# Method 2: Use telnet
telnet localhost 30000
# Then type the password when connected

# Method 3: Use /dev/tcp
echo "fGrHPx402xGC7U7rXKDaxiWFTOiF0ENq" > /dev/tcp/localhost/30000
cat < /dev/tcp/localhost/30000

Password: jN2kgmIXJ6fShzhT2avhotn4Zcka6tnt

What you learned: Network communication with nc (netcat)


Summary of Commands Learned

Level 0-5:
ssh         # Remote connection
ls, ls -la  # List files (including hidden)
cat         # Read files
file        # Check file type
find        # Search for files

Level 6-10:
grep        # Search in files
sort        # Sort lines
uniq        # Remove duplicates
strings     # Extract printable strings
base64      # Encode/decode base64
tr          # Translate characters

Level 11-15:
xxd         # Hexdump and reverse
gzip        # Compress/decompress
bzip2       # Compress/decompress
tar         # Archive files
nc          # Network communication
ssh -i      # SSH with private key

Tips for Continuing

General Strategy

  1. Read the level page carefully
  2. List files in home directory
  3. Check file types with file
  4. Use man pages when stuck
  5. Search online if really stuck

Common Patterns

# Always check what you have
ls -la

# Check file types
file *

# Search for text
grep "pattern" file

# Work in /tmp for write access
mkdir /tmp/myname
cd /tmp/myname

Practical Exercises

Exercise 1: Practice Commands

Go through levels 0-15 yourself without looking at solutions first!

Exercise 2: Alternative Solutions

Try to solve each level using different commands than shown here.

Exercise 3: Continue Beyond

Continue with Bandit levels 16-34 to master more advanced concepts!


Resources

OverTheWire:

Additional Wargames:

  • Natas (web security)
  • Leviathan (privilege escalation)
  • Krypton (cryptography)

Next Steps

  1. Complete all 34 Bandit levels - incredible practice!
  2. Try other OverTheWire games (Natas, Leviathan)
  3. Document your solutions - build your notes
  4. Help others - teaching reinforces learning
  5. Apply skills in CTFs and real pentesting

OverTheWire Bandit is the best free resource for learning Linux command-line skills. Complete all levels and you'll be dangerous with Bash!


"Bandit: Where cat is not just a pet."