tutorial · bandit

Bandit Level 2

Handle spaces in filenames safely (quotes and escaping).
banditfilesquoting
Optional narration
Marks this level complete in your browser.

Goal

The password for the next level is stored in a file with spaces in the name.

Key concept

Shells split on spaces. So you must either:

  • quote the filename, or
  • escape the spaces

Steps

  1. SSH in:
ssh bandit2@bandit.labs.overthewire.org -p 2220
  1. List files:
ls
  1. Read the file:

Option A (recommended): quotes

cat "spaces in this filename"

Option B: escape spaces

cat spaces\ in\ this\ filename

That output is the password for Level 3.

Notes

  • When in doubt, press Tab for autocomplete (it helps avoid typos and shows you what the shell thinks the path is).