1 00:00:01,650 --> 00:00:03,780 Hello and welcome back to this video. 2 00:00:04,080 --> 00:00:10,650 So in this lesson, we are going to learn about how to use search and do pattern matching. 3 00:00:10,770 --> 00:00:11,550 All right. 4 00:00:11,550 --> 00:00:13,620 So let's quickly begin. 5 00:00:14,010 --> 00:00:19,140 So as you can see on the terminal, I'm into the directory, which is up for net. 6 00:00:19,380 --> 00:00:23,910 And you can see I have listed to see what is inside it. 7 00:00:24,120 --> 00:00:30,330 Now let me quickly go into the directory which is Rohit, and you can see there is a file called as 8 00:00:30,330 --> 00:00:32,040 hacked text. 9 00:00:32,280 --> 00:00:39,330 Now what I'm going to do currently is I'm going to add some data or content into this file. 10 00:00:39,330 --> 00:00:48,570 So I'm going to add random things just to show you how to do pattern matching or how to extract a specific 11 00:00:48,570 --> 00:00:50,750 pattern out of this file. 12 00:00:50,760 --> 00:01:00,000 So let me just add some more random data and let's say hack hacking hacks, hacker apple.com, Microsoft 13 00:01:00,000 --> 00:01:02,220 dot com, etc., etc.. 14 00:01:02,610 --> 00:01:10,740 Once I have completed adding random votes into this, I'm going to do a pattern match and identify for 15 00:01:10,740 --> 00:01:12,090 a specific keyword. 16 00:01:12,120 --> 00:01:20,790 Now this is a very, very handy and helpful in terms of identifying a specific keyword into files. 17 00:01:21,210 --> 00:01:27,570 For that, I'm going to use the command, which is cat hacked text through which we are basically reading 18 00:01:27,570 --> 00:01:32,400 the file and then I'm going to use grep hack. 19 00:01:32,550 --> 00:01:36,180 Now by doing this, you can see the output over here. 20 00:01:37,020 --> 00:01:43,170 It has grabbed those words which contains the pattern hack as you can see. 21 00:01:43,200 --> 00:01:46,500 Hacking D Hack Hacking Hacks. 22 00:01:46,500 --> 00:01:48,780 Hacker Hacks Hacks. 23 00:01:49,170 --> 00:01:55,440 I hope you guys understood how to use grab to identify a pattern into a file. 24 00:01:55,470 --> 00:01:56,130 All right. 25 00:01:57,540 --> 00:01:59,250 Now let's move ahead. 26 00:01:59,490 --> 00:02:07,830 GREP is also useful to identify patents not only into files but into directories as well. 27 00:02:08,190 --> 00:02:14,760 So let's quickly see that how you can search recursively for a pattern in a directory using the command 28 00:02:14,760 --> 00:02:15,270 grep. 29 00:02:15,630 --> 00:02:20,220 For that, you can simply type in grep hyphen R and the pattern. 30 00:02:20,220 --> 00:02:23,340 So let's say hack and the directory name. 31 00:02:23,340 --> 00:02:30,990 So let's say the directory is root you have for net and hit enter and you can see it has matched the 32 00:02:30,990 --> 00:02:38,790 pattern hack into the whole directory in all the files that exist as you can see root here for net build 33 00:02:38,790 --> 00:02:39,240 file. 34 00:02:39,240 --> 00:02:44,760 So these are all the configuration files which contains the keyword hack. 35 00:02:44,760 --> 00:02:48,810 As you can see, it is matching into this JavaScript file, etc., etc.. 36 00:02:49,050 --> 00:02:55,290 Now this is again very helpful in case you want to identify a specific keyword related pattern into 37 00:02:55,290 --> 00:03:03,500 a directory where there are multiple files and you can just identify that sensitive content, for instance. 38 00:03:03,510 --> 00:03:05,250 Now let us move ahead. 39 00:03:05,820 --> 00:03:10,380 Now we are going to find files and directories by their names. 40 00:03:10,380 --> 00:03:13,410 For that we are going to use the command which is locate. 41 00:03:14,250 --> 00:03:21,030 So there's a file called a super hack which is created into the user share Metasploit framework. 42 00:03:21,210 --> 00:03:23,640 And I'm going to locate that file. 43 00:03:23,670 --> 00:03:29,550 As you can see, the command is very simple locate and the file name that you want or the directory 44 00:03:29,550 --> 00:03:33,630 name that you want and it is able to successfully located. 45 00:03:33,810 --> 00:03:37,380 This is again pretty simple but very, very handy. 46 00:03:38,650 --> 00:03:40,090 Let's move ahead now. 47 00:03:40,210 --> 00:03:47,410 Now we are going to find files in the directory that starts with a prefix. 48 00:03:47,410 --> 00:03:57,940 So this time let's identify or find a file into the root directory into the U.F.O. net, which is inside 49 00:03:57,940 --> 00:03:58,930 the root directory. 50 00:03:58,990 --> 00:04:01,060 And let's specify the name. 51 00:04:01,060 --> 00:04:05,350 So the name of the file that we created was hack dot txt. 52 00:04:05,350 --> 00:04:09,670 So we do not get anything on hack because there is no such file. 53 00:04:09,670 --> 00:04:15,940 But when we change the name to hack dot txt, we are able to identify that. 54 00:04:15,940 --> 00:04:19,720 Yes, hacked txt exist in this part. 55 00:04:19,720 --> 00:04:25,600 So now remember whenever you are playing TFS at that time you always try to find the flags. 56 00:04:25,600 --> 00:04:26,770 So this can be helpful. 57 00:04:26,770 --> 00:04:33,790 This command find will automatically find the flag files into any of the directory which will make your 58 00:04:33,790 --> 00:04:35,380 work much more easier. 59 00:04:35,530 --> 00:04:42,580 So these are small hacks that are very, very helpful and these tricks make your work much more faster. 60 00:04:43,620 --> 00:04:44,640 Let's move ahead. 61 00:04:44,670 --> 00:04:51,780 So now let's say you want to find the files which are larger than 100 MB B, for instance, into a specific 62 00:04:51,780 --> 00:04:52,400 directory. 63 00:04:52,410 --> 00:04:59,250 So for that also you can use the command, find the directory name where you want to identify the file 64 00:04:59,250 --> 00:05:01,620 which is greater than the size 100 MB. 65 00:05:01,620 --> 00:05:07,650 B So you can specify find slash root hyphen size plus 100 MB. 66 00:05:07,650 --> 00:05:10,710 B And these are the files which are greater than 100 MB. 67 00:05:10,710 --> 00:05:17,250 B As you can see, these are some of the word lists which I have created to brute force on various websites. 68 00:05:17,250 --> 00:05:22,760 So I hope you guys understood how you can do pattern matching as well as search. 69 00:05:22,770 --> 00:05:23,580 Thank you.