OverTheWire.org Walkthrough: Bandit

LEVEL 3→4

~ Level Description ~

The password for the next level is stored in a hidden file in the inhere directory.

Commands from previous levels may be useful in solving this level. The commands provided are: ls, cd, cat, file, du, find.


Research Before Solving

The key information from the level's description seems to be that file the password is being stored in is hidden. We know the ls command is used to list out files in a directory. Is there an option that allows us to see hidden files? How do we know if a file is hidden in Linux?

Using our preferred search engine, let's see how a hidden file is denoted in Linux.

Hidden files are denoted by a period in front of the name

If we recall the switches available for use with the ls command, the -a option made it so entries with a period were not ignored. This command and switch may very well prove to be the solution.


Solution Walkthrough

As has been done previously, SSH into the OverTheWire server, this time using bandit3 during username substitution: ssh bandit3@bandit.labs.overthewire.org -p 2220. After pasting in the password you should have a shell prompt available as user bandit3@bandit.

Since we are again in the home directory by default, let's run the ls command to list the files inside.

Output of LS command inside the home directory

The instructions told us that the file is located inside of the inhere directory . Next we need to find a way to change directories. The cd command looks to be an acronym of change directory. If you didn't previously or if you need a refresher, use the built in documentation function and type cd --help to learn about this command.

Output of CD --help command

According to the documentation our hunch was correct, cd is used to change directories. The documentation also shows us we simply need to use cd followed by the name of the directory we wish to switch to. Your command for the next step should look like this: cd inhere

Output of using cd inhere command

Notice there is no visual message confirming that we swapped directories. If we look at the command line after the user, however, we see :~/inhere$. This shows us we are now in the directory by the name of inhere.

Now that we are in the proper directory, we need to input the ls command with the -a switch to list all files, including hidden ones, in the current working directory.

Output of LS -a command showing inhere directory

We can now see a file with the name of .hidden! This should be the file we are looking for. In order to view the contents of the file, we will use the cat command. Making sure to add ./ in front of the filename just as we did previously to see the contents of the dash filename. The command will be: cat ./.hidden

Success! The hidden file has been opened to reveal the password to the next level: pIwrPrtPN36QITSp3EQaw936yaFoFgAB

Password for level 4

Before continuing to the next level, try to view the hidden file using the ls command without any switches. Make sure to save the password you retrieved and exit out of the shell session.