Hello and welcome back to this video.
So in this lesson, we are going to learn about how to use search and do pattern matching.
All right.
So let's quickly begin.
So as you can see on the terminal, I'm into the directory, which is up for net.
And you can see I have listed to see what is inside it.
Now let me quickly go into the directory which is Rohit, and you can see there is a file called as
hacked text.
Now what I'm going to do currently is I'm going to add some data or content into this file.
So I'm going to add random things just to show you how to do pattern matching or how to extract a specific
pattern out of this file.
So let me just add some more random data and let's say hack hacking hacks, hacker apple.com, Microsoft
dot com, etc., etc..
Once I have completed adding random votes into this, I'm going to do a pattern match and identify for
a specific keyword.
Now this is a very, very handy and helpful in terms of identifying a specific keyword into files.
For that, I'm going to use the command, which is cat hacked text through which we are basically reading
the file and then I'm going to use grep hack.
Now by doing this, you can see the output over here.
It has grabbed those words which contains the pattern hack as you can see.
Hacking D Hack Hacking Hacks.
Hacker Hacks Hacks.
I hope you guys understood how to use grab to identify a pattern into a file.
All right.
Now let's move ahead.
GREP is also useful to identify patents not only into files but into directories as well.
So let's quickly see that how you can search recursively for a pattern in a directory using the command
grep.
For that, you can simply type in grep hyphen R and the pattern.
So let's say hack and the directory name.
So let's say the directory is root you have for net and hit enter and you can see it has matched the
pattern hack into the whole directory in all the files that exist as you can see root here for net build
file.
So these are all the configuration files which contains the keyword hack.
As you can see, it is matching into this JavaScript file, etc., etc..
Now this is again very helpful in case you want to identify a specific keyword related pattern into
a directory where there are multiple files and you can just identify that sensitive content, for instance.
Now let us move ahead.
Now we are going to find files and directories by their names.
For that we are going to use the command which is locate.
So there's a file called a super hack which is created into the user share Metasploit framework.
And I'm going to locate that file.
As you can see, the command is very simple locate and the file name that you want or the directory
name that you want and it is able to successfully located.
This is again pretty simple but very, very handy.
Let's move ahead now.
Now we are going to find files in the directory that starts with a prefix.
So this time let's identify or find a file into the root directory into the U.F.O. net, which is inside
the root directory.
And let's specify the name.
So the name of the file that we created was hack dot txt.
So we do not get anything on hack because there is no such file.
But when we change the name to hack dot txt, we are able to identify that.
Yes, hacked txt exist in this part.
So now remember whenever you are playing TFS at that time you always try to find the flags.
So this can be helpful.
This command find will automatically find the flag files into any of the directory which will make your
work much more easier.
So these are small hacks that are very, very helpful and these tricks make your work much more faster.
Let's move ahead.
So now let's say you want to find the files which are larger than 100 MB B, for instance, into a specific
directory.
So for that also you can use the command, find the directory name where you want to identify the file
which is greater than the size 100 MB.
B So you can specify find slash root hyphen size plus 100 MB.
B And these are the files which are greater than 100 MB.
B As you can see, these are some of the word lists which I have created to brute force on various websites.
So I hope you guys understood how you can do pattern matching as well as search.
Thank you.