1
00:00:00,760 --> 00:00:02,160
Welcome back everybody.

2
00:00:02,170 --> 00:00:08,880
Let's see now how we can actually call our port scanner class into our vulnerability scanner program.

3
00:00:08,890 --> 00:00:12,120
All right so we have everything ready right here.

4
00:00:12,130 --> 00:00:14,440
We switched everything that we needed to.

5
00:00:14,560 --> 00:00:19,450
We also added some of the lists some of the specific attributes to this class.

6
00:00:19,450 --> 00:00:24,880
We changed some of the functions as well as deleted the get better method from this class.

7
00:00:25,090 --> 00:00:29,830
And we also added the conversion of IP address into this can port method.

8
00:00:29,830 --> 00:00:30,810
All right.

9
00:00:30,940 --> 00:00:36,490
So now what we need to do is we need to see how we can create an object that belong to this class and

10
00:00:36,490 --> 00:00:41,590
how we can use it inside of operable ability cannot program well right away.

11
00:00:41,590 --> 00:00:46,720
I can tell you that this will not work because with this we are simply specifying the name of the file

12
00:00:46,810 --> 00:00:54,100
that we import it and then the function but this function no longer exists as a separate function inside

13
00:00:54,100 --> 00:00:55,350
of the port scanner.

14
00:00:55,450 --> 00:01:00,760
That function is now the actual method to the port scan class.

15
00:01:00,760 --> 00:01:05,620
So in order to actually call that we first of all need to create an object that will belong to that

16
00:01:05,620 --> 00:01:09,670
class and we can simply call that object target.

17
00:01:09,670 --> 00:01:12,380
So simple as that target will be able object.

18
00:01:12,490 --> 00:01:17,770
And in order to initiate that object to belong to the port scan class we first of all need to specify

19
00:01:17,770 --> 00:01:21,120
the port Canada which is the file that we are using the class from.

20
00:01:21,250 --> 00:01:24,430
And then the name of the class itself.

21
00:01:24,430 --> 00:01:30,850
Now you will notice that if we specify the open closed brackets pie chart will suggest right away that

22
00:01:30,850 --> 00:01:35,290
this port can class takes two parameters.

23
00:01:35,290 --> 00:01:41,530
The first parameter will be the target's IP address and the number of ports that we want to scan for

24
00:01:41,530 --> 00:01:43,360
the vulnerable software.

25
00:01:43,360 --> 00:01:45,840
Now why does it say these two parameters.

26
00:01:45,850 --> 00:01:50,980
Well inside of our port scanner class you will notice that we have two variables inside of our in it

27
00:01:51,360 --> 00:01:51,970
method.

28
00:01:52,090 --> 00:01:56,350
And these two variables are exactly what we need to specify to our object.

29
00:01:56,380 --> 00:02:00,310
So we need to know the target's IP address as well as the number of ports.

30
00:02:00,310 --> 00:02:04,510
So let's specify that we already prompted to the user for these two values.

31
00:02:04,510 --> 00:02:10,760
Therefore we can simply just specify right here targets IP and then comma port number.

32
00:02:11,130 --> 00:02:12,060
All right.

33
00:02:12,190 --> 00:02:18,340
And we successfully created the object to our ports can class right now in order to initiate the scan

34
00:02:18,340 --> 00:02:23,070
itself so we can scan for the open ports and retrieve the banners to those open ports.

35
00:02:23,170 --> 00:02:26,380
We need to initiate the method from this class.

36
00:02:26,470 --> 00:02:27,610
And how do we do that.

37
00:02:27,730 --> 00:02:33,430
We need to initiate the method onto our object from the port scanner class.

38
00:02:33,430 --> 00:02:34,480
So how can we do that.

39
00:02:34,570 --> 00:02:37,700
But first of all we need to check which method we need to initiate.

40
00:02:37,870 --> 00:02:43,220
And ideally we want to initiate one method which will call all of the other methods as well.

41
00:02:43,570 --> 00:02:50,950
And in our case that method would be this can function as it can method calls this can port method and

42
00:02:50,950 --> 00:02:56,920
this can port method calls the check IP method as well as checks for the banners and adds them to the

