OverTheWire Bandit - LVL2 (Completed):

The goal for → LVL 2::

Level Goal:

→ The password for the next level is stored in a file called spaces in this filename located in the home directory.

Commands you may need to solve this level:

ls , cat

Explanation:

Password for Bandit2: 263JGJPfgU6LtdEvgfWU1XP5yac29mFx

Using what we learned from the last lesson, ssh into Bandit Lvl 0. We can do this by entering the following:

ssh bandit2@bandit.labs.overthewire.org -p2220

You’ll then be asked to enter the password for Bandit2. Type it in and press enter (REMEMBER, you wont see the password type out on screen so type it carefully and correctly). Once this is done you’ll successfully connect:

Now, we have already been told what file the password for the next level is located in so lets start looking for this by using the ls command.

When we do this we see is a file called “spaces in this filename” (a very self explanatory name). We can try and access this file as normal using the cat command but we will come across an error:

In the above you can see I've attempted it without speech marks.

The error occurred as the shell thought I was providing separate files to locate as you can provide multiple filenames using the cat command. This is an issue as we need to let the system know we are trying to locate a filename with ALL the words together, not separate.

So how do we solve this issue?

(At least now you know to NEVER save a filename like this, instead of spaces use dashes or underscores, it’ll stop your Linux friends from ripping their hair out).

Filenames with spaces in them… in Linux:

For more information on Dashed Filenames, please visit the link below:

Dealing With Spaces in Filenames in Linux

As you can see in the image below there are 3 ways you can solve this issue:

Option No.1: The use of Backslash before every space in the filename.

cat spaces\\ in\\ this\\ filename

  • Now typing this out is all very long, but Linux is always looking to be efficient so we can still do this but through tab completion.

  • After you type cat command, type the first word of the filename and then press the tab button, you should see that the tab completion automatically fills out the rest of the filename with backslashes. This is what I did in the above.

Option No.2: Encasing the filename within single quotes.

cat 'spaces in this filename'

Option No.3: Encasing the filename within double quotes.

cat "spaces in this filename”

Our Level 3 password is: MNk8KNH3Usiio41PRUEoDFPqfxLPlSmx

That is Bandit Level 2 complete, Head over to Bandit Level 3!

0
Subscribe to my newsletter

Read articles from Mike Kobbie Tieku TABI directly inside your inbox. Subscribe to the newsletter, and don't miss out.

Written by

Mike Kobbie Tieku TABI
Mike Kobbie Tieku TABI