WEBVTT - This file was automatically generated by VIMEO

0
00:00:13.500 --> 00:00:16.300
Hello and welcome back

1
00:00:16.300 --> 00:00:17.000
 to this video.

2
00:00:17.900 --> 00:00:20.600
So in this lesson, we are going to learn about how

3
00:00:20.600 --> 00:00:24.000
 to use search and do pattern matching.

4
00:00:23.500 --> 00:00:26.900
 Alright, so let's quickly begin.

5
00:00:27.800 --> 00:00:30.400
So as you can see on the terminal I'm into

6
00:00:30.400 --> 00:00:33.500
 the directory, which is UFO net and you

7
00:00:33.500 --> 00:00:36.400
 can see I have listed to see what is

8
00:00:36.400 --> 00:00:39.500
 inside it. Now. Let me quickly go

9
00:00:39.500 --> 00:00:42.400
 into the directory, which is Rohit and you can see there

10
00:00:42.400 --> 00:00:45.400
 is a file called as hack dot txt.

11
00:00:45.400 --> 00:00:48.400
 Now. What I'm going to do currently is

12
00:00:48.400 --> 00:00:51.500
 I'm going to add some data or

13
00:00:51.500 --> 00:00:54.900
 content into this file. So I'm going to add random

14
00:00:54.900 --> 00:00:57.100
 things just to show you

15
00:00:57.100 --> 00:01:00.300
 how to do pattern matching or how to

16
00:01:00.300 --> 00:01:03.500
 extract a specific pattern out of

17
00:01:03.500 --> 00:01:06.500
 this file. So, let me just add some

18
00:01:06.500 --> 00:01:07.700
 more random data.

19
00:01:09.200 --> 00:01:14.000
And let's say hack hacking hacks hacker apple.com microsoft.com,

20
00:01:13.600 --> 00:01:15.700
 etc, etc.

21
00:01:16.400 --> 00:01:19.500
Once I have completed adding random

22
00:01:19.500 --> 00:01:23.000
 words into this I'm going to do a pattern match and

23
00:01:22.400 --> 00:01:26.100
 identify for a specific keyword. Now.

24
00:01:25.100 --> 00:01:28.900
 This is a very very handy and helpful

25
00:01:28.900 --> 00:01:31.400
 in terms of identifying a specific

26
00:01:31.400 --> 00:01:34.200
 keyword into files.

27
00:01:35.100 --> 00:01:39.500
For that I'm going to use the command which is cat hack.txt through

28
00:01:38.500 --> 00:01:41.300
 which we are basically reading the

29
00:01:41.300 --> 00:01:44.500
 file and then I'm going to use grep.

30
00:01:45.400 --> 00:01:48.100
Hack Now by doing this you can

31
00:01:48.100 --> 00:01:49.500
 see the output over here.

32
00:01:50.700 --> 00:01:53.800
It has grabbed those words which

33
00:01:53.800 --> 00:01:56.700
 contains the pattern hack as you

34
00:01:56.700 --> 00:02:00.100
 can see hacking D hack hacking hacks

35
00:01:59.100 --> 00:02:03.000
 hacker hacks hacks. I

36
00:02:02.100 --> 00:02:05.900
 hope you guys understood how to use grab to

37
00:02:05.900 --> 00:02:08.500
 identify a pattern into a

38
00:02:08.500 --> 00:02:09.600
 file. Alright.

39
00:02:11.200 --> 00:02:14.500
Now let's move ahead grip is also

40
00:02:14.500 --> 00:02:17.900
 useful to identify patterns not

41
00:02:17.900 --> 00:02:20.900
 only into files but into directories as

42
00:02:20.900 --> 00:02:23.700
 well. So let's quickly see that how

43
00:02:23.700 --> 00:02:26.400
 you can search recursively for a

44
00:02:26.400 --> 00:02:28.900
 pattern in a directory using the command grip.

45
00:02:29.400 --> 00:02:32.600
For that you can simply type grip hyphen R

46
00:02:32.600 --> 00:02:35.800
 and the pattern so let's say hack and

47
00:02:35.800 --> 00:02:38.400
 the directory name. So let's say the directory is

48
00:02:38.400 --> 00:02:40.900
 root UFO net and hit enter.

49
00:02:41.900 --> 00:02:44.600
And you can see it has matched the

50
00:02:44.600 --> 00:02:47.800
 pattern hack into the whole directory in all

51
00:02:47.800 --> 00:02:50.100
 the files that exist as you can

52
00:02:50.100 --> 00:02:53.200
 see root here for net build file. So these

53
00:02:53.200 --> 00:02:57.200
 are all the configuration files which contains

