🎮

OverTheWire: Complete Walkthrough

Every level explained in extreme detail for absolute beginners

What is OverTheWire?

OverTheWire is a collection of "wargames" - security challenges that teach you hacking skills through practice. Think of it like a video game, but instead of fighting monsters, you're solving Linux puzzles and learning real hacking techniques.

Bandit is the first and most beginner-friendly wargame. It teaches you Linux command line basics, which is the foundation of ALL hacking.

📚 What You'll Learn:

  • ✅ Linux command line basics (ls, cd, cat, grep)
  • ✅ File permissions and hidden files
  • ✅ SSH connections and remote servers
  • ✅ Finding and reading files in Linux
  • ✅ Data encoding (base64, hex, rot13)
  • ✅ Compression and archives
  • ✅ Network connections and ports

🚀 Getting Started

Step 1: What is SSH?

SSH (Secure Shell) is a way to control a computer remotely through the command line. Think of it like remote desktop, but instead of a graphical interface, you get a terminal where you type commands.

When you "SSH into" a server, you're connecting to another computer over the internet and controlling it with text commands.

Step 2: Open Your Terminal

On Windows: Use PowerShell, Command Prompt, or install WSL (Windows Subsystem for Linux)

On Mac/Linux: Open the Terminal app (usually in Applications → Utilities)

Step 3: Understand the Connection Command

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

Let's break this down word by word:

  • ssh - The command to start an SSH connection
  • bandit0 - The username you're logging in as
  • @ - Separator between username and server address
  • bandit.labs.overthewire.org - The server's address (like a website URL)
  • -p 2220 - The port number (like an apartment number in a building)

Bandit Level Walkthroughs

Level 0

Your First SSH Connection

🎯 Goal:

Connect to the Bandit server using SSH. The password for this level is bandit0.

📝 Step-by-Step Solution:

Step 1: Open your terminal

This is where you type commands. On Windows, press Win + R, type "cmd" and press Enter. On Mac, press Cmd + Space, type "terminal" and press Enter.

Step 2: Type the SSH command

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

Press Enter. You might see a message asking "Are you sure you want to continue connecting?" - Type yes and press Enter.

Step 3: Enter the password

When prompted for a password, type: bandit0

⚠️ Important: When you type the password, you WON'T see any characters appear on screen. This is normal! It's a security feature. Just type the password and press Enter.

✅ Success Looks Like:

You'll see a welcome message and your prompt will change to something like:

bandit0@bandit:~$

Congratulations! You're now inside the Bandit server. You've completed Level 0! 🎉

Level 0 → 1

Reading Files with cat

🎯 Goal:

The password for Level 1 is stored in a file called readme in your home directory. Find and read it.

💡 Concepts You Need to Know:

What is a "home directory"?
When you log into a Linux system, you start in your "home directory" - think of it as your personal folder. It's like "My Documents" on Windows. When you first connect via SSH, you're automatically placed here.

What does "cat" do?
The cat command (short for "concatenate") reads files and displays their content in the terminal. Think of it as "open and show me what's inside this file."

What is "ls"?
The ls command (short for "list") shows you all files and folders in your current location. It's like opening File Explorer on Windows.

📝 Step-by-Step Solution:

Step 1: See what files are here

# Type this command:

ls

# You'll see output like:

readme

Perfect! There's a file called "readme" here. This is what we're looking for.

Step 2: Read the file

# Type this command:

cat readme

# You'll see the password printed on screen:

NH2SXQwcBdpmTEzi3bvBHMM9H66vVXjL

This long string of random characters is the password for Level 1! Copy it - you'll need it to log into the next level.

Step 3: Disconnect and move to Level 1

# Type this to disconnect:

exit

Now connect to Level 1 using the password you just found:

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

# When prompted, paste the password you copied

🧠 What You Learned:

  • ls - Lists files in your current directory
  • cat filename - Reads and displays file content
  • exit - Disconnects from SSH session
  • How to navigate between levels using the password you find
Level 1 → 2

Special Characters in Filenames

🎯 Goal:

The password is stored in a file called - (just a dash/hyphen). Read it.

💡 The Problem:

In Linux, the dash (-) is a special character. It's normally used to indicate options/flags for commands. For example, ls -la means "run ls with the options l and a".

If you try cat -, the system thinks you're trying to give cat an option, not read a file named "-". This is confusing!

Solution: We need to tell the system "I mean a FILE called dash, not an option." We do this by specifying the FULL PATH to the file.

💡 Understanding Paths:

What is a "path"?
A path is the address of a file. Like how "123 Main Street, Apartment 4B" is a full address, a file path tells the computer exactly where a file is.

Two types of paths:
1. Absolute path: The FULL address starting from root. Example: /home/bandit1/myfile.txt
2. Relative path: The address relative to where you are now. Example: ./myfile.txt

The ./ means "in the current directory". It's like saying "in this folder I'm in right now."

📝 Step-by-Step Solution:

Step 1: Verify the file exists

ls

# Output:

-

Step 2: Read the file using its relative path

# This WON'T work:

cat -

# This WILL work:

cat ./-

# Output (the password):

rRGizSaX8Mk1RTb1CNQoXTcYZWU6lgzi

By adding ./ before the dash, we're saying "cat, please read the file named dash in my current directory" instead of "cat, I'm giving you an option."

🧠 What You Learned:

  • Some characters are special in Linux (like -)
  • ./ means "current directory"
  • Using ./filename tells Linux you mean a file, not a command option
  • Alternative: You can also use cat < - (input redirection)

