Hey there,
I had so much fun solving bandit levels and blogging about it, so I decided to make it a habit and see if I can solve all the levels till the end of the year. Now, without further ado, we pick up from where we stopped last time.
Bandit Level 5 → 6
Our task is to find the file which is human-readable, 1033 bytes in size and is not executable. I assume, that the command, that will help us today is the find
. So, I’m gonna see what is find for and what other options it has. I found -executable
, which is probably one of the commands I need right now, but I’m still looking for the way to filter by its size and see if it’s human readable. Awesome, there is -size
command and we should pay attention that for bytes we should use c
. I found the directory named “inhere” which contains too many directories. In order to save time and not to check every directory I just stay in “inhere” and do:
find -size 1033c
It shows me the only file that is 1033 bytes: /maybehere07/.file2
, so I cat the file. There is the password!
Bandit Level 6 → 7
This level seems to be harder at the first sight, because it’s the first time I should find a file owned by another user. It’s hard but not possible. Let’s dig in. In order to find a file owned by a user or a group I just type:
find -user bandit7 -group bandit6
and for the size, as we learnt from the previous level, we need -size 33c
. No result. Let’s read the task again. The password is stored somewhere on the server. So we should look for it everywhere.
find / -user bandit7 -group bandit6 -size 33c.
Oh no, it shows all the errors as well. We don’t need them at all, so let’s redirect all of them in /dev/null
.
ind / -user bandit7 -group bandit6 -size 33c 2>/dev/null
Success!! There is the file we were looking for. And it contains the password for the next level.
Bandit Level 7 → 8
The password is in the file named data.txt
next to the word millionth. I guess I should find out how to find a word in a file. Here is the solution. So I just type:
grep millionth data.txt
This was such a child’s play.
Bandit Level 8 → 9
The password for the next level is stored in the file data.txt and is the only line of text that occurs only once. The key word is “occurs only once”, it seems kind of unique, right? What a pleasant coincidence, we have a command called uniq. On the man page of uniq I found this awesome option:
-u, --unique
only print unique lines
I see that sort
command that can be used for the level. What does it stand for? The man page says:
sort - sort lines of text files
Also, the helpful reading material suggests that we should read about piping and redirection. After looking through the material I try this:
cat data.txt | sort | uniq -u
And there is our password. Another, more sufficient way would have been:
sort data.txt | uniq -u
Bandit Level 9 → 10
The password for the next level is stored in the file data.txt in one of the few human-readable strings, preceded by several =
characters. I understand that my task is to find the human-readable string in a file. Here I found the most efficient and maybe the only way:
strings data.txt | grep "= "
Success! The password is on my screen already!
For me these levels were easier than the previous ones. Maybe because I’ve already learnt the art of understanding the problem and reading every possible man or –help page.
I thought it’s supposed to be easier…