Write-up for OverTheWire:Bandit (Part II/III)

logo

Level 5

The level goal for this level is “The password for the next level is stored in a file somewhere under the inhere directory and has all of the following properties: human-readable, 1033 bytes in size, not executable”

So for answering this challenge a simple use of the “find” command should all I need to use as I can use the command to find files of a specific size and type and etc.

bandit5@melinda:~$ ls -lh
total 4.0K
drwxr-x--- 22 root bandit5 4.0K Jun  6 13:59 inhere
bandit5@melinda:~$ ls -lh inhere/
total 80K
drwxr-x--- 2 root bandit5 4.0K Jun  6 13:59 maybehere00
drwxr-x--- 2 root bandit5 4.0K Jun  6 13:59 maybehere01
drwxr-x--- 2 root bandit5 4.0K Jun  6 13:59 maybehere02
drwxr-x--- 2 root bandit5 4.0K Jun  6 13:59 maybehere03
drwxr-x--- 2 root bandit5 4.0K Jun  6 13:59 maybehere04
drwxr-x--- 2 root bandit5 4.0K Jun  6 13:59 maybehere05
drwxr-x--- 2 root bandit5 4.0K Jun  6 13:59 maybehere06
drwxr-x--- 2 root bandit5 4.0K Jun  6 13:59 maybehere07
drwxr-x--- 2 root bandit5 4.0K Jun  6 13:59 maybehere08
drwxr-x--- 2 root bandit5 4.0K Jun  6 13:59 maybehere09
drwxr-x--- 2 root bandit5 4.0K Jun  6 13:59 maybehere10
drwxr-x--- 2 root bandit5 4.0K Jun  6 13:59 maybehere11
drwxr-x--- 2 root bandit5 4.0K Jun  6 13:59 maybehere12
drwxr-x--- 2 root bandit5 4.0K Jun  6 13:59 maybehere13
drwxr-x--- 2 root bandit5 4.0K Jun  6 13:59 maybehere14
drwxr-x--- 2 root bandit5 4.0K Jun  6 13:59 maybehere15
drwxr-x--- 2 root bandit5 4.0K Jun  6 13:59 maybehere16
drwxr-x--- 2 root bandit5 4.0K Jun  6 13:59 maybehere17
drwxr-x--- 2 root bandit5 4.0K Jun  6 13:59 maybehere18
drwxr-x--- 2 root bandit5 4.0K Jun  6 13:59 maybehere19
bandit5@melinda:~$ find ./* -size 1033c -readable ! -perm /111
./inhere/maybehere07/.file2
bandit5@melinda:~$ cat ./inhere/maybehere07/.file2
********************************

Very simple use of the “find” command in Linux, just looked for a size of 1033 bytes in length and was readable, the output from this was the file seen above, but I wanted to search for all 3 criteria instead of 2 out of the 3, so this meant searching for non-executable. With a quick Google search, I found that the use of “! -perm /111” will find a file not executable by anyone.

Level 6

This level goal builds on the previous level, there is a file somewhere on the server and have the following characteristics:

  1. owned by user bandit7
  2. owned by group bandit6
  3. 33 bytes in size

so using the find command again I went to work.

bandit6@melinda:~$ find / -size 33c -group bandit6 -user bandit7
/var/lib/dpkg/info/bandit7.password
bandit6@melinda:~$ cat /var/lib/dpkg/info/bandit7.password
********************************

Level 7

This level the challenge was to find the password in the file called “data.txt” which was next to the word “millionth”, time to pipe the output from cat of the file into grep searching for “millionth”.

bandit7@melinda:~$ ls -lh
total 4.0M
-rw-r----- 1 bandit8 bandit7 4.0M Jun  6 13:59 data.txt
bandit7@melinda:~$ cat data.txt |grep "millionth"
millionth    ********************************

Level 8

This was an interesting challenge, the goal was to the find the password instead the file “data.txt”, the password line only occurs once in the file. So simply again cat the file and pipe it into the command “sort” and then pipe the output from sort into the command “uniq” with the switch operator “-u” to find the unique string.

bandit8@melinda:~$ ls -lh
total 36K
-rw-r----- 1 bandit9 bandit8 33K Jun  6 13:59 data.txt
bandit8@melinda:~$ cat data.txt |sort |uniq -u
********************************
Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s