Find the password to the next level
- The password for the next level is stored in the file data.txt next to the word millionth
This is easy. In fact I already taught you the skills needed to complete this in the Bandit 6 Walkthrough. We know that the password is in the file data.txt and when we read the file with
cat it looks something like this.
We could just scroll through and look through the word “millionth” but as hackers-in-training we prefer to do things efficiently. So rather than scroll through this entire list we simply have our shell search for us. By reading the file and then piping the output into a grep we are easily given the result.
cat data.txt | grep -i 'millionth' will give you the desired result.
You may be wondering what the
-i is on the end of my grep? Well I urge you to read the man page on it to find out. Here’s a tip for getting through man pages quickly. When you enter the man page if you hit
/ and type in a search string and hit enter your shell will highlight what you’re looking for if it exists. For example if I was looking for what
-i did in the grep man page I would type
n will give you the next result. Hitting return and then q will drop you back into your shell.
We reviewed grep from the previous lesson and used to it discover our answer when piping our read file command into it. We also went over how to search through a man page to help make our searches more efficient. In the next lesson we will dig a little deeper into using more advanced commands to search through strings.