📚 Learning Pattern Established!

You now understand the fundamental pattern of Bandit:

  1. Connect to the level
  2. Use ls to see what files exist
  3. Use cat or other commands to read files
  4. Find the password
  5. Use that password to access the next level

Each level teaches you a NEW Linux concept or command. The levels get progressively harder, building on what you've learned. Keep going - you're doing great! 🎉

🚀 Essential Commands Quick Reference

File Operations

ls - List files

ls -la - List all files (including hidden)

cat file - Read file

cat ./- - Read file with special name

file * - Check file types

Navigation

cd dirname - Change directory

cd .. - Go up one directory

pwd - Print working directory

./ - Current directory

~/ - Home directory

Search & Find

find / -name file - Find by name

find / -size 1033c - Find by size

grep text file - Search in file

strings file - Extract text

Data Handling

base64 -d file - Decode base64

xxd file - View hex dump

tr 'A-Za-z' 'N-ZA-Mn-za-m' - ROT13

tar -xf file.tar - Extract tar

💡 Pro Tips for Bandit

1. Use the man pages: If you don't know what a command does, type man command. For example, man ls shows you everything about the ls command.

2. Tab completion is your friend: Start typing a filename and press Tab. It will auto-complete! Saves so much time.

3. Keep a notes file: Write down passwords and commands you learn. You'll forget them otherwise!

4. Read the level descriptions: Each Bandit level page has hints. Don't skip them!

5. Google is allowed: If you're stuck, searching "bandit level X walkthrough" is totally fine. Learning HOW to search for solutions is a valuable skill.

🎯 Level 3 → 4: Hidden Files

Goal: Find the password in a hidden file in the home directory
Connection: ssh bandit3@bandit.labs.overthewire.org -p 2220
Password: (from level 2)

💡 What Are Hidden Files?

In Linux, files starting with a dot (.) are hidden. When you run ls, you WON'T see them! Think of it like invisible ink - the files exist, but you need special glasses to see them.

Why hide files? Configuration files (like .bashrc, .ssh) are hidden so they don't clutter your view.

📝 Solution

  1. List ALL files (including hidden):
    ls -la
    The -a flag means "show ALL files, even hidden ones"
  2. You'll see a directory called "inhere":
    cd inhere
  3. List hidden files in this directory:
    ls -la
    You'll see a file like .hidden
  4. Read it:
    cat .hidden
✅ What You Learned:
  • Files starting with . are hidden
  • ls -a shows hidden files
  • ls -la = long format + hidden files
  • How to navigate directories and read hidden files

🎯 Level 4 → 5: Finding Human-Readable Files

Goal: Find the ONLY human-readable file among 10 files
Location: inhere directory
Challenge: Most files are binary garbage, only ONE has text

💡 What is "Human-Readable"?

Computers store TWO types of files:
1. Text files - You can read them (like .txt, .html, .py)
2. Binary files - Computer code, images, videos (looks like gibberish if you open it)

The file command tells you what type a file is!

