OverTheWire Bandit Walkthrough
What is Flag?
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
2220instead of the default port22. - password is
bandit0
- Command:
ssh bandit0@bandit.labs.overthewire.org -p 2220and 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 readmeorlscommand. - use
cat readmeto 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
lsto 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 thecatcommand.
Level 2 -> Level 3
- Objective: Read a file with spaces in its name.
- Steps:
- Use
lsto 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
lsto list files, but it won’t show hidden ones (files starting with.). - Use
ls -ato 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
.hiddenand read it.
- Use
- Command:
cat inhere/.hidden - Password:
2WmrDFRmJIq3IPxneAaMGhap0pFhF3NJ - Explanation: The
-aflag withlslists 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
lsto see multiple files namedfile01,file02, etc., in theinheredirectory. - 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
findcommand to search for files meeting specific criteria.find . -type f -size 1033c -type fensures you’re only looking for files.-size 1033clooks for files exactly 1033 bytes (cstands for bytes).
- Use the
- Password:
HWasnPhtq9AVKe0dmk45nxy20cvUa6EG - Explanation: The
findcommand 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
findwith additional filters for ownership and size.find / -type f -user bandit7 -group bandit6 -size 33c 2>/dev/null -userand-groupfilter by the file’s owner and group.2>/dev/nullsuppresses 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
grepto 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:
grepis a tool for searching text patterns in files.
Level 8 -> Level 9
- Objective: Find the only unique line in a file.
- Steps:
- Use
sortto arrange lines, thenuniq -uto 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
uniqonly works on consecutive identical lines.
Level 9 -> Level 10
- Objective: Extract the password from printable strings starting with
==. - Steps:
- Use
stringsto extract readable text from the file.strings data.txt | grep == - Filter the results using
grep.
- Use
- Password:
FGUW5ilLVJrxX9kMYMmlN4MgbpfMiqey - Explanation:
stringsis handy for reading text from binary files.
Level 10 -> Level 11
- Objective: Decode a Base64-encoded string.
- Steps:
- Use
base64with the-dflag 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
trcommand 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