43
00:02:56,920 --> 00:02:58,100
list.

44
00:02:58,150 --> 00:02:59,630
So we need to type right here.

45
00:02:59,650 --> 00:03:09,490
Target dot scan and simply with just these two lines we performed in Paris scan for open ports and softwares

46
00:03:09,580 --> 00:03:12,210
on our targets IP address.

47
00:03:12,340 --> 00:03:18,190
All we're left to do right now is compare those banners that we retrieved from the open ports with the

48
00:03:18,190 --> 00:03:22,720
banners that we will have in a separate file that we're just going that we're going to create in just

49
00:03:22,720 --> 00:03:23,590
a second.

50
00:03:23,680 --> 00:03:29,490
And if we find a match that means that we found a vulnerable software.

51
00:03:29,500 --> 00:03:29,940
All right.

52
00:03:29,950 --> 00:03:36,700
So first of all we need to perform something and that will be scanning a target and then we're going

53
00:03:36,700 --> 00:03:40,930
to add two or three banners to the actual text file which then we are going to use.

54
00:03:41,620 --> 00:03:46,630
Well let me just show you it is easier if I just show you first of all I will enlarge this zoom this

55
00:03:46,630 --> 00:03:52,870
in and I will navigate to our pie chart projects as well as the port scanner project.

56
00:03:52,870 --> 00:04:01,330
And here if I simply just bite on the port scanner P Y and let's say we test this Web site test BHP

57
00:04:01,330 --> 00:04:04,990
dot one word dot com press your enter.

58
00:04:04,990 --> 00:04:09,150
It will scan for the open ports and we will retrieve some banners from it.

59
00:04:09,280 --> 00:04:14,770
Then we're going to copy these banners and add them into at the extend file which then we will use inside

60
00:04:14,770 --> 00:04:16,240
of this program.

61
00:04:16,270 --> 00:04:19,180
So let's say we want to copy first two banners.

62
00:04:19,240 --> 00:04:24,160
All right we're just going to wait for a few seconds for this can finish.

63
00:04:24,160 --> 00:04:29,770
And keep in mind we are using the port scanner tool that we created so you can see it can be sometimes

64
00:04:29,770 --> 00:04:34,990
useful especially when you try to gather more information about the target's machine.

65
00:04:35,560 --> 00:04:35,880
All right.

66
00:04:35,890 --> 00:04:36,610
So here it is.

67
00:04:36,610 --> 00:04:37,480
It has finished.

68
00:04:37,480 --> 00:04:42,130
Now let's copy this we don't need that IP address.

69
00:04:42,130 --> 00:04:48,070
We're going to copy this then right here a hundred volts candidate we're going to click on new.

70
00:04:48,280 --> 00:04:52,000
But instead of new python file we're simply just want to create new file.

71
00:04:52,000 --> 00:04:59,730
It will be called let's say Val underscore file or no let's not call it like the actual variable hold

72
00:04:59,770 --> 00:05:03,150
banners dot the extreme let's call it just like that.

73
00:05:03,160 --> 00:05:09,400
And then right here we're going to paste this as a first banner and as the second banner we're going

74
00:05:09,400 --> 00:05:16,960
to paste let's say this copy selection and paste it right here.

75
00:05:16,990 --> 00:05:17,440
All right.

76
00:05:17,470 --> 00:05:19,000
So here it is.

77
00:05:19,130 --> 00:05:26,590
We got two banners ready and now let's see if we manage to find these two matches with our portability

78
00:05:26,600 --> 00:05:27,550
scanner.

79
00:05:27,550 --> 00:05:27,860
OK.

80
00:05:27,950 --> 00:05:34,400
So first of all what we need to do in order to compare the banners with the banners from the file we

81
00:05:34,400 --> 00:05:37,970
need to open that file first so how can we do that file in Python.

82
00:05:37,970 --> 00:05:40,110
We do it with this statement.

83
00:05:40,160 --> 00:05:48,260
So with open and then open and close brackets and first parameter to this open function would be the

84
00:05:48,260 --> 00:05:51,860
file name which is stored inside of this will file variable.

