Bandit levels 6 – 9 [overthewire.org]

Level 6 – 7

The password for the next level is stored somewhere on the server and has all of the following attributes:

  • owned by user bandit7
  • owned by group bandit6
  • 33 bytes in size

We already looked for a file of a certain size in the previous level, to do that we can use command find with size option and suffix c to look for size in bytes:

find -size 33c

Next we can narrow our search to files owned by user bandit7. To do that we can one more time use command find, with option –user

find -user bandit7

We will use the same command with option -group to find files owned by group bandit6

find -group bandit6

Finally, using all 3 options together:

find -group bandit6 -user bandit7 -size 33c

As a result we will get a list of all files matching our criteria

To remove error messages (permission denied), we can add a following line at the end of find command:

2>dev/null

Now we just have to access this file and retrieve the password needed to access level 7

Level 7-8

In this level we will have to open a text file and find a password that is located next to word “millionth”. To do that we can use grep (a command-line utility for searching plain-text data sets for lines that match a regular expression).

To search for a string in a particular file (data.txt in this instance) we can use a combination of cat with grep:

cat data.txt | grep "millionth"

the command will return only one line of text, which includes our password to level 8 (right after string “millionth”)

Level 8-9

In this level we again have to access text file data.txt, however this time we are looking for a string that occurs only once in the file.

We can use command sort to sort strings in the file and command uniq with option -u to print only unique lines

sort data.txt | uniq -u

Author: Lukasz Milek