OverTheWire Bandit: levels 0–12
What I did in Bandit levels 0–12: SSH, hidden files, find, errors, and a hexdump. No passwords included.
Spoilers ahead. Levels 0–12. Try each level first. Under OverTheWire's rules for content creators, I do not publish passwords. Every password here is redacted. Bandit is free, so consider donating if it helps you.
Bandit is a free game from OverTheWire. It teaches Linux by giving you small puzzles. You connect over SSH, find a password on the machine, and use it to log in to the next level.
These notes cover levels 0 → 12. I wrote down what I did, including the mistakes, so I can repeat the process later.
Before you start
- Starting password: on the Bandit level 0 page
- The username changes each level:
bandit0,bandit1,bandit2, and so on. - A Linux or macOS terminal is enough. On Windows, use WSL.
- Read the error messages. They usually tell you what went wrong.
SSH lets you log in to another computer over the network.
# The port is 2220, not the default 22.
ssh bandit0@bandit.labs.overthewire.org -p 2220
The first time, SSH asks if you trust the host fingerprint. You cannot check it for a game host, so type yes. On a real server, check it against a known value first.
Then paste the password from the level page. It will not show on screen while you type. That is normal.
Shell symbols you will see
If you are new to the command line, this table helps:
| Symbol | What it means |
|---|---|
$ |
The prompt. Do not type it. |
| |
Pipe. Sends one command's output to the next command. |
./ |
"In this folder." ./- means the file named - here. |
~ |
Your home folder. |
* |
Wildcard. ./-file* matches every name that starts with -file. |
Level 0 → 1: log in and read the README
Look around:
ls
There is one file, readme. Read it:
cat readme
It explains the rules and ends with the password for bandit1:
The password you are looking for is: [redacted]
Log out, then log in as bandit1 with that password.
Level 1 → 2: a file named -
The password is in a file called -. The obvious command seems to hang:
cat -
A lone - usually means "read from standard input," not "read a file named -." Give it a path:
ls -l
file ./-
cat ./-
./- means "the file named - in this folder." file confirms it is text before you read it.
Level 2 → 3: spaces in the filename
This file has spaces and leading dashes in its name. Put quotes around it:
ls
cat ./"--spaces in this filename--"
The quotes keep the whole name as one argument. Without them, the shell splits it into pieces. Tab completion also helps: type cat ./--sp and press Tab.
Level 3 → 4: hidden files
There is a folder called inhere, but it looks empty:
cd inhere
ls
Nothing. On Unix, a hidden file is a file whose name starts with a dot. Ask for hidden entries:
ls -a
You will see ...Hiding-From-You next to . and ... Read it:
ls -la
cat ...Hiding-From-You
The leading dots are part of the name. They do not mean "go up a folder" unless the name is exactly . or ...
Level 4 → 5: the readable file
Log in as bandit4, then enter the folder:
cd inhere
There are ten files, -file00 through -file09. Only one is readable text. Do not cat all of them. Ask the system what they are:
file ./-file*
One is ASCII text. The rest are data. Read the text one:
cat ./-file07
The answer is usually -file07, but trust file, not my notes.
If you run cat ./-file*, you will get a screen of binary garbage and maybe a broken terminal. reset fixes the display. It does not delete anything.
Level 5 → 6: find by size
Log in as bandit5. The password is somewhere under inhere, in a file that is readable text, exactly 1033 bytes, and not executable.
cd inhere
find . -type f -size 1033c ! -executable
What each part does:
-type f: normal files only.-size 1033c: exactly 1033 bytes. Thecmeans bytes.! -executable: skip anything you can run.
Then confirm and read:
file ./maybehere07/.file2
cat ./maybehere07/.file2
Your path may be different. Use whatever find printed.
Level 6 → 7: the whole filesystem and a wall of errors
Now the file can be anywhere. The level says it is owned by user bandit7, owned by group bandit6, and 33 bytes. Search from the root:
find / -type f -size 33c -user bandit7 -group bandit6
You will get a wall of Permission denied. That is expected.
Errors go to standard error (file descriptor 2). The result goes to standard output (file descriptor 1). You can throw the errors away:
find / -type f -size 33c -user bandit7 -group bandit6 2>/dev/null
2>redirects file descriptor 2, which is stderr./dev/nullthrows data away.
Now the result is readable: /var/lib/dpkg/info/bandit7.password. Read it:
cat /var/lib/dpkg/info/bandit7.password
Level 7 → 8: grep the millionth word
data.txt is about 4 MB. It has one word per line followed by a value. The password is next to the word millionth. Do not read the whole file:
grep "millionth" data.txt
grep prints the matching line. The value on that line is the next password.
Level 8 → 9: the line that appears once
data.txt is full of repeated random strings. The password is the only line that appears exactly once.
sort data.txt | uniq -u
sort is not optional. uniq only compares lines next to each other. Sorting puts identical lines together. uniq -u prints only lines that appear once.
sort -u removes duplicates and prints each remaining line once. sort | uniq -u prints only lines that had no duplicate at all. They answer different questions.
Level 9 → 10: strings in a binary
file data.txt says this is data, not text. cat would dump binary noise. strings pulls readable text out of a binary. The level says the password is one of the few readable strings, preceded by several = characters:
strings data.txt | grep "="
The match is one line: several equals signs followed by the password.
Level 10 → 11: base64
data.txt is text, but it is encoded. file will not tell you which encoding. The level does. Base64 turns binary data into text. It is encoding, not encryption:
base64 -d data.txt
-d means decode. You will get a sentence that ends with the next password. If a string uses only letters, digits, +, and /, and ends with = or ==, base64 is a good guess.
Level 11 → 12: ROT13
Every letter in this file is shifted 13 places. ROT13 is its own inverse: apply it twice and you get the original back. tr maps one set of characters to another:
tr 'A-Za-z' 'N-ZA-Mn-za-m' < data.txt
A becomes N, B becomes O, and so on, wrapping at Z. Lowercase works the same way. tr only reads standard input, so < avoids an extra cat.
Level 12 → 13: the hexdump
data.txt is a hexdump of a file that was compressed many times. You need to reverse the hexdump, then keep asking file what you have and decompressing it with the right tool.
Make a working folder under /tmp and copy the data there:
WORK=$(mktemp -d)
cp ~/data.txt "$WORK/"
cd "$WORK"
mktemp -d creates a unique folder and prints its name. $(...) runs that command and puts the result in WORK.
Reverse the hexdump:
xxd -r data.txt data1
file data1
xxd -r turns the hexdump back into binary. file says gzip, so give it a .gz name and decompress:
mv data1 data.gz
gunzip data.gz
file data
gunzip removes the .gz file and writes data. Now file says bzip2. Same pattern:
mv data data.bz2
bzip2 -d data.bz2
file data
From here, the loop is always the same:
- Run
fileon the current file. - If it says gzip, rename to
.gzand rungunzip. - If it says bzip2, rename to
.bz2and runbzip2 -d. - If it says tar, rename to
.tarand runtar xf. - Repeat until
filesays ASCII text.
The layers come in this order: gzip, bzip2, gzip, tar, tar, bzip2, tar, gzip. The names come from the archives, so use whatever ls shows. The remaining layers look like this:
# gzip again
mv data data.gz && gunzip data.gz
# then the rest of the layers
mv data data.tar && tar xf data.tar # -> data5.bin
mv data5.bin data5.tar && tar xf data5.tar # -> data6.bin
mv data6.bin data6.bz2 && bzip2 -d data6.bz2 # -> data6
mv data6 data6.tar && tar xf data6.tar # -> data8.bin
mv data8.bin data8.gz && gunzip data8.gz # -> data8
file data8
cat data8
file says ASCII text, and cat prints the password sentence:
The password is [redacted]
file is the map. Extensions are only hints.
Clean up when you are done: cd ~ && rm -r "$WORK". That deletes only the temporary folder you created.
Level 13 → 14: the next part
Level 13 changes the pattern. Instead of a password, it gives you a private SSH key that logs in as bandit14. The next password is in a file only bandit14 can read. That means key permissions, ssh -i, and reading error messages carefully.
I have not written that part yet. Level 14 is next.
What I learned
None of these levels needed a clever exploit. They needed the right small tool:
ls -afor hidden names.filebeforecat, especially when the file might not be text.findfor more than names.2>to separate useful output from noise.grep,sort,uniq,strings,base64, andtrto filter and decode.xxd -rplusfileto peel back compression layers.
The real skill is the same one that matters in security work: look, make a small guess, test it, and read the error when it fails.
Thanks to the OverTheWire community for keeping Bandit free. If you are playing, follow the rules and do not post passwords. That is why every password above is redacted.
Level 14 next.