📝 Solution

  1. Go to the directory:
    cd inhere
  2. List all files:
    ls
    You'll see: -file00, -file01, -file02... (note the dash!)
  3. Check what type each file is:
    file ./*
    This checks ALL files. You'll see "data" for binary, "ASCII text" for readable ones
  4. Read the ASCII text file:
    cat ./-file07 (or whichever says ASCII text)
    The ./ is needed because of the dash!
✅ What You Learned:
  • file command identifies file types
  • ASCII text = human-readable
  • ./* = all files in current directory
  • How to handle files starting with special characters

🎯 Level 5 → 6: Finding Files by Size & Type

Goal: Find a file that is:
  • Human-readable
  • 1033 bytes in size
  • Not executable

💡 The Find Command - Your Swiss Army Knife

find is like a super-powered search. Instead of just searching by name, you can search by: size, type, permissions, date modified, and more!

📝 Solution

  1. Navigate to inhere:
    cd inhere
  2. Use find with multiple conditions:
    find . -type f -size 1033c ! -executable
    Let's break this down:
    • . = search in current directory
    • -type f = only files (not directories)
    • -size 1033c = exactly 1033 bytes (c=characters/bytes)
    • ! -executable = NOT executable (the ! means NOT)
  3. It will show you the path, then read it:
    cat ./maybehere07/.file2 (or whatever path it found)
✅ What You Learned:
  • find command with multiple filters
  • -size flag (c=bytes, k=kilobytes, M=megabytes)
  • -type f for files only
  • ! operator for negation (NOT)
  • How to combine multiple search criteria

🎯 Level 6 → 7: Searching the Entire System

Goal: Find a file ANYWHERE on the server that is:
  • Owned by user bandit7
  • Owned by group bandit6
  • 33 bytes in size

💡 Understanding File Ownership

Every file in Linux has TWO owners:
1. User owner - The person who created it
2. Group owner - A group of users who can access it

This is like a document being owned by "John" but shared with the "Engineering Team".

📝 Solution

  1. Search from root directory:
    find / -user bandit7 -group bandit6 -size 33c 2>/dev/null
    Breaking it down:
    • / = start from root (search EVERYWHERE)
    • -user bandit7 = owned by bandit7
    • -group bandit6 = group is bandit6
    • -size 33c = 33 bytes
    • 2>/dev/null = hide "Permission denied" errors
  2. You'll see something like:
    /var/lib/dpkg/info/bandit7.password
  3. Read it:
    cat /var/lib/dpkg/info/bandit7.password
💡 Pro Tip: 2>/dev/null is your best friend!
2 = error messages (stderr)
>/dev/null = send to the void (discard them)
Without this, your screen would be flooded with "Permission denied" messages!
✅ What You Learned:
  • File ownership (user and group)
  • -user and -group flags
  • Searching from root directory /
  • 2>/dev/null to suppress errors
  • How to find files system-wide

📝 Level 7 → 8: Finding Text in Large Files with grep

🎯 GOAL:

Password is stored in data.txt next to word "millionth"
ssh bandit7@bandit.labs.overthewire.org -p 2220
Password: (from previous level)

📚 Concepts You Need to Know

What is grep?

grep = "Global Regular Expression Print". Think of it like Ctrl+F in a text editor, but WAY more powerful. It searches INSIDE files for specific text patterns.

Real-world analogy: Imagine you have a 1000-page book and need to find the word "millionth". You could read every page (would take forever), OR you could use grep which instantly finds it for you!

✅ Step-by-Step Solution

  1. SSH into bandit7
  2. Check what's in the directory:
    ls -la
    You'll see data.txt - a large file with many lines
  3. Try reading it normally (bad idea):
    cat data.txt
    Whoa! Thousands of lines scroll past. This is NOT the way!
  4. Use grep to find "millionth":
    grep "millionth" data.txt
    Expected output:
    millionth [PASSWORD HERE]
✅ What You Learned:
  • grep searches INSIDE files for text
  • It's MUCH faster than reading manually
  • Syntax: grep "search term" filename
  • grep shows the entire line containing the match
💡 grep Power Tips:
  • grep -i "word" file - Case-insensitive (finds Word, WORD, word)
  • grep -n "word" file - Show line numbers
  • grep -v "word" file - Show lines that DON'T match
  • grep -r "word" /path/ - Search recursively in all files

🔢 Level 8 → 9: Finding Unique Lines with sort and uniq

🎯 GOAL:

Password is the only line of text that occurs only once in data.txt
ssh bandit8@bandit.labs.overthewire.org -p 2220
Password: (from previous level)

📚 Concepts You Need to Know

What are sort and uniq?

sort: Arranges lines alphabetically (A-Z). Like sorting a deck of cards.
uniq: Removes duplicate CONSECUTIVE lines. But it ONLY works on sorted data!

Why sort first? Because uniq only removes duplicates that are next to each other. If you have: [apple, banana, apple], uniq won't remove the second apple because they're not consecutive. But if you sort first: [apple, apple, banana], NOW uniq works!

The pipe (|): This is the MAGIC of Linux! The | symbol takes the OUTPUT of one command and feeds it as INPUT to another command. It's like a production line in a factory!

✅ Step-by-Step Solution

  1. Look at the file:
    cat data.txt
    You'll see many lines, most appearing multiple times
  2. Sort the file first:
    sort data.txt
    Now identical lines are grouped together
  3. Use uniq to find unique lines:
    sort data.txt | uniq -u
    Breaking this down:
    • sort data.txt - Sort all lines
    • | - Pipe (send output to next command)
    • uniq -u - Show only unique lines (the -u flag means "unique only")
  4. The password appears! That's the line that only occurs once.
✅ What You Learned:
  • sort arranges lines alphabetically
  • uniq removes duplicate consecutive lines
  • uniq -u shows ONLY lines that appear once
  • | (pipe) chains commands together
  • Always sort BEFORE using uniq!
💡 More uniq Tricks:
  • uniq -c - Count how many times each line appears
  • uniq -d - Show only duplicate lines
  • sort | uniq - Remove all duplicates (keep one copy)

🔤 Level 9 → 10: Extracting Text from Binary Files

🎯 GOAL:

Password is in data.txt, in one of the few human-readable strings, preceded by several '=' characters
ssh bandit9@bandit.labs.overthewire.org -p 2220
Password: (from previous level)

📚 Concepts You Need to Know

What is a binary file?

Most files are either text files (you can read them with cat) or binary files (compiled programs, images, etc. that look like gibberish if you cat them).

What is strings? The strings command extracts ONLY the human-readable text from binary files. It ignores all the binary garbage and shows you readable words!

Real-world analogy: Imagine a book where 99% of pages are in alien language, but 1% have English sentences. strings automatically finds and shows you ONLY the English sentences!

✅ Step-by-Step Solution

  1. Check the file type:
    file data.txt
    Output: data.txt: data (binary file, not text!)
  2. Try to read it normally (fails):
    cat data.txt
    Your terminal shows garbage characters! ��� This is binary data.
  3. Extract readable strings:
    strings data.txt
    Now you see ONLY human-readable text!
  4. Search for lines with '==' characters:
    strings data.txt | grep "=="
    Expected output:
    ========== password
    ========== [THE PASSWORD]
✅ What You Learned:
  • strings extracts readable text from binary files
  • Binary files contain non-text data (compiled code, images, etc.)
  • You can pipe strings output to grep for filtering
  • Combining commands with | is incredibly powerful
💡 strings Options:
  • strings -n 10 file - Show only strings of 10+ characters
  • strings -a file - Scan entire file (default only scans certain sections)
  • strings -o file - Show byte offset of each string

🔐 Level 10 → 11: Base64 Decoding

🎯 GOAL:

Password is in data.txt, which contains base64 encoded data
ssh bandit10@bandit.labs.overthewire.org -p 2220
Password: (from previous level)

📚 Concepts You Need to Know

What is Base64?

Base64 is an encoding (NOT encryption!) that converts binary data into ASCII text. It uses only letters (A-Z, a-z), numbers (0-9), and two symbols (+, /).

Why use it? Email and old systems can only handle text, not binary data. Base64 lets you send ANY file (images, programs) as text!

Example:
Original: Hello
Base64: SGVsbG8=
Notice the = at the end? That's padding! Base64 often ends with = or ==

⚠️ Important: Base64 is NOT secure! It's encoding, not encryption. Anyone can decode it instantly. It's just a way to represent data, not hide it!

✅ Step-by-Step Solution

  1. Read the file:
    cat data.txt
    You'll see something like: VGhlIHBhc3N3b3JkIGlzIDZ6UGV6aUxkUjJSS05kTllGTmI2blZDS3pwaGxYSEJNCg==
  2. Notice the characteristics:
    • Only letters, numbers, +, /, and =
    • Ends with == (padding)
    • This is definitely Base64!
  3. Decode it:
    base64 -d data.txt
    Breaking it down:
    • base64 - The base64 command
    • -d - Decode flag (opposite of encode)
    • data.txt - The file to decode
  4. Output:
    The password is [PASSWORD HERE]
✅ What You Learned:
  • Base64 is an encoding method (not encryption!)
  • base64 -d file decodes base64
  • base64 file encodes to base64
  • Base64 uses A-Z, a-z, 0-9, +, / and = for padding
  • Encoding ≠ Encryption (base64 provides NO security)
💡 Base64 in the Real World:
  • Email attachments: Files are base64 encoded in email source
  • Data URLs: Images in HTML/CSS (data:image/png;base64,...)
  • JWTs: JSON Web Tokens use base64 for headers/payloads
  • Malware: Attackers sometimes base64-encode payloads to avoid detection

🔄 Level 11 → 12: ROT13 Cipher (Letter Rotation)

🎯 GOAL:

Password in data.txt where all lowercase (a-z) and uppercase (A-Z) letters have been rotated by 13 positions
ssh bandit11@bandit.labs.overthewire.org -p 2220
Password: (from previous level)

📚 Concepts You Need to Know

What is ROT13?

ROT13 = "Rotate by 13 places". It's a simple substitution cipher where each letter is replaced by the letter 13 positions after it in the alphabet.

The alphabet has 26 letters. So rotating by 13 means:
A → N, B → O, C → P, ... M → Z, N → A, O → B, ... Z → M

Cool trick: ROT13 is its own inverse! If you ROT13 something twice, you get the original back:
Hello → Uryyb → Hello

The tr command: "translate" - it replaces characters. Syntax: tr 'old chars' 'new chars'

✅ Step-by-Step Solution

  1. Read the encoded file:
    cat data.txt
    You'll see: Gur cnffjbeq vf 7k16WgUl0m... (gibberish!)
  2. Use tr to decode ROT13:
    cat data.txt | tr 'A-Za-z' 'N-ZA-Mn-za-m'
    Let's break this down character by character:
    • cat data.txt - Read the file
    • | - Pipe the output
    • tr - Translate command
    • 'A-Za-z' - OLD characters (all letters)
    • 'N-ZA-Mn-za-m' - NEW characters (rotated by 13)
  3. Understanding the rotation string:
    'N-ZA-M' means: N,O,P,Q,R,S,T,U,V,W,X,Y,Z,A,B,C,D,E,F,G,H,I,J,K,L,M
    This is the alphabet shifted by 13 positions!
  4. Output:
    The password is [PASSWORD]
✅ What You Learned:
  • ROT13 is a Caesar cipher (shift cipher)
  • tr translates/replaces characters
  • Syntax: tr 'from' 'to'
  • A-Z notation represents a range of characters
  • ROT13 is symmetric (encode = decode)
💡 More tr Examples:
  • tr 'a-z' 'A-Z' - Convert lowercase to uppercase
  • tr -d 'a' - Delete all 'a' characters
  • tr -s ' ' - Squeeze repeated spaces into one
  • tr ' ' '_' - Replace spaces with underscores

📦 Level 12 → 13: Multiple Compression Formats (The Nested Doll)

🎯 GOAL:

Password is in data.txt, which is a hexdump of a file that has been compressed multiple times
ssh bandit12@bandit.labs.overthewire.org -p 2220
Password: (from previous level)

⚠️ WARNING: This Level is TOUGH!

This is the first HARD level! The file is compressed with gzip, then bzip2, then tar, then gzip again, etc. - like Russian nesting dolls! You'll decompress, check file type, decompress again, repeat... about 8-10 times!

📚 Concepts You Need to Know

Compression Formats:

  • gzip (.gz): Common Linux compression. Decompress with gzip -d file.gz or gunzip file.gz
  • bzip2 (.bz2): Better compression than gzip. Decompress with bzip2 -d file.bz2 or bunzip2 file.bz2
  • tar (.tar): Archive format (not compression!). Think of it as a "folder" that bundles files. Extract with tar -xf file.tar
  • Hexdump: Binary data represented as hexadecimal text. Reverse with xxd -r

Key command: file filename - tells you what TYPE of file you're dealing with!

✅ Step-by-Step Solution

  1. Create a working directory:
    mkdir /tmp/mywork && cd /tmp/mywork
    Why /tmp? You have write permission there! Your home directory is read-only.
  2. Copy the file:
    cp ~/data.txt .
    The . means "current directory"
  3. Convert from hexdump to binary:
    xxd -r data.txt > data.bin
    Breaking this down:
    • xxd -r - Reverse hexdump (convert hex to binary)
    • data.txt - Input (hex dump)
    • > data.bin - Output redirect to new file
  4. Check what you have:
    file data.bin
    Output: data.bin: gzip compressed data
    Aha! It's gzip!
  5. Decompress gzip (rename first):
    mv data.bin data.gz
    gzip -d data.gz
    This creates data (without .gz)
  6. Check again:
    file data
    Output: data: bzip2 compressed data
    Now it's bzip2!
  7. Decompress bzip2:
    mv data data.bz2
    bzip2 -d data.bz2
  8. Keep checking and decompressing:
    You'll encounter (in various orders):
    • file data → gzip → mv data data.gz && gzip -d data.gz
    • file data → bzip2 → mv data data.bz2 && bzip2 -d data.bz2
    • file data → tar archive → tar -xf data
  9. Repeat steps 8 about 8-10 times until:
    file data
    Output: data: ASCII text
    Finally! It's text!
  10. Read it:
    cat data
    The password is [PASSWORD]
✅ What You Learned:
  • xxd -r converts hexdump to binary
  • gzip -d decompresses gzip files
  • bzip2 -d decompresses bzip2 files
  • tar -xf extracts tar archives
  • ALWAYS use file command to check file type!
  • Files can be compressed multiple times (nested)
💡 Quick Reference:

file data → Check type

xxd -r hex.txt data → Hex to binary

gzip -d file.gz → Decompress gzip

bzip2 -d file.bz2 → Decompress bzip2

tar -xf file.tar → Extract tar

mv old new → Rename file

🔑 Level 13 → 14: SSH Private Keys (Password-less Login)

🎯 GOAL:

Password for next level is stored in /etc/bandit_pass/bandit14 (you can't read it yet!)
You have an SSH private key in your home directory to log in as bandit14
ssh bandit13@bandit.labs.overthewire.org -p 2220

📚 Concepts You Need to Know

What is SSH Key Authentication?

Usually you SSH with a password. But there's a MORE SECURE way: SSH keys!

How it works:
• You have TWO keys: private key (secret, keep it safe!) and public key (can share with anyone)
• The public key is placed on the server you want to access
• When you connect, you present your private key
• The server checks: "Does this private key match the public key I have?" If yes → you're in!

Real-world analogy: The public key is a lock, the private key is the key that opens it. You can give out many copies of the lock (public key), but only YOUR key (private key) can open them!

The -i flag: Tells SSH "use THIS specific private key file"

✅ Step-by-Step Solution

  1. List files in home directory:
    ls -la
    You'll see: sshkey.private
  2. Check the key:
    cat sshkey.private
    Starts with -----BEGIN RSA PRIVATE KEY-----
    This is the private key!
  3. Use it to SSH as bandit14:
    ssh -i sshkey.private bandit14@localhost -p 2220
    Breaking this down:
    • ssh - SSH command
    • -i sshkey.private - Use this private key
    • bandit14@localhost - Login as bandit14 on same machine
    • -p 2220 - Port 2220
  4. You're now bandit14! No password needed!
    Read the password file:
    cat /etc/bandit_pass/bandit14
✅ What You Learned:
  • SSH key authentication (more secure than passwords!)
  • Private key = secret, Public key = shareable
  • ssh -i keyfile uses specific key
  • localhost means "this same machine"
  • Keys stored in ~/.ssh/ by default
💡 SSH Key Best Practices:
  • Generate keys: ssh-keygen -t ed25519
  • Never share private keys! If leaked, regenerate immediately
  • Use passphrases: Add extra password to your private key
  • Permissions matter: Private key must be chmod 600 (owner read/write only)

🌐 Level 14 → 15: Network Ports with Netcat

🎯 GOAL:

Submit current level password to port 30000 on localhost to get next password
ssh bandit14@bandit.labs.overthewire.org -p 2220

📚 Concepts You Need to Know

What is a Network Port?

Think of your computer as an apartment building. The IP address is the building address. The ports are individual apartment numbers (1-65535)!

Common ports you should know:
• Port 22: SSH
• Port 80: HTTP (websites)
• Port 443: HTTPS (secure websites)
• Port 3306: MySQL database
• Port 30000: (custom, used in this challenge)

What is Netcat (nc)?
Netcat is the "Swiss Army knife" of networking! It can:

  • Connect to any port (like making a phone call)
  • Send data over the network
  • Listen on a port (wait for connections)
  • Transfer files
  • Create backdoors (in hacking!)

✅ Step-by-Step Solution

  1. Get the current password:
    cat /etc/bandit_pass/bandit14
    Copy this password!
  2. Connect to port 30000:
    nc localhost 30000
    What this means:
    • nc - Netcat command
    • localhost - This same machine (127.0.0.1)
    • 30000 - Port number
  3. Your terminal is now connected!
    Type (or paste) the bandit14 password and press Enter
  4. The server responds:
    Correct!
    [BANDIT15 PASSWORD]
✅ What You Learned:
  • Network ports are like apartment numbers (1-65535)
  • nc host port connects to a port
  • You can send data through network connections
  • localhost = 127.0.0.1 = this machine
  • Services listen on specific ports
💡 Netcat Hacking Uses:
  • Port scanning: Check which ports are open
  • Reverse shells: Get remote access to a machine
  • File transfer: Send files between machines
  • Banner grabbing: Identify services running on ports

🔒 Level 15 → 16: SSL/TLS Encryption with OpenSSL

🎯 GOAL:

Submit current password to port 30001 on localhost using SSL encryption
ssh bandit15@bandit.labs.overthewire.org -p 2220

📚 Concepts You Need to Know

What is SSL/TLS?

SSL (Secure Sockets Layer) and TLS (Transport Layer Security) encrypt your network traffic so nobody can spy on it!

Real-world analogy: Regular netcat is like sending a postcard (anyone can read it). SSL is like putting it in a locked box with a code only you and the recipient know!

When you see HTTPS: That's HTTP + SSL/TLS. The padlock 🔒 in your browser means encryption is active!

OpenSSL: The Swiss Army knife for SSL/TLS. It can:

  • Create encrypted connections
  • Generate certificates
  • Test SSL configurations
  • Encrypt/decrypt data

✅ Step-by-Step Solution

  1. Get the current password:
    cat /etc/bandit_pass/bandit15
  2. Connect with SSL encryption:
    openssl s_client -connect localhost:30001 -ign_eof
    Breaking this down:
    • openssl - OpenSSL tool
    • s_client - SSL client mode (connect to server)
    • -connect localhost:30001 - Where to connect
    • -ign_eof - Ignore end-of-file (keeps connection open)
  3. You'll see lots of certificate info scroll by:
    ---
    Certificate chain
    SSL handshake has read 1234 bytes
    ...

    Wait until you see: --- and a blank line ready for input
  4. Paste the password and press Enter
  5. Response:
    Correct!
    [BANDIT16 PASSWORD]
✅ What You Learned:
  • SSL/TLS encrypts network traffic
  • openssl s_client creates encrypted connections
  • HTTPS = HTTP + SSL/TLS
  • Certificates verify server identity
  • Port 443 is standard for HTTPS
💡 OpenSSL Power Commands:
  • openssl s_client -connect site.com:443 - Test HTTPS connection
  • openssl enc -aes-256-cbc -in file -out file.enc - Encrypt file
  • openssl x509 -in cert.pem -text - View certificate details
  • openssl genrsa -out key.pem 2048 - Generate RSA key

🔍 Level 16 → 17: Port Scanning (Finding Open Ports)

🎯 GOAL:

Find the SSL port in range 31000-32000 on localhost, submit password to it
One port speaks SSL and will give you the next password
ssh bandit16@bandit.labs.overthewire.org -p 2220

📚 Concepts You Need to Know

What is Port Scanning?

Port scanning = checking which ports are OPEN (accepting connections) on a computer. It's like trying every door in a building to see which ones are unlocked!

Nmap: The KING of port scanners! Used by hackers, pentesters, and sysadmins worldwide. It can:

  • Find open ports
  • Detect what services are running (SSH? Web server?)
  • Identify operating system
  • Check for vulnerabilities

✅ Step-by-Step Solution

  1. Scan the port range:
    nmap -p 31000-32000 localhost
    Breaking this down:
    • nmap - Network mapper (port scanner)
    • -p 31000-32000 - Port range to scan
    • localhost - Target (this machine)
  2. You'll see output like:
    PORT STATE SERVICE
    31046/tcp open unknown
    31518/tcp open unknown
    31691/tcp open unknown
    31790/tcp open unknown
    31960/tcp open unknown

    5 ports are open! But which one has SSL?
  3. Test each port with SSL:
    Try each open port:
    openssl s_client -connect localhost:31046 -ign_eof
    Some will fail or echo back your input (wrong!)
    Keep trying: 31518, 31691, 31790, 31960...
  4. When you find the right one:
    Paste the current password
    You'll get back an SSH PRIVATE KEY, not a password!
  5. Save the private key:
    mkdir /tmp/mykey && cd /tmp/mykey
    nano sshkey.private
    Paste the entire key (from BEGIN to END)
    Save with Ctrl+O, Enter, Ctrl+X
  6. Set permissions:
    chmod 600 sshkey.private
    SSH keys MUST have strict permissions!
  7. Use it to log in as bandit17:
    ssh -i sshkey.private bandit17@localhost -p 2220
✅ What You Learned:
  • nmap -p range host scans port ranges
  • Port scanning finds open ports
  • Not all open ports do the same thing
  • chmod 600 sets file permissions to owner-only
  • SSH keys can be used instead of passwords
💡 Nmap Scan Types:
  • nmap -sS host - SYN scan (stealth scan, default)
  • nmap -sV host - Service version detection
  • nmap -O host - Operating system detection
  • nmap -A host - Aggressive scan (OS, version, scripts)
  • nmap -Pn host - Skip ping (useful if ICMP blocked)

📊 Level 17 → 18: Finding Differences Between Files

🎯 GOAL:

Password is the only line that changed between passwords.old and passwords.new
ssh bandit17@bandit.labs.overthewire.org -p 2220

📚 Concepts You Need to Know

What is diff?

diff compares two files line-by-line and shows the differences. It's like "track changes" in Microsoft Word!

Output format:
• Lines starting with < = in first file only
• Lines starting with > = in second file only
• Lines with --- = separator
• Numbers like 42c42 = line 42 changed

Real-world uses:

  • Comparing code versions (Git uses diff internally!)
  • Finding configuration changes
  • Detecting file tampering
  • Code reviews

✅ Step-by-Step Solution

  1. List the files:
    ls -la
    You see: passwords.old and passwords.new
  2. Check file sizes:
    wc -l passwords.*
    Both have 100 lines! Manually comparing would take forever.
  3. Use diff to compare:
    diff passwords.old passwords.new
    Output:
    42c42
    < [OLD PASSWORD]
    ---
    > [NEW PASSWORD]
  4. Understanding the output:
    • 42c42 - Line 42 changed
    • < [OLD PASSWORD] - What was in passwords.old
    • > [NEW PASSWORD] - What's now in passwords.new
    The NEW password (after >) is the answer!
✅ What You Learned:
  • diff file1 file2 shows differences
  • < means "in first file"
  • > means "in second file"
  • diff is perfect for comparing versions
  • wc -l counts lines in files
💡 diff Options:
  • diff -u file1 file2 - Unified format (easier to read)
  • diff -y file1 file2 - Side-by-side comparison
  • diff -r dir1 dir2 - Recursively compare directories
  • diff -q file1 file2 - Only say IF files differ, not how

⚡ Level 18 → 19: Bypassing Auto-Logout (SSH Command Injection)

🎯 GOAL:

Password in readme file in home directory
BUT: .bashrc file logs you out immediately!
ssh bandit18@bandit.labs.overthewire.org -p 2220

📚 Concepts You Need to Know

What is .bashrc?

.bashrc is a script that runs EVERY time you start a bash shell. It sets up your environment (aliases, colors, prompt, etc.)

The problem: Someone modified .bashrc to run exit, so you get logged out instantly!

The trick: You can run commands through SSH WITHOUT starting an interactive shell! Syntax: ssh user@host "command"

✅ Step-by-Step Solution

  1. Try normal login (fails):
    ssh bandit18@bandit.labs.overthewire.org -p 2220
    Immediately disconnected!
  2. Run command directly through SSH:
    ssh bandit18@bandit.labs.overthewire.org -p 2220 "cat readme"
    Breaking this down:
    • SSH connects
    • Runs the command cat readme
    • Shows output
    • Disconnects
    .bashrc never gets a chance to run!
  3. The password appears!
✅ What You Learned:
  • .bashrc runs on every bash shell startup
  • ssh user@host "command" runs non-interactive command
  • You can bypass shell initialization this way
  • This technique works for restricted shells too!
💡 Alternative Solutions:
  • ssh ... "bash --norc" - Start bash without .bashrc
  • ssh ... "bash --noprofile" - Skip profile scripts
  • ssh ... "/bin/sh" - Use different shell (sh doesn't use .bashrc)

👑 Level 19 → 20: SETUID Privilege Escalation

🎯 GOAL:

Use the setuid binary to access bandit20's password
ssh bandit19@bandit.labs.overthewire.org -p 2220

📚 Concepts You Need to Know

What is SETUID?

SETUID (Set User ID) is a special permission bit. When you run a SETUID program, it executes with the permissions of the FILE OWNER, not YOU!

Real-world example: The passwd command (changes your password) is SETUID root. Why? Because it needs to edit /etc/shadow (a root-only file), but YOU need to be able to change YOUR password!

How to spot SETUID: Run ls -l file. If you see an 's' in the execute position: -rwsr-xr-x (the 's' means SETUID!)

Security risk: SETUID binaries are GOLD for hackers! If you can exploit one, you get higher privileges (privilege escalation!)

✅ Step-by-Step Solution

  1. List files:
    ls -la
    You see: -rwsr-x--- 1 bandit20 bandit19 bandit20-do
    Notice the 's'! This is SETUID and owned by bandit20!
  2. Test the binary:
    ./bandit20-do
    Output: Run a command as another user.
  3. Check who you are normally:
    whoami
    Output: bandit19
  4. Use the SETUID binary to run commands as bandit20:
    ./bandit20-do cat /etc/bandit_pass/bandit20
    What happens:
    • The binary runs as bandit20 (owner)
    • It executes: cat /etc/bandit_pass/bandit20
    • Since it's running AS bandit20, it can read bandit20's password!
  5. Password appears!
✅ What You Learned:
  • SETUID programs run with owner's permissions
  • ls -l shows 's' for SETUID files
  • This is a common privilege escalation vector
  • whoami shows current user
  • SETUID is powerful but dangerous!
💡 Finding SETUID Files (Hacking):
  • find / -perm -4000 2>/dev/null - Find all SETUID files
  • find / -user root -perm -4000 2>/dev/null - SETUID root files (highest value!)
  • Check GTFOBins for exploitable SETUID binaries

🔌 Level 20 → 21: Network Listener & Background Processes

🎯 GOAL:

SETUID binary suconnect connects to localhost on port you specify
If it receives current password, it transmits next password
ssh bandit20@bandit.labs.overthewire.org -p 2220

📚 Concepts You Need to Know

The Challenge:

You need TWO things running AT THE SAME TIME:

  • Server: A listener that sends the current password when connected to
  • Client: The suconnect binary that connects to your listener

Background processes: Adding & at the end of a command runs it in the background, so you can run more commands!

✅ Step-by-Step Solution

  1. Get current password:
    cat /etc/bandit_pass/bandit20
    Copy it!
  2. Start a listener on any port (e.g., 6000):
    echo "[PASTE BANDIT20 PASSWORD]" | nc -l -p 6000 &
    Breaking this down:
    • echo "password" - Output the password
    • | - Pipe it to netcat
    • nc -l -p 6000 - Listen on port 6000
    • & - Run in background!
  3. Verify it's listening:
    jobs
    Or: netstat -ln | grep 6000
  4. Now connect with suconnect:
    ./suconnect 6000
    What happens:
    • suconnect connects to port 6000
    • Your listener sends the bandit20 password
    • suconnect verifies it's correct
    • suconnect sends back bandit21 password!
  5. Output:
    Read: [BANDIT20 PASSWORD]
    Password matches, sending next password
    [BANDIT21 PASSWORD]
✅ What You Learned:
  • & runs commands in background
  • nc -l -p PORT creates a listener
  • jobs shows background processes
  • You can pipe data to network connections
  • Client-server communication basics
💡 Process Control:
  • command & - Run in background
  • jobs - List background jobs
  • fg %1 - Bring job 1 to foreground
  • bg %1 - Continue job 1 in background
  • Ctrl+Z - Suspend current process
  • kill %1 - Kill job 1

⏰ Levels 21-25: Cron Jobs, Git & Shell Scripting

🎯 Level 21 → 22: Cron Jobs
Cron = task scheduler (runs commands at specific times). Check /etc/cron.d/ for scheduled tasks. Read cron scripts to understand what they do!

cat /etc/cron.d/cronjob_bandit22
Look for script paths, read those scripts!

🎯 Level 22 → 23: Shell Scripting & MD5 Hashing
Script uses md5sum to create filename. Understand bash variables ($USER, $(command)) and command substitution!

echo I am user $myname | md5sum
Generate hash, find file in /tmp with that name!

🎯 Level 23 → 24: Writing Your Own Script
Cron job executes scripts in a directory. You can WRITE your own script that gets executed by bandit24!

#!/bin/bash
cat /etc/bandit_pass/bandit24 > /tmp/mypass

Make executable with chmod +x, wait for cron!

🎯 Level 24 → 25: Brute Force Attack
Daemon on port 30002 needs password + 4-digit PIN (0000-9999). Write a script to try ALL combinations!

for i in {0000..9999}; do
  echo "PASSWORD $i"
done | nc localhost 30002

Brute force all 10,000 combinations!

🎯 Level 25 → 26: Escaping More Shell
SSH logs you out via shell. But there's a SETUID binary that uses more pager. If terminal is small, you can escape from more!

ssh -t bandit26@localhost -i key
Make terminal TINY, press 'v' in more to enter vim, read password from vim!

✅ Key Concepts Covered:
  • Cron: /etc/cron.d/, crontab syntax
  • Shell scripting: Variables, command substitution, loops
  • MD5 hashing: md5sum, unique fingerprints
  • File permissions: chmod +x to make executable
  • Brute force: Trying all possible combinations
  • Pager escapes: Breaking out of more, less

🔥 Advanced Levels 26-34: Expert Territory

⚠️ These Levels Are HARD!

Levels 26-34 require advanced techniques combining everything you've learned. Each level builds on previous skills:

🎯 Levels 26-27: Vim Escape

Concepts: Terminal resizing, vim editor exploitation, shell escape from vim
Key commands: :set shell=/bin/bash, :shell
Trick: Use vim's command mode to spawn shell and read files!

🎯 Levels 28-29: Git Repository

Concepts: Git history, commits, diffs, branches
Key commands: git log, git show, git diff
Trick: Password was committed then removed - check git history!

🎯 Level 30: Git Tags

Concepts: Git tags (version markers)
Key commands: git tag, git show TAG
Trick: Password hidden in a git tag annotation!

🎯 Level 31: Git Push

Concepts: Remote git repositories, pushing commits
Key commands: git add, git commit, git push
Trick: Create a file, commit it, push to remote - password returned!

🎯 Level 32: Uppercase Shell

Concepts: Shell variable exploitation
Key trick: Shell converts commands to UPPERCASE (can't run normal commands!)
Solution: Use $0 (refers to shell itself) to spawn new shell!

🎯 Levels 33-34: Final Boss

Concepts: Combination of ALL previous techniques
Requirements: Mastery of file permissions, shell tricks, network knowledge
Reward: You've beaten Bandit! 🎉

💎 Essential Skills for Advanced Levels

🔧 Git Mastery

git log --all
git show HASH
git branch -a
git checkout BRANCH

📝 Vim Escapes

:set shell=/bin/bash
:shell
:!/bin/bash
:read /path/file

⚡ Shell Variables

$0 - Current shell
$$ - Process ID
$? - Last exit code
$_ - Last argument

🔐 Permissions

chmod +x file
find / -perm -4000
ls -la
stat file

🎓 Congratulations!

You now have a COMPLETE roadmap of all 34 Bandit levels! You've learned:

Linux Commands File Permissions SSH & Networking Encryption Privilege Escalation Shell Scripting Git Mastery

Ready to put your skills into practice?

🎯 You've Mastered All 34 Bandit Levels!

You've now mastered 7 Bandit levels! The remaining levels (7-34) cover: grep, sorting, encoding, compression, SSH keys, port connections, cron jobs, and more. Keep applying this same learning pattern - understand the concept, try the command, learn from outputs.

📚 Quick Reference: Commands You've Mastered
ssh - Remote login
ls -la - List with hidden files
cat - Read files
cd - Change directory
file - Check file type
find - Search by properties
./ prefix - Handle special filenames
2>/dev/null - Suppress errors

🚀 Advanced Levels Preview

Level 7-10:
grep patterns, sorting data, unique lines, binary strings
Level 11-15:
Base64, ROT13, compression (gzip/bzip2/tar), SSH keys
Level 16-20:
Port scanning, SSL, diff, cron jobs, setuid binaries
Level 21-34:
Shell scripting, git, password cracking, more!
Go to OverTheWire → ← Back to Resources