BanditOverTheWire Level 5 Walkthough
Outline
I’ve been fascinated with the info-security/cybersecurity world lately. A friend of mine told me to start with BanditOverTheWire. BanditOverTheWire serves as an introduction to advanced terminal commands that allows a players to find the ‘flag’ in each level. Each flag serves as a password to get to the next level. At the time of writing this, I am on level 15.
I’d like to do a walkthrough of one of my favorite levels so far, level 5.
To follow along simply run this command in your terminal:
ssh bandit5@bandit.labs.overthewire.org -p2220
enter this password:
koReBOKuIDDepwhWk7jZC0RTdopnAYKh
Concept
In level 5, the goal is to find the password that is stored in a nested directory in the inhere
directory that is:
- human-readable
- 1033 bytes in size
- not executable
When we first cd
into inhere
and type in ls
, we see that there are multiple directories that the password could be hidden in.
Upon using the command cd maybehere00
to go inside the mayberhere00
directory, we see that there are many files inside the directory.
Oh no! What do we do? Each directory has many files of their own as well. There’s simply too many files for any sane person to check. We have to get the password somehow.
Luckily, we have a set of commands that the level advised us to take a closer look at.
We can type in the command line man
following the command to open the manual and access the full description of what the command does. For now, here’s the TLDR:
ls
- displays whats in a directorycd
- jumps into a directorycat
- prints whats in a readable-filefile
- determines file typedu
- estimates file space usagefind
- searches for files in a directory hierarchy
If we look closely at the manual for find
we can see that there is a -type
predicate that can be used after find
to filter for a specific type of file.
Since we want to find something that is human-readable and regular, we will use -type f
.
if we use find ./ -type f
we still end up with a lot of files.
Let’s add to our command to see if we can narrow it down some more.
Next, we want to filter for 1033 bytes size and non-executable file.
Going back to the find
manual, we find other predicates that could be useful to use.
-size
and -executable
(make sure to add !
in front of -executable
because we are looking for a non-executable file!)
Thus, we combine all 3 predicates to make
find ./ -type f -size 1033c ! -executable
We simply cat ./maybehere07/.file2
from here to find the password for level 9.
We’ve successfully captured the flag DXjZPULLxYr17uwoI01bNLQbtFemEgo7