This is a walkthrough to the bandit wargame made by OverTheWire. It can be found on their website at https://overthewire.org/wargames/bandit
Given Info: 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 data.txt file in this level contains many lines of possible passwords, and every one is repeated at least one time except for the correct password.
For this level we can use a tool called uniq. The ‘-u’ argument causes it to search for unique lines. We can use this to find the only unique line in data.txt.
The first thing you have to know is that uniq only looks at adjacent lines. What this means is that when looking to see if a line has duplicates, it only checks the line immediately above and the line immediately below it. We want to make sure that even if there is a repeated line anywhere, it will catch it, and to do this we have to sort the file. Using the ‘sort’ command on a file without any arguments causes the command to sort the file by line. This means that lines that are similar will end up next to each other, and then the ‘uniq’ command will work properly. So to do this we can once again use a pipe to direct the output to the next command. The final command is ‘sort data.txt | uniq -u’ .
Put this in your passwords file, and don’t forget to save!
This wargame can be found on https://overthewire.org/wargames/bandit
Check them out for more wargames and the rest of the levels.