85
00:05:52,370 --> 00:05:59,820
So with open Val underscore file and the second parameter would be how you want to actually open it

86
00:05:59,830 --> 00:06:03,830
in our case we want to open that file for reading so we want to read from it.

87
00:06:03,910 --> 00:06:05,710
You also have the right and append option.

88
00:06:05,710 --> 00:06:11,160
But in this case we're going to open the file for reading which we specified just by simply typing smaller

89
00:06:11,170 --> 00:06:15,850
case are and then we specify as.

90
00:06:15,850 --> 00:06:18,450
And then the name of the file object as file.

91
00:06:18,640 --> 00:06:19,480
Let's call it like that.

92
00:06:19,480 --> 00:06:27,100
So with open vulnerability file for reading as file then we need to perform the comparison of these

93
00:06:27,190 --> 00:06:28,030
banners.

94
00:06:28,090 --> 00:06:34,060
What we're going to do first is we're going to add a count variable which will be equal to zero and

95
00:06:34,060 --> 00:06:39,000
then we're going to take a look at all of the banners that we gathered during our scan.

96
00:06:39,010 --> 00:06:39,430
All right.

97
00:06:39,430 --> 00:06:47,350
So how can we do that we can access those benders by simply typing target that planners how can we do

98
00:06:47,350 --> 00:06:47,900
that.

99
00:06:47,920 --> 00:06:54,940
Well since we created this object right here this object besides these two variables also has these

100
00:06:55,090 --> 00:06:58,720
two variables right here or these two lists three they say.

101
00:06:58,780 --> 00:07:03,170
So we can also access them as well if we want to using our object.

102
00:07:03,340 --> 00:07:08,520
So Target banners and what we want to do with that is we want to iterate over it.

103
00:07:08,530 --> 00:07:17,680
So full banner in target banners but first of all want to navigate to the beginning of our bold banner

104
00:07:17,690 --> 00:07:21,820
stop the steep fall and we can do that using filed or seek zero.

105
00:07:22,630 --> 00:07:29,590
And the reason why we need this line is because in case we remove this it will only find the first result

106
00:07:29,650 --> 00:07:35,080
and it will not manage to find the second result because it will take the first banner then it will

107
00:07:35,140 --> 00:07:41,260
iterate over all of the banners inside of this list and if it finds it it will be stuck at the end of

108
00:07:41,260 --> 00:07:46,690
the actual file and it will not get back to read it from the beginning for the next banner.

109
00:07:46,690 --> 00:07:48,580
It will just read it from where it stopped.

110
00:07:48,580 --> 00:07:54,190
That's why after every banner of We need to actually seek to the beginning of this file which we do

111
00:07:54,190 --> 00:08:01,430
using file that seek 0 0 means simply return to the beginning and read all over again.

112
00:08:01,950 --> 00:08:03,900
And now we need to iterate once again.

113
00:08:03,910 --> 00:08:13,280
So for line in file dot read lines and you will notice that we actually have two functions right here.

114
00:08:13,290 --> 00:08:16,500
One is read line and one is read lines.

115
00:08:16,500 --> 00:08:20,910
If you read line it will only read one characters one by one.

116
00:08:20,910 --> 00:08:25,740
So we don't read the one that we want to use read lines so it actually leads line by line.

117
00:08:25,740 --> 00:08:30,750
So let's just type it right here for the line in file that read lines.

118
00:08:30,750 --> 00:08:38,300
And since this is a function we need to open close brackets and now we can compare debentures if lined

119
00:08:38,300 --> 00:08:39,280
up strip.

120
00:08:39,290 --> 00:08:43,850
We want to strip it from anything that might cause some problems in matching these two banners.

121
00:08:43,850 --> 00:08:48,460
And keep in mind that this line is simply just a line from the the excel file.

122
00:08:48,460 --> 00:08:55,320
For example it can be this and then we need to compare that with t banners from this list right here.

123
00:08:55,820 --> 00:09:03,830
So if line that strip in banner in banner that we are currently reading from this list.

124
00:09:03,830 --> 00:09:05,980
So a final strip in better.

125
00:09:06,380 --> 00:09:10,300
And then here we want to print with print like this.

