Lcome To OverTheWire
Lcome To OverTheWire
If you find any problems, please report them to the #wargames channel on
discord or IRC.
working directory with a hard-to-guess name in /tmp/. You can use the
with easily guessable or short names will be periodically deleted! The /tmp
firewall.
For your convenience we have installed a few useful tools which you can find
* radare2 (http://www.radare.org/)
http://www.overthewire.org/wargames/
bandit1@bandit:~$ ^C
| _ ___
[email protected]'s password:
,----.. ,----, .---.
/ / \ ,/ .`| /. ./|
. / ;. \ ; ; / /__./ \ : |
| : | ; | ' ; |.'; ; ; \ \; :
' ; \; / | ' : ; . \ .\ ;
bandit1@bandit:~$ cat ./ -
^C
263JGJPfgU6LtdEvgfWU1XP5yac29mFx
bandit2@bandit:~$ ls
MNk8KNH3Usiio41PRUEoDFPqfxLPlSmx
bandit2@bandit:~$
bandit2@bandit:~$ ls
MNk8KNH3Usiio41PRUEoDFPqfxLPlSmx
Level Goal
The password for the next level is stored in a hidden file in the inhere directory.
Goal:
The password for Level 4 is hidden in a file located in the inhere directory.
Key Steps:
List all files, including hidden ones, using ls -a to reveal files that start with a dot (.).
Find the hidden file containing the password by checking files like ...Hiding-From-You.
View the contents of the file using cat to retrieve the password.
Commands to Use:
The hidden file is in plain sight but requires using basic file listing and searching commands (ls, find,
cat) to retrieve the password.
2WmrDFRmJIq3IPxneAaMGhap0pFhF3NJ
bandit3@bandit:~/inhere$
2WmrDFRmJIq3IPxneAaMGhap0pFhF3NJ
bandit3@bandit:~/inhere$
Objective:
Learn how to locate files in a directory based on specific properties, such as size, type, and
permissions, using the find command.
Key Concepts:
File Searching:
The find command is used to search for files and directories based on various criteria.
File Properties:
Size: Measured in bytes, kilobytes, etc.
Excluding Files:
Navigate to a Directory:
cd inhere
-size 1033c: Look for files exactly 1033 bytes in size (c = bytes).
Step-by-Step Practice:
Use cd to navigate.
Use cat to view the content once the correct file is identified.
Lesson Outcome:
Use the find command to locate files based on size, type, and permissions.
Combine navigation (cd), searching (find), and viewing (cat) commands for efficient file
management.
Real-World Application:
These skills are essential for system administrators, developers, and anyone working with Linux-
based systems, enabling efficient file searches and effective troubleshooting.
To solve Bandit Level 6 → Level 7, you need to find a file that meets the specified criteria:
33 bytes in size
Here's a step-by-step guide to help you find the file and retrieve the password:
If you're not already logged in, use SSH to log into the Bandit server:
The find command can help you locate files based on user, group, size, and other attributes. To find
a file that is owned by bandit7, belongs to the group bandit6, and has a size of 33 bytes, run the
following command:
Explanation:
/: Start searching from the root directory (you can specify a subdirectory if you know one).
-size 33c: Look for files that are exactly 33 bytes in size (c means bytes).
Once the correct file is found (e.g., ./path/to/file), use the cat command to view its contents:
cat /path/to/file
4. Troubleshooting
If the search command finds no results or gives errors, try searching within a specific directory if you
know where the file might be located.
If you encounter permission errors, ensure you're using the correct user (bandit6).
Example Workflow
cat /path/to/file
Lesson Outcome
Using find to search for files based on multiple criteria (user, group, file size).
This skill is essential in tasks like system administration and troubleshooting in Linux environments.
To solve Bandit Level 7 → Level 8, the goal is to find the password stored in the data.txt file next to
the word "millionth."
Step-by-Step Guide:
To confirm that data.txt exists and locate it, you can use the ls command to list the contents of the
current directory:
ls
If it's not in the current directory, you can search for it:
Once you've confirmed the file exists, you can use the grep command to search for the word
"millionth" inside the file:
exit
This will display the line(s) containing the word "millionth" and the password next to it.
Copy the <password> after the word "millionth." This is the password for Level 8.
Additional Tips:
If the output is large or you want to clean it up, you can use grep with flags:
Show only the matching part of the line: grep -o "millionth.*" data.txt
Example Workflow
ls
Lesson Outcome:
This is a common task when working with logs, configuration files, or data files that contain
important information or secrets.
To solve Bandit Level 7 → Level 8, the goal is to extract the password from the data.txt file,
specifically the part next to the word "millionth".
If you're not already logged in, connect to the server via SSH:
You need to make sure that the file data.txt is in your current directory. You can list the files with:
ls
Once you find the data.txt file, use the grep command to search for the word "millionth" inside the
file:
This will display any lines containing the word "millionth" along with the password next to it.
Step 4: Extract the Password
millionth some_password_here
The password for the next level will be the string next to millionth.
If you just want the password without the word "millionth", you can pipe the output to awk or cut to
extract just the second word:
Using awk:
Using cut:
Once you have the password, use it to log into Bandit Level 8.
Example Workflow
ls
Lesson Outcome
These are fundamental skills that are often used in system administration, security, and text
processing tasks.
To solve Bandit Level 8 → Level 9, the goal is to extract the password from the data.txt file. The
password is the only line of text that occurs only once in the file.
If you're not already logged in, connect to the server via SSH:
Make sure you're in the correct directory where data.txt is located. You can check by running:
ls
If you see data.txt in the listing, you can proceed. Otherwise, use find to search for it.
The goal is to find the line that appears only once. You can achieve this by sorting the lines and then
using the uniq command to filter out duplicate lines.
First, sort the file:
sort data.txt
Explanation:
sort data.txt: Sorts the file so that duplicate lines are grouped together.
uniq -u: Filters out duplicate lines and displays only those that occur exactly once.
The command will print the unique line (which is the password) from data.txt. This is the password
for Level 9.
Once you have the password, use it to log into Bandit Level 9.
Example Workflow
Sort the contents of data.txt and display only the unique line:
the_unique_password_here
Additional Notes:
Piping and Redirection: This level reinforces the use of piping (|) to connect the output of one
command to the input of another. Here, sort sends its output to uniq, which processes it further.
The sort command is essential here because it organizes the lines so that uniq can easily find the
duplicates and single occurrences.
Lesson Outcome:
Learn to apply uniq to filter duplicate lines and find unique occurrences.
These skills are fundamental in text processing and data manipulation tasks on Linux systems.
To solve Bandit Level 9 → Level 10, the goal is to find the password stored in the data.txt file. The
password is one of the human-readable strings, which is preceded by several = characters.
Step-by-Step Guide:
Make sure you're in the correct directory where data.txt is located. If it's not there, use the find
command to locate it.
ls
The password is a human-readable string. To find human-readable content, you can use the strings
command. This command extracts printable characters from binary files or files with mixed content.
strings data.txt
This will output a list of readable strings from the file. Among them, look for one that is preceded by
= characters.
Once you've identified the readable string surrounded by = characters, the password for Level 10 will
be displayed.
To filter for strings that start with = characters, you can use grep:
This command will only display lines that start with = and may help isolate the relevant password.
Once you have the password, use it to log into Bandit Level 10.
Example Workflow
strings data.txt
Additional Notes:
strings Command: This command is essential when working with binary or mixed-content files, as it
extracts all sequences of printable characters.
Regular Expression: The grep "^=.*" pattern ensures that only lines starting with = are matched,
narrowing down the results to relevant strings.
Lesson Outcome:
How to use the strings command to extract human-readable text from files.
The importance of filtering specific content using regular expressions and grep.
The practical use of string searching when dealing with mixed-content files.
These skills are commonly used when dealing with data extraction, reverse engineering, and binary
analysis.
In Bandit Level 9 → Level 10, the goal is to find the password for the next level stored in a file named
data.txt. The password is among human-readable strings but is preceded by several = characters.
Preceded by = characters: This indicates a pattern to look for, where the desired string (password)
starts right after multiple = characters.
Commands to Use
Solution Steps
cd /path/to/level
Examine the file contents: Start with strings to extract human-readable text from data.txt:
strings data.txt
Filter lines with = characters: Use grep to find lines containing multiple = characters:
======password123
Save or copy the password: Copy the password and use it to log into the next level.
Notes
If data.txt is compressed (e.g., .tar, .gz, .bz2), you’ll need to decompress it first using tools like tar or
gzip:
gunzip data.txt.gz
By following these steps, you can extract the password and proceed to Level 10. Let me know if
you'd like further clarification!
In Bandit Level 10 → Level 11, your goal is to retrieve the password for the next level, which is stored
in a file named data.txt. The file contains Base64 encoded data.
Base64 is a binary-to-text encoding scheme that represents binary data in an ASCII string format. It's
commonly used to encode data for transmission or storage. When you decode Base64, you get the
original readable or binary data.
cd /path/to/level
View the contents of data.txt: Use cat or less to inspect the file and confirm it is Base64 encoded:
cat data.txt
If it looks like a mix of letters, numbers, and slashes, it’s likely Base64. Example:
SGVsbG8gd29ybGQhCg==
Decode the Base64 data: Use the base64 command with the -d option to decode:
base64 -d data.txt
The output should reveal the readable text, which contains the password.
Copy the password: The decoded output should be the password for the next level. For example:
Hello world!
Test the result: Use the password to log into the next level.
Commands Used
base64:
cat:
Example
VGhlIHBhc3N3b3JkIGlzIGZvb2Jhcg==
base64 -d data.txt
Output:
Additional Notes
If the file is compressed (e.g., .gz, .bz2, .tar), decompress it first.
Base64 encoding often adds padding characters (=) at the end of the encoded string. These are
normal and don’t affect decoding.
In Bandit Level 11 → Level 12, the password is stored in a file called data.txt, but all the letters in the
file have been ROT13-encoded. You need to decode the text to find the password.
What is ROT13?
ROT13 (short for "rotate by 13 places") is a substitution cipher where each letter of the alphabet is
replaced with the letter 13 positions ahead (or behind, since the alphabet has 26 letters).
For example:
cd /path/to/level
Examine the file contents: Use cat to view the content of data.txt:
cat data.txt
Decode the ROT13 text: Use the tr command to translate the characters:
cat data.txt | tr 'A-Za-z' 'N-ZA-Mn-za-m'
Extract the password: The decoded text will reveal the password. For example:
Save the password: Copy the password and use it to log into the next level.
tr 'A-Za-z' 'N-ZA-Mn-za-m':
Example
If data.txt contains:
Output:
Additional Notes
ROT13 only affects letters (a-z, A-Z) and leaves other characters (numbers, symbols, whitespace)
unchanged.
You can also use Python or other programming languages to decode ROT13, but tr is the simplest
approach.
In Bandit Level 12 → Level 13, the password is stored in a file named data.txt, which contains a
hexdump of a file that has been repeatedly compressed. You need to reverse the process (decode
the hexdump and decompress the data) to retrieve the password.
Key Concepts
Hexdump: A hexadecimal representation of binary data. To retrieve the original binary file, the
hexdump must be reversed.
Repeated Compression: The file has been compressed multiple times using various compression
methods. You'll need to identify the compression type and decompress it step by step.
Temporary Directory: It's good practice to work in a temporary directory to avoid clutter and
accidental overwrites. Use mktemp -d to create a secure temporary directory.
Step-by-Step Solution
mkdir /tmp/mytempdir
cd /tmp/mytempdir
Or, use:
cd "$(mktemp -d)"
cp /path/to/data.txt .
Determine the file type: Use the file command to identify the type of compression:
file data.bin
Example output:
data.bin: gzip compressed data
Decompress the file: Based on the file type, use the appropriate decompression command. Repeat
this step until all compression layers are removed.
If gzip:
mv data.bin data.gz
gunzip data.gz
If bzip2:
mv data.bin data.bz2
bunzip2 data.bz2
If tar:
mv data.bin data.tar
Repeat steps 4 and 5: After each decompression, use file to check the new file type and decompress
it again as needed.
Extract the password: Eventually, you’ll reach a human-readable file that contains the password. Use
cat or strings to read the file:
cat final_file
Example Walkthrough
file data.bin
Output:
Decompress Gzip:
mv data.bin data.gz
gunzip data.gz
Check Again:
file data
Output:
Decompress Bzip2:
mv data data.bz2
bunzip2 data.bz2
cat final_file
Tips
Work Incrementally: After each decompression step, use file to confirm the file type before
proceeding.
In Bandit Level 14 → Level 15, the goal is to retrieve the password for the next level by submitting
the password of the current level to port 30000 on localhost.
Key Concepts
Localhost:
Port:
nc (Netcat): A versatile networking utility for reading and writing to network connections.
openssl s_client: Used for secure communication but is not necessary for this level since it's not
encrypted.
Steps to Solve
The response will display the password for the next level.
Alternative: Using a File: You can store the password in a file and send it:
Example
Output:
Tips
Tools Comparison:
nc: Simple and widely used for such tasks.
openssl s_client: More secure but unnecessary here as the connection is not encrypted.
If Connection Fails: Ensure you are on the correct server (localhost) and using the right port (30000).
In Bandit Level 15 → Level 16, the password for the next level is retrieved by sending the current
level's password to port 30001 on localhost using SSL/TLS encryption.
Key Concepts
SSL/TLS Encryption:
OpenSSL s_client:
Localhost:
Steps to Solve
CONNECTED(00000003)
depth=0 ...
---
Once connected, paste the password for Bandit Level 15 and press Enter.
The server should respond with the password for the next level.
Automate the Submission: You can automate the process using echo and a pipe:
Look for the response in the output, which should contain the password for Level 16.
Example
Output:
Tips
Troubleshooting:
If you encounter messages like DONE, RENEGOTIATING, or KEYUPDATE, refer to the CONNECTED
COMMANDS section in the OpenSSL man page. Use commands like QUIT to properly terminate the
session if needed.
Alternative Tools:
While openssl s_client is the most straightforward, tools like ncat or socat can also handle SSL/TLS
connections.
OpenSSL outputs diagnostic information. Focus on the server’s response, which contains the
password.
In Bandit Level 16 → Level 17, the goal is to retrieve the credentials for the next level by submitting
the password for the current level to the correct SSL/TLS-enabled server on a port between 31000
and 32000.
Key Concepts
Port Scanning:
SSL/TLS Detection:
Server Responses:
Steps to Solve
Scan the Ports: Use nmap to find open ports in the range 31000-32000:
Check for SSL/TLS: For each open port, use openssl s_client to check if the server uses SSL/TLS:
Send the Password to the SSL Server: For the identified SSL/TLS server:
The correct server will respond with the credentials for Bandit Level 17.
Example
Scan ports:
Output (example):
Output:
CONNECTED(00000003)
depth=0 ...
---
Output:
username: bandit17
password: xyz456
Tips
ss -tuln | grep 31
Ensure you test all open ports in the range to find the correct SSL/TLS server.
If OpenSSL reports RENEGOTIATING, try resending the password or restarting the connection.
In Bandit Level 17 → Level 18, the task is to find the password for the next level by identifying the
line that has been changed between two files: passwords.old and passwords.new.
Key Concepts
diff:
A command-line tool that compares two files line by line and highlights differences.
File Comparison:
passwords.new: Contains the updated passwords, including the one for the next level.
Steps to Solve
ls
Use diff to Find Changes: Compare the two files using diff:
For example:
42c42
< oldpassword
---
> newpassword
The password for the next level is the new line in passwords.new.
Save the Password: Copy the password for use in the next level.
Example
Compare files:
Output:
5c5
< abc123
---
> xyz456
Alternative Approach
Output:
xyz456
Tips
Avoiding Errors:
If diff or grep gives unexpected results, double-check file contents with cat.
Byebye Issue:
If you see "Byebye!" when logging into Bandit 18, it's related to Bandit Level 19, not this level.
In Bandit Level 18 → Level 19, the challenge is to retrieve the password from a file named readme in
the home directory, despite being logged out automatically due to a modified .bashrc file.
Key Concepts
.bashrc File:
SSH provides options to run commands directly on the remote system without starting an interactive
shell, bypassing .bashrc.
Steps to Solve
Log in Using SSH and Run a Command: Use the ssh command to directly read the readme file
without starting an interactive session:
The password for the next level will be displayed in the terminal.
Copy the Password: Save the displayed password for use in the next level.
Example
Command:
Output:
abcdefghijklmnopqrst
Tips
Don’t attempt to log in normally using ssh bandit18@.... It will immediately log you out.
Debugging:
In Bandit Level 19 → Level 20, the task is to use a setuid binary in the home directory to gain access
to the password for the next level. This involves executing the binary in a way that allows you to
access the password located in /etc/bandit_pass.
Key Concepts
A special permission that allows a user to execute a program with the privileges of the owner of the
file (usually root).
When a binary has the setuid bit set, it runs with the permissions of the file's owner, rather than the
user who runs it.
Setuid Binary:
The binary file in the home directory is likely designed to allow you to elevate your privileges
temporarily, enabling you to read the password file located at /etc/bandit_pass.
Steps to Solve
Log in to Bandit Level 19: If you are not already logged in, connect using SSH:
Locate the Setuid Binary: List the files in the home directory to find the setuid binary:
ls -l
You should see a file with the setuid bit set, indicated by an s in the permissions (e.g., -rwsr-xr-x).
Execute the Setuid Binary: Run the binary without any arguments to understand how it works:
./setuid_binary_name
This will likely provide information on how to use the binary, possibly giving you instructions or
output that reveals how to access the password.
Read the Password File: Once you have used the setuid binary correctly, it should grant you the
necessary privileges to access the password for the next level from /etc/bandit_pass.
cat /etc/bandit_pass
Save the Password: Copy the password for Bandit Level 20 and use it to log into the next level.
Example
ls -l
./setuid_binary
Access /etc/bandit_pass:
cat /etc/bandit_pass
Tips
Investigating Setuid: If you're unsure about the setuid binary, you can inspect it with file or strings to
get more details:
file setuid_binary_name
strings setuid_binary_name
Permissions: If you're not able to run the binary, check if the setuid bit is properly set by looking at
the file permissions with ls -l.
Let me know if you need more help with this or any other level!
Here's a summary of the key commands used in the OverTheWire Bandit practice so far, categorized
by their functionality:
Example: chmod 755 file.txt (gives read, write, and execute permissions to the owner, and
read/execute permissions to others)
4. Text Manipulation
Example: grep 'password' file.txt (searches for the word "password" in file.txt)
nc (Netcat): A network utility for reading from and writing to network connections.
telnet: A tool to communicate with remote servers via the Telnet protocol.
Example: kill <PID> (kills the process with the specified PID)
nohup: Runs a command immune to hangups (e.g., when the terminal is closed).
SSL/TLS Tools:
Example: openssl s_client -connect localhost:30001 (connects to an SSL/TLS service on port 30001)
This list encompasses most of the key commands used in the OverTheWire Bandit challenges so far.
Understanding and practicing these commands will help you perform various system administration
tasks, troubleshoot, and interact with network services efficiently.
Moses