OverTheWire Bandit Level 2->Level 3 - Walkthrough
Introduction
In this article, I will give you a walkthrough of the Bandit wargame Level 2->Level 3. This article will help the player clear the wargame with additional knowledge on how to deal with spaces in a filename.
The player is required to fetch the password from a file containing spaces located in the home directory. Commands used will be same as in the previous levels.
Goal
Get the password for Level 3 from the file named 'spaces in this filename'.
Login Details
Server - bandit.labs.overthewire.org
Port - 2220
Username - bandit2
Password - rRGizSaX8Mk1RTb1CNQoXTcYZWU6lgzi
Theory
Just like in the previous posts, you need to login through SSH and find the file placed in the home directory. You will observe that the file name is "spaces in this filename" and it contains space in its name. As a convention, there should not be spaces placed within a filename or a directory. Instead, underscore(_) should be used to separate words.
This is because bash shell will interpret the space separated
strings as individual command argument. For example, the command "cat
spaces in this filename" will be considered by the bash shell as four
separate cat commands and it will try to output the four files-:
- cat spaces
- cat in
- cat this
- cat filename
I would highly commend you to read this article for a detailed explanation on how to deal with spaces within a filename.
Solution
As described in previous posts, login to bandit2 through SSH using the command "ssh bandit2@bandit.labs.overthewire.org -p 2220" and above password. Locate the file in the home directory using the command ls.
Observe the spaces within the filename and the error that we get on using the cat command as "cat spaces in this filename".
To avoid the error and read the file, we need to enter the filename within quotes or with backslash preceding the spaces in the filename. Below are the ways through which we can get the required output-:
- cat "spaces in this filename"
- cat 'spaces in this filename'
- cat spaces\ in\ this\ filename
As required, you have got the next level's password. This
completes the Level 3 walkthrough.
I would encourage you to write your thoughts in the comments
of this post if you have any questions or recommendations to make it better.





Comments
Post a Comment