126
00:09:11,020 --> 00:09:18,890
So open single quote two exclamation marks and let's print the capital letters for example our vulnerable

127
00:09:20,930 --> 00:09:30,140
Banner and then let's also double quotes to our actual string so we can add it between the banner plus

128
00:09:30,140 --> 00:09:38,760
the banner itself plus and then single quotes double quote at the beginning and then on port and let's

129
00:09:38,760 --> 00:09:40,080
print it inflate this

130
00:09:43,450 --> 00:09:51,490
plus string and here want to actually print the port number corresponding to that specific banner.

131
00:09:51,640 --> 00:09:53,350
So how can we do that.

132
00:09:53,410 --> 00:09:58,990
Well that is why we need this count variable since discount variable will keep track of each element

133
00:09:58,990 --> 00:10:01,970
that we'd pass by by scanning each and every banner.

134
00:10:02,080 --> 00:10:09,240
So each and every banner will correspond to the exact same number of elements inside of this open ports

135
00:10:09,250 --> 00:10:10,120
list right here.

136
00:10:10,270 --> 00:10:13,780
So for example if the count variable came to number three.

137
00:10:14,020 --> 00:10:20,320
That means we are scanning third banner and that third banner will be correspondent to The third element

138
00:10:20,410 --> 00:10:26,380
of the open ports list which will be the actual port number to that specific banner.

139
00:10:26,410 --> 00:10:34,390
So in order to access that list we need to type the target object dot open ports we can access it the

140
00:10:34,390 --> 00:10:36,190
same way that we access the banners.

141
00:10:36,220 --> 00:10:37,820
So that open ports.

142
00:10:38,020 --> 00:10:42,850
And here we need to specify which element we're looking for and we specify that in the square brackets

143
00:10:42,850 --> 00:10:43,420
right here.

144
00:10:44,140 --> 00:10:50,820
So then we add right here count so simple as that.

145
00:10:50,960 --> 00:10:59,560
For some reason we are getting these red lines in for example line dots strip port scanner the ports

146
00:10:59,560 --> 00:11:00,160
can.

147
00:11:01,740 --> 00:11:02,900
And why is that

148
00:11:05,480 --> 00:11:11,590
religious finish this so we don't forget the last line which will be to actually increase the count

149
00:11:11,590 --> 00:11:12,970
variable by one.

150
00:11:12,970 --> 00:11:14,100
And you need to keep in mind.

151
00:11:14,110 --> 00:11:15,760
Where are you actually increasing it.

152
00:11:15,760 --> 00:11:16,990
Inside of which low.

153
00:11:17,020 --> 00:11:19,000
Well they want to increase it inside of this loop.

154
00:11:19,030 --> 00:11:22,250
But you don't want to increase it inside of this loop.

155
00:11:22,450 --> 00:11:27,970
So you want to increase it after you pass every banner you increase the element by one because you proceed

156
00:11:28,000 --> 00:11:29,470
to the next panel in less.

157
00:11:29,470 --> 00:11:31,650
Therefore we want to increase it right here.

158
00:11:31,750 --> 00:11:34,770
So count plus equals 1

159
00:11:38,510 --> 00:11:38,870
Okay.

160
00:11:38,880 --> 00:11:41,710
So everything seems to be working correctly.

161
00:11:41,750 --> 00:11:44,960
We just seem to have bunch of errors right here.

162
00:11:44,960 --> 00:11:51,530
But let's try to run the program so we can see what type of errors or those so we'll scan that P Y.

163
00:11:52,250 --> 00:11:56,010
And it says right here invalid syntax.

164
00:11:56,780 --> 00:12:01,090
Let's see where that is invalid syntax inside of the profile.

165
00:12:02,000 --> 00:12:05,930
Okay so we have a bracket extra so let's delete this.

166
00:12:05,930 --> 00:12:07,250
Try it once again.

167
00:12:09,530 --> 00:12:13,640
Oh no we actually do not have a bracket extra.

168
00:12:13,710 --> 00:12:16,010
We're not even fixing the correct part.

169
00:12:16,020 --> 00:12:18,150
It is inside of this full file.

