← Back to Home

OverTheWire Bandit: Level 1 → Level 2

Technical Note

1. Context

We have logged in as bandit1 using the password from the previous level. The password for the next level is stored in a file located in the home directory named - (dash). Our goal is to read this file.

2. Technical Logic

In the Linux command line, the - character holds a special meaning. For most commands, it represents Standard Input (STDIN) or Standard Output (STDOUT) rather than a literal filename.

  • For instance, running cat - instructs the command to wait for keyboard input (stdin) instead of looking for a file on the disk.
  • To bypass this interpretation, we must use a Relative Path. Instead of referring to the file simply as -, we use ./-, which explicitly translates to “the file named - inside the current directory”.

3. Execution

Step 1: List Files

ls
# Output: -

Step 2: Verify File Type We prepend ./ to the filename to treat it as a path.

file ./-
# Output: ./-: ASCII text

Step 3: Read Content If you run cat -, the terminal might hang waiting for input (exit with Ctrl+C or Ctrl+D). The correct way is:

cat ./-
# Output: [The password is here]

Alternatively, providing the full path works as well: cat /home/bandit1/-

4. Result

Retrieve the password, terminate the session, and proceed to the next level. Logout: exit New Connection: ssh bandit2@bandit.labs.overthewire.org -p 2220