← Back to Home

OverTheWire Bandit: Level 2 → Level 3

Technical Note

1. Context

We have logged in as bandit2. The password for the next level is stored in a file named --spaces in this filename-- located in our home directory. Our task is to read this file which contains spaces and starts with dashes.

2. Technical Logic

This filename presents a double challenge for the Linux Shell:

  1. Spaces: Interpreted as delimiters by the Shell.
  2. Dashes (- or --): Interpreted as the start of a command flag/option.

Simply quoting it (cat "--spaces...") might not be enough, as the command could still parse it as a flag. We need to combine quoting with an explicit path indication.

3. Execution

Step 1: List Files

ls
# Output: --spaces in this filename--

Step 2: Read Content The safest method is to specify the file relative to the current directory (./) while also quoting it.

Method: Quotes + Relative Path (Best Practice)

cat "./--spaces in this filename--"

Alternative: Escaping

cat \-\-spaces\ in\ this\ filename\-\-

Method C: Tab Completion (Practical) Type the first few letters of the filename and press the TAB key. The Shell will automatically apply the correct formatting (usually escaping).

cat "./--<TAB>"
# Automatically becomes: cat "./--spaces in this filename--"

4. Result

Copy the password, log out, and connect to the next level. Logout: exit New Connection: ssh bandit3@bandit.labs.overthewire.org -p 2220