170
00:12:18,150 --> 00:12:18,330
Yeah.

171
00:12:18,330 --> 00:12:21,840
We have an extra square bracket right here so let's delete that.

172
00:12:21,840 --> 00:12:26,960
And if I run it once again I know we can notice that we no longer have any errors.

173
00:12:26,970 --> 00:12:32,760
So this extra bracket right here created as the problem throughout the entire program so now that we

174
00:12:32,760 --> 00:12:33,290
fixed it.

175
00:12:33,300 --> 00:12:34,790
This should work.

176
00:12:34,820 --> 00:12:37,230
Enter target to scan for vulnerable open ports.

177
00:12:37,230 --> 00:12:43,750
Let's type test BHP dot one word dot com.

178
00:12:43,860 --> 00:12:49,710
We want to scan for first 100 ports because both of the vulnerable softwares are located inside of the

179
00:12:49,710 --> 00:12:55,140
first 100 ports and we want to enter the path to the file with formidable software as well in our case

180
00:12:55,140 --> 00:12:59,100
since the actual file is inside the same directories our program.

181
00:12:59,100 --> 00:13:00,590
We don't need to specify the path.

182
00:13:00,600 --> 00:13:02,700
We can simply just passive file the file name.

183
00:13:02,700 --> 00:13:07,620
But if this file was in another directory you would need to specify the full path to that directory

184
00:13:08,610 --> 00:13:16,390
in our case well banners dot the extreme press your enter and now we wait for it to perform the scan

185
00:13:16,390 --> 00:13:22,630
first of the first 100 ports then it will go to this iteration right here with the opening of the file

186
00:13:22,630 --> 00:13:23,910
and then comparing the banners.

187
00:13:23,980 --> 00:13:30,460
And if it manages to find the banner that matches in both of the banners list and the actual file that

188
00:13:30,460 --> 00:13:35,310
we open then it will print that of vulnerable software has been found.

189
00:13:35,320 --> 00:13:35,810
All right.

190
00:13:35,830 --> 00:13:37,100
So let's see right here.

191
00:13:37,150 --> 00:13:44,160
It might take a few seconds to finish and here it is we found two vulnerable banners as it prints right

192
00:13:44,160 --> 00:13:44,850
here.

193
00:13:44,850 --> 00:13:53,130
Vulnerable banner with this name right here on Port 21 and vulnerable banner with this name on port

194
00:13:53,150 --> 00:13:54,620
twenty two.

195
00:13:54,620 --> 00:13:55,090
All right.

196
00:13:55,110 --> 00:13:56,160
So good.

197
00:13:56,160 --> 00:14:02,220
We managed to find a vulnerable banners and now we can simply just proceed to exploit the target with

198
00:14:02,250 --> 00:14:05,340
these two vulnerabilities.

199
00:14:05,340 --> 00:14:05,870
All right.

200
00:14:05,880 --> 00:14:10,200
So that would be about it for this vulnerability scanner as you can see it is not really that big of

201
00:14:10,200 --> 00:14:11,390
a project.

202
00:14:11,400 --> 00:14:13,630
It is mostly based on our ports candidate.

203
00:14:13,680 --> 00:14:21,360
We simply just compare the actual banners from the file and the scan itself and then we print it out.

204
00:14:21,390 --> 00:14:21,780
All right.

205
00:14:21,800 --> 00:14:27,510
So once again this is something that you can download from the Internet or you can simply just create

206
00:14:27,630 --> 00:14:32,940
it by yourself just by adding multiple vulnerable banners to this list and then creating your own list

207
00:14:34,310 --> 00:14:41,040
and then you can use this program in order to scan the target in the next video we're going to perform

208
00:14:41,040 --> 00:14:43,570
the recap of the sexual project.

209
00:14:43,710 --> 00:14:46,260
We're going to see once again how this program works.

210
00:14:46,260 --> 00:14:50,430
Briefly explain it once again in case there is something that you missed or did not understand.

211
00:14:50,580 --> 00:14:54,150
And then we are going to proceed to our next project.

212
00:14:54,240 --> 00:14:56,940
Thank you for watching and see you in the next lecture by.
