← Bandit Solutions

Level 1 → Level 2 Walkthrough

Level 1 → Level 2

Completed

📋 Level Information

Host: bandit.labs.overthewire.org
Port: 2220
Username: bandit1
Password: [From Level 0]

🎯 Level Goal

The password for the next level is stored in a file called - located in the home directory.

Challenge: The filename is just a dash (-), which is a special character in Linux command line.

🔧 Solution Steps

Step 1: Connect to Bandit1

Use the password you obtained from Level 0 to log in:

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

Step 2: List Files in Home Directory

Check what files are available:

ls

You should see a file named - (just a dash)

Step 3: Read the File (Method 1 - Using ./ prefix)

The safest way to read a file named "-" is to specify the path explicitly:

cat ./-

Step 4: Read the File (Method 2 - Using stdin redirection)

You can also use input redirection to read the file:

cat < -

Step 5: Read the File (Method 3 - Using -- argument)

Many commands accept "--" to indicate the end of options:

cat -- -

Step 6: Get the Password

Whichever method you use, the command will output the password for Level 2.

CV1DtqXWVFXTvM2F0k09SHz0YwRINYA9

💡 Explanation

This level teaches you how to handle filenames with special meanings in Linux.

Why the Dash (-) Causes Problems:

  • In Linux command line, a single dash (-) typically represents standard input (stdin) or standard output (stdout)
  • When you type cat -, the system expects you to provide input from the keyboard
  • It doesn't interpret - as a filename because it has a special meaning

Solution Methods:

  • ./ prefix: Adding ./ before the filename makes it clear you're referring to a file in the current directory
  • Stdin redirection: Using < tells the shell to read from the file rather than expecting keyboard input
  • -- argument: The double dash (--) signals the end of command options, so anything after it is treated as a filename

⚠️ Common Mistakes

  • Trying cat - alone: This will put you in input mode waiting for keyboard input
  • Forgetting the path: Always specify the path when dealing with special filenames
  • Confusing with options: Remember that single characters after a command are often interpreted as options

💡 Pro Tips

  • Using ./- is the most reliable method across different systems
  • The -- method works with many commands, not just cat
  • You can press Ctrl+D to exit if you accidentally run cat - without the proper syntax
  • Remember this technique for any filename that starts with a dash
← Previous Level Next Level →