OverTheWire Bandit Walkthrough ๐
What is Flag?
๐ Happy New Year (2025)! ๐
May this year bring you success, joy, and countless adventures in your learning journey!
Introduction
Ready to dive into the OverTheWire Bandit CTF series? ๐ต๏ธโโ๏ธ This walkthrough is a guide. Whether youโre a beginner or looking to brush up your basics, the Bandit series is perfect for honing your Linux command-line skills while navigating realistic scenarios.
Before You Start: Make sure to check out the rules to ensure a fair and fun experience.
This guide covers:
- Detailed objectives for each level.
- Commands and step-by-step solutions.
- Explanations to help you understand the โwhyโ behind each step.
Letโs gear up, fire up your terminal, and tackle these challenges head-on!
note: for each level at ssh increase the count before the username
bandit0 , bandit1, bandit3, bandit4...
and so on.
Level 0
- Objective : Connect to the Bandit server via SSH.
- Steps:
- SSH into the server with the provided credentials.
- The username is
bandit0
, and the host isbandit.labs.overthewire.org
. - Use port
2220
instead of the default port22
. - password is
bandit0
- Command:
ssh bandit0@bandit.labs.overthewire.org -p 2220
and level0 -> level1 begins
Level 0 -> Level 1
- Objective: The password for the next level is stored in a file called readme located in the home directory.
- Command:
ssh bandit0@bandit.labs.overthewire.org -p 2220
- locate the file by
find readme
orls
command. - use
cat readme
to read the content in the file.
- locate the file by
- Password:
ZjLjTmM6FvvyRnrb2rfNWOZOTa6ip5If
- Explanation: SSH (Secure Shell) is a protocol to connect to remote servers securely. Here, we use the username and host details along with a non-standard port.
Level 1 -> Level 2
- Objective: Read a file named
-
in the home directory. - Steps:
- Use
ls
to list the files in the directory.ls
- Notice a file named
-
. This is tricky because-
is often treated as an option by commands. - To read the file, prefix the name with
./
to indicate itโs a file.
- Use
- Command:
cat ./-
- Password:
263JGJPfgU6LtdEvgfWU1XP5yac29mFx
- Explanation: The
./
tells the shell that-
is a file in the current directory and not an option for thecat
command.
Level 2 -> Level 3
- Objective: Read a file with spaces in its name.
- Steps:
- Use
ls
to list the files in the directory.ls
- Youโll see a file named
spaces in this filename
. - To read it, enclose the name in quotes or escape the spaces with
\
.
- Use
- Command:
cat "spaces in this filename"
- Password:
MNk8KNH3Usiio41PRUEoDFPqfxLPlSmx
- Explanation: Quotes or escape characters allow you to handle file names with special characters or spaces.
Level 3 -> Level 4
- Objective: Find and read a hidden file.
- Steps:
- Use
ls
to list files, but it wonโt show hidden ones (files starting with.
). - Use
ls -a
to include hidden files in the listing.ls -a
- Youโll see a hidden directory named
inhere
. Navigate into it and list files again. - Inside, find a hidden file named
.hidden
and read it.
- Use
- Command:
cat inhere/.hidden
- Password:
2WmrDFRmJIq3IPxneAaMGhap0pFhF3NJ
- Explanation: The
-a
flag withls
lists all files, including hidden ones. Hidden files are often used to store sensitive data.
Level 4 -> Level 5
- Objective: Find the password in one of multiple files.
- Steps:
- Use
ls
to see multiple files namedfile01
,file02
, etc., in theinhere
directory. - Read all the files manually or use a single command to output them together.
- Use
- Command:
cat inhere/file*
- Password:
4oQYVPkxZOOEOO5pTW81FB8j8lxXGUQw
- Explanation: The
*
wildcard matches all files starting withfile
. This saves time compared to reading files one by one.
Level 5 -> Level 6
- Objective: Search for a file of a specific size (1033 bytes).
- Steps:
- Use the
find
command to search for files meeting specific criteria.find . -type f -size 1033c
-type f
ensures youโre only looking for files.-size 1033c
looks for files exactly 1033 bytes (c
stands for bytes).
- Use the
- Password:
HWasnPhtq9AVKe0dmk45nxy20cvUa6EG
- Explanation: The
find
command is powerful for locating files based on attributes like size, ownership, and permissions.
Level 6 -> Level 7
- Objective: Find a file owned by a specific user and group.
- Steps:
- Use
find
with additional filters for ownership and size.find / -type f -user bandit7 -group bandit6 -size 33c 2>/dev/null
-user
and-group
filter by the fileโs owner and group.2>/dev/null
suppresses permission errors during the search.
- Use
- Password:
morbNTDkSW6jIlUc0ymOdMaLnOlFVAaj
- Explanation: Combining filters helps narrow down the results to the exact file youโre looking for.
Level 7 -> Level 8
- Objective: Search for the password beside the keyword โmillionthโ.
- Steps:
- Use
grep
to search for the keyword directly in the file.grep millionth data.txt
- The password will be displayed next to the keyword.
- Use
- Password:
dfwvzFQi4mU0wfNbFOe9RoWskMLg7eEc
- Explanation:
grep
is a tool for searching text patterns in files.
Level 8 -> Level 9
- Objective: Find the only unique line in a file.
- Steps:
- Use
sort
to arrange lines, thenuniq -u
to filter out duplicate lines.sort data.txt | uniq -u
- This command outputs the line that appears only once.
- Use
- Password:
4CKMh1JI91bUIZZPXDqGanal4xvAg0JM
- Explanation: Sorting is necessary because
uniq
only works on consecutive identical lines.
Level 9 -> Level 10
- Objective: Extract the password from printable strings starting with
==
. - Steps:
- Use
strings
to extract readable text from the file.strings data.txt | grep ==
- Filter the results using
grep
.
- Use
- Password:
FGUW5ilLVJrxX9kMYMmlN4MgbpfMiqey
- Explanation:
strings
is handy for reading text from binary files.
Level 10 -> Level 11
- Objective: Decode a Base64-encoded string.
- Steps:
- Use
base64
with the-d
flag to decode the file content.base64 -d data.txt
- The decoded string contains the password.
- Use
- Password:
dtR173fZKb0RRsDFSGsg2RWnpNVj3qRr
- Explanation: Base64 encoding is often used to represent binary data in ASCII format.
Level 11 -> Level 12
- Objective: Decrypt a ROT13-encoded file.
- Steps:
- Use the
tr
command to perform the ROT13 transformation.cat data.txt | tr 'a-zA-Z' 'n-za-mN-ZA-M'
- The password will be revealed after decryption.
- Use the
- Password:
7x16WNeHIi5YkIhWsfFIqoognUTyj9Q4
- Explanation: ROT13 shifts each letter by 13 places, a simple substitution cipher.
Up Next
To be contโฆ XD