54
00:02:56.200 --> 00:02:59.600
 the keyword hack as you can see. It is

55
00:02:59.600 --> 00:03:02.300
 matching into this Javascript file, etc. Etc.

56
00:03:02.300 --> 00:03:06.000
 Now this is again very helpful in case you want to identify a

57
00:03:05.300 --> 00:03:08.700
 specific keyword related pattern into

58
00:03:08.700 --> 00:03:12.000
 a directory where there are multiple files and

59
00:03:11.200 --> 00:03:15.000
 you can just identify that sensitive

60
00:03:14.500 --> 00:03:17.900
 content for instance now, let

61
00:03:17.900 --> 00:03:18.600
 us move ahead.

62
00:03:19.600 --> 00:03:22.900
Now we are going to find files and directories by

63
00:03:22.900 --> 00:03:25.300
 their names for that. We are going to use the

64
00:03:25.300 --> 00:03:26.900
 command which is locate.

65
00:03:28.200 --> 00:03:31.600
So there's a file called a super hack which is created into

66
00:03:31.600 --> 00:03:34.400
 the user share metasprite framework

67
00:03:34.400 --> 00:03:37.500
 and I'm going to locate that file as

68
00:03:37.500 --> 00:03:40.700
 you can see the command is very simple locate and

69
00:03:40.700 --> 00:03:43.500
 the file name that you want or the directory name

70
00:03:43.500 --> 00:03:46.800
 that you want and it is able to successfully locate

71
00:03:46.800 --> 00:03:49.500
 it. This is again pretty simple, but

72
00:03:49.500 --> 00:03:50.700
 very very handy.

73
00:03:52.300 --> 00:03:55.100
Let's move ahead. Now. Now we are going

74
00:03:55.100 --> 00:03:58.800
 to find a files in the directory that

75
00:03:58.800 --> 00:04:01.300
 starts with a prefix. So

76
00:04:01.300 --> 00:04:04.900
 this time let's identify or find

77
00:04:04.900 --> 00:04:08.200
 a file into the

78
00:04:07.200 --> 00:04:10.700
 root directory into the UFO

79
00:04:10.700 --> 00:04:13.400
 net which is inside the root directory and let's

80
00:04:13.400 --> 00:04:16.100
 specify the name. So the name of the file that we

81
00:04:16.100 --> 00:04:19.200
 created was hack dot txt. So

82
00:04:19.200 --> 00:04:22.600
 we do not get anything on hack because there is no such

83
00:04:22.600 --> 00:04:25.700
 file but when we change the

84
00:04:25.700 --> 00:04:28.400
 name to hack.txt we're able

85
00:04:28.400 --> 00:04:32.300
 to identify that yes hack.txt exist in

86
00:04:31.300 --> 00:04:34.700
 this path. So now remember whenever

87
00:04:34.700 --> 00:04:37.600
 you're playing ctfs at that time, you always

88
00:04:37.600 --> 00:04:40.600
 try to find the flags. So this can be helpful this

89
00:04:40.600 --> 00:04:43.400
 command find will automatically find

90
00:04:43.400 --> 00:04:46.700
 the flag files into any of the directory which

91
00:04:46.700 --> 00:04:49.900
 will make your work much more easier. These are

92
00:04:49.900 --> 00:04:52.000
 small hacks that are very very helpful.

93
00:04:52.300 --> 00:04:55.200
And these tricks make your work much more

94
00:04:55.200 --> 00:04:55.900
 faster.

95
00:04:57.200 --> 00:05:00.100
Let's move ahead. So now let's say you want to

96
00:05:00.100 --> 00:05:03.500
 find files which are larger than 100 MB for

97
00:05:03.500 --> 00:05:06.300
 instance into a specific directory. So

98
00:05:06.300 --> 00:05:10.000
 for that also, you can use the command find the directory

99
00:05:09.300 --> 00:05:12.600
 name where you want to identify the file,

100
00:05:12.600 --> 00:05:15.500
 which is greater than the size hundred MB.

101
00:05:15.500 --> 00:05:18.800
 So you can specify find slash root

102
00:05:18.800 --> 00:05:21.500
 hyphen size plus 100 MB

103
00:05:21.500 --> 00:05:24.700
 and these are the files which are greater than 100 MB

104
00:05:24.700 --> 00:05:27.200
 as you can see. These are some of the word list, which

105
00:05:27.200 --> 00:05:30.700
 I have created to brute force on various websites.

106
00:05:30.700 --> 00:05:33.500
 So I hope you guys understood how you

107
00:05:33.500 --> 00:05:36.700
 can do pattern matching as well as search. Thank

108
00:05:36.700 --> 00:05:36.800
 you.
