Bandit level 8 is fairly simple, it teaches you how to check for text that is unique in a document.
Let’s start By Logging into the bandit level 8 machine:
ssh email@example.com -p 2220
and with using the password that we got from the previous level
let’s start by listing all the files that are in the current directory.
drwxr-xr-x 2 root root 4096 May 7 2020 . drwxr-xr-x 41 root root 4096 May 7 2020 .. -rw-r--r-- 1 root root 220 May 15 2017 .bash_logout -rw-r--r-- 1 root root 3526 May 15 2017 .bashrc -rw-r----- 1 bandit9 bandit8 33033 May 7 2020 data.txt -rw-r--r-- 1 root root 675 May 15 2017 .profile
so we know the unique line is in data.txt, so let’s start first by printing the data just to get an idea of what kind of data we have.
VkBAEWyIibVkeURZV5mowiGg6i3m7Be0 zdd2ctVveROGeiS2WE3TeLZMeL5jL7iM sYSokIATVvFUKU4sAHTtMarfjlZWWj5i ySvsTwlMgnUF0n86Fgmn2TNjkSOlrV72 NLWvtQvL7EaqBNx2x4eznRlQONULlCYZ LfrBHfAh0pP9bgGAZP4QrVkut3pysAYC U0NYdD3wHZKpfEg9qGQOLJimAJy6qxhS flyKxCbHB8uLTaIB5LXqQNuJj3yj00eh TThRArdF2ZEXMO47TIYkyPPLtvzzLcDf cIPbot7oYveUPNxDMhv1hiri50CqpkTG .........
We can see a list of strings where one of them only is unique.
We can use “uniq” command that searches for strings or values that are repeated only once, but first we need to sort the data alphabetically because “uniq” compares with the next value only. For example:
uniq can determine that letter “A” is unique in the following:
A A B
but it won’t detect that “A” is unique in the following example:
A B A
so, let’s do our piping command, where we need to sort the values first then pass it to uniq in order to get our unique value.
cat data.txt | sort | uniq --unique
Let’s Explain what happened here:
- cat command to display the content of the file
- sort to sort the value and prepare it for uniq
- uniq command with “-u” or “–unique” flag to print only unique lines
and you will get the password for the next level.