Friday, December 5, 2014

Bandit Level 8 to Level 9

Find string of text in a text file that is the only line that does not have a duplicate line.

Host name is bandit.labs.overthewire.org 
User: bandit8
password: cvX2JJa4CFALtqS87jk27qwqGhBM9plV

Commands used for this level:
ls - List information about the FILE's (the current directory by default).
sort - sort lines of text files print to stdout
uniq - report or omit repeated lines

Step 1.
After logging in type ls
You will see a file data.txt

Step 2.
In that data.txt file we need to find the one line that does not repeat, that line will be our password for the next level.
You could start with a cat of the file and find that the file is huge, it would take forever to search to find the one non-repeating line with out a tool. Let's figure out what command we could use to sort the data and find this line. Lets look at the man page for sort. We see that sort will sort the text for us in order. Let's do a sort on data.txt.
2a. Type sort data.txt
We see that sort has sorted all the text in our data.txt file and we see that we do have many repeating lines of data. We need to somehow find the one non-repeating line still. If we go back to the man page on sort and scroll to the bottom we see that it says to SEE ALSO uniq. Let's do a man uniq. We see that uniq is used to filter adjacent matching lines from INPUT. We also see that when uniq is used with -u option it will print only unique lines of text. Lets sort the data.txt file and pipe into uniq.
2b. Type sort data.txt | uniq -u and our password for level 9 is displayed.
 UsvVyFSfZZWbi6wgC7dAFyFuR6jQQUhR

2 comments:

  1. This isnt working for me, ive even copied and pasted sort data.txt | uniq -u nut still receiving a massive wall of text

    ReplyDelete
    Replies
    1. Apologies! I was attempting to use this to access level 8!

      Delete