WEBVTT - This file was automatically generated by VIMEO

0
00:00:13.160 --> 00:00:17.350
Hello and welcome back to a brand new section in Dark Web and cybersecurity

1
00:00:17.350 --> 00:00:21.430
course. In this section we will talk about dark web automation,

2
00:00:21.430 --> 00:00:22.830
which is based on Python.

3
00:00:23.490 --> 00:00:28.450
So on the first video we will start a fast introduction about, uh,

4
00:00:28.450 --> 00:00:32.810
Python. Uh, keep in mind, uh, this course doesn't focus on Python,

5
00:00:33.190 --> 00:00:36.570
so you will learn Python a bit faster. Uh,

6
00:00:36.570 --> 00:00:39.730
it's better if you have the knowledge of Python before,

7
00:00:40.310 --> 00:00:42.330
but I will explain the, uh,

8
00:00:42.830 --> 00:00:47.590
the useful stuff and the beginner stuff in Python as like a fast

9
00:00:47.590 --> 00:00:48.423
walkthrough.

10
00:00:50.350 --> 00:00:55.240
It's not enough to just learn, uh, learn this, uh,

11
00:00:55.500 --> 00:00:58.800
in Python. Uh, you should have more knowledge about it.

12
00:00:58.940 --> 00:01:03.510
But as a beginner level and a fast walkthrough, it's uh,

13
00:01:03.620 --> 00:01:08.110
it's good to have these knowledge and maybe you can practice, uh,

14
00:01:08.370 --> 00:01:10.630
and get some knowledge for those who don't know Python.

15
00:01:11.470 --> 00:01:15.810
So let's start in introduction in Python. So what is Python?

16
00:01:15.910 --> 00:01:19.610
Python is a commonly used general purpose, high level programming language.

17
00:01:20.110 --> 00:01:24.850
It was founded by WeDo Roso in 1991 and then further

18
00:01:24.850 --> 00:01:27.210
developed by Python Software Foundation.

19
00:01:28.410 --> 00:01:33.260
This is designed with a focus on code readability as well as is syntax

20
00:01:33.280 --> 00:01:37.180
allows programmers to demonstrate their ideas and lesson lines of code.

21
00:01:37.920 --> 00:01:41.540
And Python has a programming language that helps you to work quickly and

22
00:01:41.570 --> 00:01:46.020
integrate system more effective. So why we need Python?

23
00:01:46.630 --> 00:01:49.860
Cause Python can create literally anything.

24
00:01:50.840 --> 00:01:53.170
Like you can use it in AI machine learning,

25
00:01:53.390 --> 00:01:58.050
you can use it in cybersecurity business, digital marketing,

26
00:01:58.310 --> 00:02:00.770
uh, like create apps, creating games.

27
00:02:01.150 --> 00:02:05.010
It can be used nearly in anything and especially automation.

28
00:02:05.390 --> 00:02:08.210
And this is what our main concern in this course,

29
00:02:08.210 --> 00:02:12.130
which is automation for the purpose of dark web investigation.

30
00:02:12.310 --> 00:02:16.530
So we can like create hacking tools, automated system administration.

31
00:02:17.110 --> 00:02:21.410
It can be used to also create web apps and it can be linked to databases

32
00:02:22.230 --> 00:02:25.890
and can be used in data science like AI and machine learning as we said before.

33
00:02:26.310 --> 00:02:28.170
And what's nice about uh, Python,

34
00:02:28.720 --> 00:02:33.570
it's a high level programming language and it's designed

35
00:02:33.570 --> 00:02:35.050
to do many tasks.

36
00:02:35.750 --> 00:02:38.730
And Python is an interpreter language.

37
00:02:39.150 --> 00:02:43.050
So basically it uh, runs line by line.

38
00:02:43.120 --> 00:02:47.930
It's not like c plus plus or Java or these kind of languages. So,

39
00:02:48.470 --> 00:02:49.303
uh,

40
00:02:49.570 --> 00:02:54.540
basically Python is based on C and so everything what we write and Python

41
00:02:54.640 --> 00:02:57.580
is being converted to c and C.

42
00:02:57.840 --> 00:03:02.500
He handles the execution on the lower level of the computer

43
00:03:02.650 --> 00:03:06.720
into binaries. So features of Python, easy to code,

44
00:03:07.570 --> 00:03:12.220
it's like writing English words cross platform mainly on all

45
00:03:12.500 --> 00:03:15.540
platforms available nowadays. Free and open source,

46
00:03:15.830 --> 00:03:20.540
integrated and interpreted language as we said. And it's a high level language.

47
00:03:21.390 --> 00:03:25.690
Python versus other languages. Python is easy and beginner friendly,

48
00:03:26.390 --> 00:03:28.410
mostly used by junior developers.

49
00:03:28.670 --> 00:03:31.890
And Java and other languages is harder for beginners.

50
00:03:32.780 --> 00:03:35.190
Basically we, when when you learn Python,

51
00:03:36.210 --> 00:03:38.790
you can learn it fast like in one or two hours.

52
00:03:40.210 --> 00:03:42.150
If you have like a basic, uh,

53
00:03:42.720 --> 00:03:46.330
programming knowledge or if you even don't have programming knowledge,

54
00:03:46.560 --> 00:03:50.640
this is Python let you ease.

55
00:03:50.640 --> 00:03:52.400
It can let you finish your task.

56
00:03:52.400 --> 00:03:55.360
Even if you don't know a lot of programming knowledge,

57
00:03:55.900 --> 00:03:57.640
unlike c plus plus and Java,

58
00:03:57.640 --> 00:04:01.520
where you need to have lots of knowledge about it and it,

59
00:04:01.630 --> 00:04:05.800
it's harder to uh, write uh, using these kind of languages.

60
00:04:06.220 --> 00:04:10.920
So Python is the most beginner friendly and at the end it can do the task that

61
00:04:10.920 --> 00:04:14.640
we want and that's what's important. So what is a variable?

62
00:04:14.980 --> 00:04:19.000
The first thing we need to begin in any language is to understand

63
00:04:19.920 --> 00:04:24.320
variable, especially for those who don't know. So variable is for storing data.

64
00:04:25.280 --> 00:04:29.930
Data can be taxed on numbers and you must assign an operator for the

65
00:04:30.330 --> 00:04:33.010
variable like the equals operator.

66
00:04:33.510 --> 00:04:38.320
But we will discuss operator after the variable section cause there's a lot of

67
00:04:38.320 --> 00:04:39.760
kinda, uh, operators.

68
00:04:41.210 --> 00:04:45.710
So basically a variable can be a name, can be anything. It just a,

69
00:04:45.830 --> 00:04:49.150
a place to store a data and use it later. For example,

70
00:04:49.220 --> 00:04:50.950
like you want to say,

71
00:04:51.720 --> 00:04:56.530
you want to create a variable called port and this port equals 80,

72
00:04:56.860 --> 00:04:58.930
let's say, which is the http.

73
00:05:00.040 --> 00:05:04.940
So what are the types of the variable we haver flow stringless topal

74
00:05:04.940 --> 00:05:08.350
dictionary Integer is uh, is a number.

75
00:05:08.520 --> 00:05:11.510
Float is a decimal number and string,

76
00:05:11.580 --> 00:05:15.790
basically it's any word you can put words, uh,

77
00:05:15.790 --> 00:05:18.310
it can be a single letter also. Uh,

78
00:05:18.310 --> 00:05:23.260
it's literally everything in between double quotation or single

79
00:05:23.260 --> 00:05:27.060
quotation. That would be called a string. A list example,

80
00:05:28.240 --> 00:05:30.340
we have services equal

81
00:05:32.940 --> 00:05:36.520
sub http, ssh and ftp.

82
00:05:36.780 --> 00:05:41.760
So that's the syntax of creating a list. So basically we have a variable,

83
00:05:42.030 --> 00:05:46.760
it's equal to a sub and each sub it's have its own uh, value.

84
00:05:47.590 --> 00:05:50.970
And it's the same thing with, but it's,

85
00:05:51.430 --> 00:05:54.010
and double parentheses instead of subs.

86
00:05:54.340 --> 00:05:59.100
We'll discuss more about these later in the future slides.

87
00:06:00.630 --> 00:06:04.210
And uh, finally we have the dictionary. Uh,

88
00:06:04.210 --> 00:06:08.810
an example for it at services equal TTP A T SSH 23,

89
00:06:09.150 --> 00:06:13.740
SMB 4 45. And here it's uh, currently bracelets.

90
00:06:14.520 --> 00:06:18.530
So also we will discuss this uh, later in the future slide.

91
00:06:18.590 --> 00:06:23.250
But these are the main types of variables that we mostly we will use.

92
00:06:24.560 --> 00:06:29.340
So variable name can be start with a character or underscore and checking type

93
00:06:29.340 --> 00:06:32.780
of variable using a method called type. For example,

94
00:06:33.360 --> 00:06:35.900
we have FTP equal 21.

95
00:06:35.900 --> 00:06:40.380
So we created a variable called FTP and it's equal to 21.

96
00:06:40.760 --> 00:06:43.300
So that's a variable of type integer.

97
00:06:43.600 --> 00:06:47.780
But if you would like to check the type of this variable simply you can use

98
00:06:48.370 --> 00:06:52.940
type which is a method bypassing the variable name within the method,

99
00:06:53.050 --> 00:06:55.790
like this type ftp.

100
00:06:56.170 --> 00:07:01.150
So when you write this on Python, you call a function,

101
00:07:01.540 --> 00:07:02.950
it's a built-in function.

102
00:07:03.050 --> 00:07:07.630
So basically you write type and in between you pass through the variable that

103
00:07:07.630 --> 00:07:11.990
you created before and it'll output that it's an integer

104
00:07:12.340 --> 00:07:14.590
basically. So this uh, function,

105
00:07:14.620 --> 00:07:18.910
it's useful for sometimes that you don't know what kind of variable is this

106
00:07:19.550 --> 00:07:24.260
cause late it might get complex. So, uh, using this function is very useful.

107
00:07:25.170 --> 00:07:27.480
Legal variables and illegal variables.

108
00:07:27.780 --> 00:07:32.360
As you know when writing uh, or when creating a variable,

109
00:07:32.790 --> 00:07:34.680
there's certain errors we might face.

110
00:07:34.710 --> 00:07:37.000
There's a correct way to create a variable.

111
00:07:37.740 --> 00:07:42.720
So the legal variables or the accepted variables must start with character or

112
00:07:42.730 --> 00:07:47.000
underscore lowercase or uppercase. As a basic example,

113
00:07:47.100 --> 00:07:50.760
as I said before, HTP equal 80.

114
00:07:50.940 --> 00:07:53.760
So I created a random variable,

115
00:07:54.150 --> 00:07:57.510
it's called http and I assign it 80.

116
00:07:57.700 --> 00:08:01.390
It's equal to 80 illegal variables. It start with a number.

117
00:08:01.930 --> 00:08:06.470
It has underscore between words like SSH, dash,

118
00:08:06.970 --> 00:08:11.950
htp, equal error. So anything would uh, underscore it won't work.

119
00:08:12.320 --> 00:08:13.430
It'll give you error.

120
00:08:14.730 --> 00:08:19.460
Operators use to perform actions on variable using plus

121
00:08:19.820 --> 00:08:24.420
operators to add together to values. And there's multiple types of operators.

122
00:08:24.560 --> 00:08:28.500
We have arithmetic operators, assignment operators, comparison,

123
00:08:29.090 --> 00:08:33.300
logical identity membership. But wise there's a lot of operators.

124
00:08:34.160 --> 00:08:35.180
But in this course,

125
00:08:35.180 --> 00:08:40.180
mostly we'll focus on the TIC comparison and the the logical

126
00:08:40.830 --> 00:08:44.380
cause. Uh, that's the most ones that we will use.

127
00:08:45.370 --> 00:08:46.203
Strings.

128
00:08:46.660 --> 00:08:51.460
A sequence of characters starts and end with double quotes or single quotes.

129
00:08:52.010 --> 00:08:56.980
Most data types used in Python as the most data type ever used

130
00:08:56.980 --> 00:09:01.700
in Python. An example port 22, it's equal to ssh.

131
00:09:01.800 --> 00:09:05.940
So as you can see it's a variable equal double quotes ssh,

132
00:09:06.310 --> 00:09:10.750
which means this variable is a string advantages,

133
00:09:11.060 --> 00:09:14.350
it's used to concatenate strings with variable or text.

134
00:09:15.280 --> 00:09:17.660
So basically combining uh,

135
00:09:17.680 --> 00:09:21.260
two variables with each other or just uh,

136
00:09:21.260 --> 00:09:23.820
the strings writing code becomes easier.

137
00:09:24.390 --> 00:09:27.100
Saves a text message in a variable like ftp,

138
00:09:27.100 --> 00:09:31.750
equal FTP server accessing a specific values. This is really useful.

139
00:09:32.130 --> 00:09:36.830
You will use things always three ways to create a string. A single quote,

140
00:09:36.860 --> 00:09:39.990
example port 22 SSH double quote,

141
00:09:40.020 --> 00:09:42.990
example port 22 ssh.

142
00:09:43.890 --> 00:09:48.150
So the difference here is just single quote on double quotes, but at the,

143
00:09:48.150 --> 00:09:51.830
it's the same. Nothing can change. You can use either this or that.

144
00:09:51.930 --> 00:09:52.910
Triple quotes,

145
00:09:52.940 --> 00:09:57.510
this is useful for to write a paragraph or to create a menu for a tool.

146
00:09:57.970 --> 00:10:02.630
As you can see like in hacking tools or any tool that you see on

147
00:10:02.650 --> 00:10:03.410
GitHub,

148
00:10:03.410 --> 00:10:07.990
you see like those big menus and stuff that you can click here or click there.

149
00:10:08.490 --> 00:10:10.470
So basically they use uh,

150
00:10:10.470 --> 00:10:14.230
these kind of stuff which is the triple quotes.

151
00:10:14.530 --> 00:10:19.110
And we have also multiline strings start with triple quotation and ends with a

152
00:10:19.110 --> 00:10:23.110
triple quotation. And you can insert a big chunk of uh words.

153
00:10:23.610 --> 00:10:27.830
An example. So you have a menu. I created a variable called menu.

154
00:10:28.970 --> 00:10:33.350
And you have welcome to my tool. If you press one, it's support scanner two,

155
00:10:33.350 --> 00:10:36.710
vulnerability scanner three, it's exit. Okay.

156
00:10:37.050 --> 00:10:41.750
And as you can see we have at first three double quotations and the end three

157
00:10:41.750 --> 00:10:44.790
double quotations. And at the end we print it.

158
00:10:45.670 --> 00:10:50.170
So to output a certain string or anything you want to output,

159
00:10:50.170 --> 00:10:52.850
basically you just use a function called print.

160
00:10:53.510 --> 00:10:58.480
So print menu concatenations putting

161
00:10:58.660 --> 00:11:01.760
two or more strings together like hack plus me,

162
00:11:02.270 --> 00:11:04.070
this will output hack me.

163
00:11:05.030 --> 00:11:09.970
So as you can see we have two strings but we concatenate it with a

164
00:11:09.970 --> 00:11:12.540
plus. So this will output hacking.

165
00:11:12.850 --> 00:11:16.900
Concatenation can be done only with strings. An example usage.

166
00:11:17.640 --> 00:11:22.210
So we have a variable called IP address and

167
00:11:22.680 --> 00:11:26.420
IP address or IP ad. It's taking an input.

168
00:11:26.840 --> 00:11:31.660
Please enter an IP address and to do an input and to

169
00:11:31.660 --> 00:11:35.740
talk with the user, you just use a uh,

170
00:11:36.700 --> 00:11:41.540
function called input. So basically whatever it's input,

171
00:11:42.320 --> 00:11:47.260
the data would be saved on IP ads. And we have port one with the sa,

172
00:11:47.260 --> 00:11:48.340
same logic bus.

173
00:11:48.440 --> 00:11:53.300
But here you will enter a port number and at the end I need to print

174
00:11:54.340 --> 00:11:56.270
what the user has input.

175
00:11:56.530 --> 00:12:01.350
So print scanning plus IP ad plus on

176
00:12:01.740 --> 00:12:02.573
plus port.

177
00:12:02.650 --> 00:12:07.390
So scanning is in double quotations cause it's not a variable plus IP

178
00:12:07.450 --> 00:12:07.670
ad.

179
00:12:07.670 --> 00:12:12.110
There's no double quotations here cause it's not a string but it's a variable of

180
00:12:12.150 --> 00:12:12.983
a string.

181
00:12:13.330 --> 00:12:18.110
So plus IP add plus on cause it's on is not a variable plus

182
00:12:18.140 --> 00:12:22.630
port. So when you have a variable or you need to print a variable,

183
00:12:22.630 --> 00:12:26.590
you don't put it in double quotations or single quotations.

184
00:12:26.890 --> 00:12:31.070
So Python will output from this example scanning uh,

185
00:12:31.070 --> 00:12:34.950
29.1 0.9 9.999 port

186
00:12:35.410 --> 00:12:40.230
2019. Therefore we successfully concatenate strings with variables.

187
00:12:41.060 --> 00:12:42.990
Accessing an item in a string.

188
00:12:43.580 --> 00:12:46.710
Accessing a string is through is by indexing.

189
00:12:47.750 --> 00:12:52.510
Assuming we have a variable course equal python programming,

190
00:12:53.010 --> 00:12:57.750
an example usage would be course zero, course one.

191
00:12:57.820 --> 00:12:59.830
This will output P, this will output Y.

192
00:13:00.180 --> 00:13:05.150
What can we understand from in programming you must count from zero

193
00:13:05.290 --> 00:13:09.350
and not from one. So Python P is zero,

194
00:13:09.910 --> 00:13:12.470
Y is one, T is two and so on,

195
00:13:13.660 --> 00:13:17.670
even the space between N and P, you must count it.

196
00:13:17.850 --> 00:13:21.390
And programming word is not like the real word that we count in.

197
00:13:22.180 --> 00:13:26.840
So course zero will output P and course one will output Y.

198
00:13:27.340 --> 00:13:30.320
The logic is the same with anything in programming.

199
00:13:30.320 --> 00:13:35.040
Literally you count from zero and it'll output the exact first thing.

200
00:13:35.310 --> 00:13:36.160
Zero is P,

201
00:13:36.740 --> 00:13:41.520
one is Y formatting a string formatting is a changing the format

202
00:13:41.580 --> 00:13:46.280
of tax of how we will output it on the screen and it can be achieved using a

203
00:13:46.280 --> 00:13:48.920
method called format. So format is a built-in function.

204
00:13:48.940 --> 00:13:53.840
We use it to change the format of the text to make it more uh,

205
00:13:54.020 --> 00:13:58.880
better on the out. So an example usage. So we have a IP address,

206
00:13:59.840 --> 00:14:04.520
a variable of string and I must print it but I don't want to

207
00:14:04.550 --> 00:14:08.560
concatenate it in a weird way like we saw in the previous slides.

208
00:14:09.220 --> 00:14:13.480
So I did put scanning IP address and curly bracelet

209
00:14:14.090 --> 00:14:16.040
where it should be put.

210
00:14:16.580 --> 00:14:21.440
So basically inside this curly bracelet we will have the IP address.

211
00:14:22.300 --> 00:14:25.920
So to achieve this, you just put the curly bracelets here,

212
00:14:26.210 --> 00:14:29.440
which is the position of the variable that you will put in.

213
00:14:29.980 --> 00:14:34.420
So in order to achieve this, when you close the double quotes,

214
00:14:34.840 --> 00:14:39.510
you just type dot for IP address.

215
00:14:40.210 --> 00:14:43.310
So directly the IP address. So it would be here.

216
00:14:43.810 --> 00:14:46.550
So at the end it'll output scanning IP address

217
00:14:46.570 --> 00:14:49.110
25 0 2 19 77.

218
00:14:49.730 --> 00:14:54.340
And every time if you want like to add more curly bracelets on the same line,

219
00:14:54.810 --> 00:14:57.900
keep in mind the first variable you put,

220
00:14:58.030 --> 00:15:02.990
it'll be given to the first curly bracelet. And so on conditions,

221
00:15:04.120 --> 00:15:08.270
conditions are statement made by the program is that determines the behavior of

222
00:15:08.270 --> 00:15:11.990
the program and evaluates whether they are true or false.

223
00:15:12.500 --> 00:15:16.910
This could be used to build pathways in a program that allows for consistency

224
00:15:17.050 --> 00:15:20.710
and a better assessment method and conditions is needed in programming,

225
00:15:20.780 --> 00:15:25.270
each condition will be shown in the exercise. So an example, uh,

226
00:15:25.280 --> 00:15:30.140
chart here you have if and inside this earth there's a condition.

227
00:15:30.400 --> 00:15:35.140
So if a equal true, then B, L C. And if, okay,

228
00:15:36.050 --> 00:15:39.310
so this is an example chart of how conditions are.

229
00:15:40.130 --> 00:15:43.630
So if a is true then we will execute B.

230
00:15:43.970 --> 00:15:46.950
But if A is false it'll execute C. Okay,

231
00:15:47.350 --> 00:15:49.910
I will show you how this is done in example.

232
00:15:50.570 --> 00:15:52.670
But we have multiple types of conditions.

233
00:15:53.010 --> 00:15:57.180
We have if else Eli or else if

234
00:15:58.040 --> 00:16:00.100
and or nested if based statement.

235
00:16:00.570 --> 00:16:04.500
This is the types of condition that you will use all the time.

236
00:16:04.920 --> 00:16:05.900
So an example.

237
00:16:06.850 --> 00:16:11.800
So there's a variable port equal 88. Okay?

238
00:16:12.220 --> 00:16:16.520
So this is an integer variable we have another variable

239
00:16:17.180 --> 00:16:20.830
is open equal port and

240
00:16:21.850 --> 00:16:26.830
22 84, 4 3 common open ports. By the way,

241
00:16:26.830 --> 00:16:31.390
everything in hashtag it's a comment vulnerability, it's a string variable.

242
00:16:31.400 --> 00:16:36.230
Heart bleed is exploitable vulnerability equal

243
00:16:36.230 --> 00:16:38.950
heart bleed or vulnerability equal equal sha shock.

244
00:16:39.290 --> 00:16:43.920
So is exploitable equal vulnerability equal,

245
00:16:43.920 --> 00:16:46.920
equal heart bleed or vulnerability equal equal sha shock.

246
00:16:47.060 --> 00:16:50.760
So here we're saying if it's equal, equal that or equal equal that.

247
00:16:51.300 --> 00:16:56.080
And here we'll create a condition. So as exploitable contain all of this.

248
00:16:56.780 --> 00:16:59.120
So if statement, an example of if,

249
00:16:59.260 --> 00:17:02.000
if is open print port is open.

250
00:17:03.020 --> 00:17:07.980
So basically it's true cause we already said it is open and all

251
00:17:07.980 --> 00:17:12.300
of this are open. If else statement, if it's open print,

252
00:17:12.300 --> 00:17:15.260
port is open, else print is closed.

253
00:17:16.310 --> 00:17:20.410
So if it's not open else it'll execute. It's closed.

254
00:17:20.790 --> 00:17:25.330
If else, if else statement we have, if is open, port is open,

255
00:17:25.520 --> 00:17:30.450
else if is exploitable port is closed but there is a vulnerability else

256
00:17:30.620 --> 00:17:33.370
ports port is closed and not vulnerable.

257
00:17:33.790 --> 00:17:37.090
So if the condition is false else,

258
00:17:37.150 --> 00:17:41.290
if if the condition is false then else it will execute that.

259
00:17:41.630 --> 00:17:45.610
And operator if is open and is exploitable,

260
00:17:45.670 --> 00:17:46.690
if both are true,

261
00:17:46.920 --> 00:17:51.020
then it'll print port is open and exploit or operator

262
00:17:51.800 --> 00:17:55.100
if is open or is exploitable. If that is true,

263
00:17:55.490 --> 00:18:00.380
then port is either open or exploitable, you see. So basically at first,

264
00:18:00.560 --> 00:18:04.620
if it's the thing is true then it'll do that. If it's not, it'll do the that.

265
00:18:04.880 --> 00:18:09.540
So nested if statement, nested if statement, basically it's an if inside, an if.

266
00:18:09.810 --> 00:18:10.370
Okay,

267
00:18:10.370 --> 00:18:15.040
basically nested the meaning of it is something inside something.

268
00:18:15.260 --> 00:18:19.200
So nested if statement if is open and if it's exploitable,

269
00:18:19.260 --> 00:18:21.520
if both is if if this is open,

270
00:18:21.580 --> 00:18:24.880
if it's true and if is exploitable is true,

271
00:18:24.970 --> 00:18:29.440
it'll print port is open and exploitable. But if it is open,

272
00:18:29.510 --> 00:18:33.640
true and if exploitable is not true then it'll go to the else.

273
00:18:34.430 --> 00:18:39.000
Okay? But if it's open is true and if exploitable is not,

274
00:18:39.610 --> 00:18:42.760
it'll print port is closed. Okay, so that's it.

275
00:18:42.990 --> 00:18:46.080
Pass a statement basically means don't do anything.

276
00:18:46.740 --> 00:18:49.720
So if is open pass, don't do anything,

277
00:18:49.900 --> 00:18:54.870
no actions needed as it'll print port is closed if the condition

278
00:18:54.970 --> 00:18:58.100
is false, not true tops.

279
00:18:58.410 --> 00:19:01.420
Tops are used to store multiple values in one variable.

280
00:19:01.920 --> 00:19:05.260
So basically topple is kind of the same logic as list,

281
00:19:05.560 --> 00:19:08.660
but as we said it's in double parenthesis, sorry,

282
00:19:09.610 --> 00:19:12.100
topples are fixed and so it can be changed.

283
00:19:12.170 --> 00:19:15.780
Topples are common separated and then the uses of the parenthesis is optional.

284
00:19:16.630 --> 00:19:18.320
Topples elements can be duplicated.

285
00:19:18.940 --> 00:19:23.000
You can access the elements in topple through indexing as I showed you before

286
00:19:23.000 --> 00:19:27.520
with strings and how to access a string. Same logic with tap. So tap

287
00:19:29.020 --> 00:19:33.800
AEI, o u 0, 1, 2, 3, 4, you see. So tap zero,

288
00:19:33.970 --> 00:19:37.720
it'll print a one, it'll and so on so forth.

289
00:19:39.590 --> 00:19:43.610
You need to count from zero in order to find an index from the number of the

290
00:19:43.610 --> 00:19:44.730
element inside of top.

291
00:19:44.910 --> 00:19:49.910
Use index function Index in order to delete a top used deal

292
00:19:50.230 --> 00:19:53.390
followed by the top name to delete at the entire topple.

293
00:19:53.530 --> 00:19:57.700
An important note about tops values cannot be changed.

294
00:19:58.250 --> 00:20:03.220
It's not like list a reference between and list besides of

295
00:20:03.360 --> 00:20:08.220
the presentation of either subs or parentheses

296
00:20:08.280 --> 00:20:09.930
or bracelets.

297
00:20:10.800 --> 00:20:15.710
The main difference between tops and list that list values can be

298
00:20:15.710 --> 00:20:20.550
changed but tops cannot, cannot be changed. List. As we said,

299
00:20:20.660 --> 00:20:22.270
it's mainly like topple,

300
00:20:22.810 --> 00:20:27.700
but here you can change the values and also you must count

301
00:20:27.770 --> 00:20:29.950
from zero dictionary.

302
00:20:30.490 --> 00:20:35.390
And Python is a unsorted set of sub data values used to store data

303
00:20:35.390 --> 00:20:37.830
values written in currently brackets.

304
00:20:38.020 --> 00:20:41.430
Each element is accessed by any key dictionary.

305
00:20:41.730 --> 00:20:46.510
RN sequence provide fast lockup and dictionary can be useful a lot

306
00:20:46.510 --> 00:20:48.860
such as filter dictionary, search by keys.

307
00:20:50.060 --> 00:20:52.960
So basically the logic of dictionary is key and values.

308
00:20:53.780 --> 00:20:58.120
So we have the key HTP and it has a value 80,

309
00:20:58.980 --> 00:21:02.710
another ftp, it's a key but it's value is 21.

310
00:21:02.810 --> 00:21:06.510
So each key has its own value and uh,

311
00:21:07.610 --> 00:21:09.350
key is a unique also.

312
00:21:10.140 --> 00:21:12.880
So here are an example list ports

313
00:21:12.880 --> 00:21:17.880
22 84, 4, 3, 3, 3, 8, 9 accessing list elements

314
00:21:18.010 --> 00:21:18.843
first port.

315
00:21:19.260 --> 00:21:23.200
So if I need to print the first value of the list,

316
00:21:23.210 --> 00:21:24.400
which is 22,

317
00:21:25.320 --> 00:21:29.060
so basically 22 is index of zero.

318
00:21:30.200 --> 00:21:35.060
So first ports subzero ports zero.

319
00:21:35.240 --> 00:21:38.420
So basically I did print first port double quotations,

320
00:21:39.090 --> 00:21:43.860
then I concatenated with with this and I call the

321
00:21:44.100 --> 00:21:48.340
variable ports sub zero and that's how will I get

322
00:21:48.870 --> 00:21:51.530
22. Same thing with the second port,

323
00:21:52.070 --> 00:21:54.450
but you should add the index one, not zero.

324
00:21:54.550 --> 00:21:59.500
So it'll be 80 modifying list values support one it's

325
00:21:59.790 --> 00:22:03.380
equal 80, 80. Now print modified port ports,

326
00:22:03.670 --> 00:22:08.660
it'll print all of this but here it'll be 80, 80 topple vulnerabilities,

327
00:22:08.870 --> 00:22:12.980
heart bleed, shell shock, spector accessing topple elements.

328
00:22:13.050 --> 00:22:16.640
Same thing with the list. Nothing change.

329
00:22:16.980 --> 00:22:21.760
But what cannot we can do is basically we can change

330
00:22:22.140 --> 00:22:26.290
the value of tops dictionary host one,

331
00:22:26.710 --> 00:22:29.210
IP host two, IP host three and the ip.

332
00:22:29.790 --> 00:22:33.290
So let's say I need the value of the second key.

333
00:22:33.950 --> 00:22:36.490
So basically uh, I say host,

334
00:22:36.840 --> 00:22:40.930
host two and then it'll print IP address of host two is that.

335
00:22:41.350 --> 00:22:45.850
And you can modify the dictionary values basically host host three for example

336
00:22:47.030 --> 00:22:51.930
and change this IP address into 2.02 cause basically it's the same but

337
00:22:52.030 --> 00:22:56.770
I'm changing one digit of it. And print modified host,

338
00:22:56.920 --> 00:23:01.490
host it will print all of it with the modified value of the

339
00:23:02.140 --> 00:23:04.680
third key loops.

340
00:23:05.450 --> 00:23:10.240
Loops are an session concept and programming as they allow us to execute a

341
00:23:10.240 --> 00:23:11.960
block of code repeatedly.

342
00:23:12.750 --> 00:23:17.280
They are used to when we want to perform a certain action multiple times

343
00:23:18.630 --> 00:23:23.530
or iterate over a collection of items such as a list or a dictionary.

344
00:23:24.220 --> 00:23:25.690
Loops provide efficiency,

345
00:23:25.840 --> 00:23:29.850
flexibility and the ability to automate repetitive task.

346
00:23:30.200 --> 00:23:35.070
Generally we use two kind of loops for loop and the

347
00:23:35.150 --> 00:23:39.390
Y loop for loop iterates over a sequence and while loop iterates

348
00:23:40.050 --> 00:23:44.470
it repeatedly execute a block of code as long as a specified condition is true.

349
00:23:44.850 --> 00:23:48.580
By utilizing loops, programs can make their code more efficient,

350
00:23:48.610 --> 00:23:52.980
concise and maintainable. They plan a vital role in automating process,

351
00:23:53.170 --> 00:23:57.900
iterating over collection and implementing dynamic behavior and various

352
00:23:57.900 --> 00:24:01.100
programming tasks including cybersecurity related operations.

353
00:24:01.640 --> 00:24:05.940
In this course we will focus on four loop and y loop and now we will see an

354
00:24:05.940 --> 00:24:08.130
example of that for loop.

355
00:24:08.390 --> 00:24:12.010
So we have a variable vulnerabilities contains all, all of that.

356
00:24:12.510 --> 00:24:15.850
So to iterate over a list of vulnerabilities using a loop,

357
00:24:16.120 --> 00:24:18.610
basically four in vulnerabilities.

358
00:24:19.150 --> 00:24:21.970
So I created vulnerabilities basically this,

359
00:24:22.390 --> 00:24:26.690
as you can see this variable doesn't exist but we have vulnerabilities even you

360
00:24:26.690 --> 00:24:31.250
can literally say anything you can say for x and vulnerabilities for Y and

361
00:24:31.250 --> 00:24:33.850
vulnerabilities for your name and your vulnerabilities.

362
00:24:34.270 --> 00:24:36.890
It doesn't matter as long you are putting in.

363
00:24:37.870 --> 00:24:42.060
So basically for vulnerabilities and vulnerabilities.

364
00:24:42.120 --> 00:24:45.740
So basically you're telling Python for this and that,

365
00:24:45.740 --> 00:24:48.300
taking it in English words. Okay,

366
00:24:48.760 --> 00:24:52.800
so print scanning for vulnerability vulnerabilities.

367
00:24:53.260 --> 00:24:55.520
So here you might ask why there's enough,

368
00:24:56.510 --> 00:24:58.370
if you remember the dot format,

369
00:24:59.120 --> 00:25:02.170
it's the same concept but different usage.

370
00:25:03.240 --> 00:25:07.780
So you put F at the beginning before double quotations and

371
00:25:07.780 --> 00:25:12.110
currently brackets here where you want to put it,

372
00:25:12.130 --> 00:25:15.500
it doesn't matter and the name of the variable. Okay,

373
00:25:15.640 --> 00:25:19.220
so the different here between this and the dot format.

374
00:25:19.400 --> 00:25:24.400
In dot format you don't say you don't put the variable name inside

375
00:25:24.400 --> 00:25:26.120
the double quotations you don't.

376
00:25:26.430 --> 00:25:29.400
This is only the case of when you use this kind of format,

377
00:25:29.530 --> 00:25:32.640
which is the F before the double quotation.

378
00:25:32.780 --> 00:25:37.600
So let's say it was four x and vulnerabilities and you need to use the

379
00:25:37.600 --> 00:25:38.640
same format here.

380
00:25:38.940 --> 00:25:43.640
So you say scanning for curly brackets X instead of vulnerability and so on.

381
00:25:44.420 --> 00:25:47.520
So now after uh, executing this,

382
00:25:48.180 --> 00:25:52.600
so each time it iterates over vulnerabilities it'll print scanning for hard

383
00:25:52.620 --> 00:25:56.560
bleeds, scanning for shell shocks, scanning for specter vulnerability.

384
00:25:57.340 --> 00:26:00.880
So basically you are iterating over a list while loop.

385
00:26:01.380 --> 00:26:05.640
So I created a condition called count and count is equal.

386
00:26:05.700 --> 00:26:09.680
One attempting to crack password using a while loop for example,

387
00:26:10.350 --> 00:26:12.980
while count is less than or equal five.

388
00:26:14.160 --> 00:26:17.900
And remember the difference between Y and four four is iterating.

389
00:26:18.500 --> 00:26:19.700
Y is based on conditions.

390
00:26:20.750 --> 00:26:25.610
So while count is less than or equal five first S

391
00:26:25.610 --> 00:26:28.450
count is less than or equal five. Yes it is.

392
00:26:28.510 --> 00:26:32.410
So it's true as one is less than or equal five

393
00:26:34.090 --> 00:26:38.550
prints attempting to attempting password count.

394
00:26:38.900 --> 00:26:39.733
Okay,

395
00:26:39.770 --> 00:26:43.940
so here it'll print each attempt at doing attempt

396
00:26:44.720 --> 00:26:49.660
1, 2, 3 until it's reach five and it'll be terminated.

397
00:26:50.280 --> 00:26:55.060
But if it was 10 it'll continue to 10. If it was hundred it'll continue to 100.

398
00:26:55.760 --> 00:26:58.460
It depends on your condition that you will put.

399
00:26:58.960 --> 00:27:03.860
But if it was count equals seven and you did less than or equal five,

400
00:27:04.050 --> 00:27:08.930
then it won't work Count plus equal one cause

401
00:27:09.140 --> 00:27:13.630
it'll add each time cause

402
00:27:13.800 --> 00:27:14.490
it'll uh,

403
00:27:14.490 --> 00:27:19.400
in order to terminate this count also count plus equal one one

404
00:27:19.400 --> 00:27:23.980
each reach five nested loop ports equal

405
00:27:24.440 --> 00:27:29.220
2 84, 4 3 we have this list and we have this list

406
00:27:29.450 --> 00:27:33.820
also one is based on integers, the other is based on strings

407
00:27:35.330 --> 00:27:39.450
checking open ports on multiple hosts using nested loop four host and host

408
00:27:40.080 --> 00:27:41.090
four port and ports.

409
00:27:41.150 --> 00:27:45.490
As you can see host and port doesn't exist Python by default.

410
00:27:45.670 --> 00:27:49.650
We can create with Python a variable that doesn't exist.

411
00:27:50.280 --> 00:27:54.460
And this is so famous when you do four loops and these kind of stuff.

412
00:27:55.240 --> 00:27:58.780
So for host and host nested for port and ports.

413
00:27:59.560 --> 00:28:04.460
So we are saying if host and the host and nested,

414
00:28:04.820 --> 00:28:08.510
I mean nested port in ports scanning host,

415
00:28:08.580 --> 00:28:10.230
host on port port.

416
00:28:10.410 --> 00:28:15.230
So basically it'll print scanning this host on this port and so on,

417
00:28:15.230 --> 00:28:17.620
so on and so on. Functions.

418
00:28:18.660 --> 00:28:23.060
Functions are integral part of coding as they allow you to break down complex

419
00:28:23.100 --> 00:28:26.660
problems into smaller manageable pieces of code.

420
00:28:26.820 --> 00:28:31.660
A function is a block of organized reusable code that performs a specific task.

421
00:28:32.200 --> 00:28:34.700
It help us improve code organization. Modularity,

422
00:28:35.810 --> 00:28:39.410
reusability and maintainability functions are fundamental.

423
00:28:39.730 --> 00:28:42.850
Building block and programming. They allow you to encapsulate logic,

424
00:28:43.040 --> 00:28:46.650
promote code, reuse, and improve code, organization and readability.

425
00:28:47.190 --> 00:28:51.370
By leveraging functions effectively, you can create more maintainable, scalable,

426
00:28:51.510 --> 00:28:54.810
and efficient code. An example of functions,

427
00:28:55.420 --> 00:28:59.250
first function is to check if a port is open. So death is port,

428
00:28:59.400 --> 00:29:04.210
open port as you can see I create a function with a keyword

429
00:29:04.210 --> 00:29:06.850
called death. Death is port open

430
00:29:08.450 --> 00:29:11.910
and I open parenthesis always a function will have parenthesis,

431
00:29:11.930 --> 00:29:14.070
but it doesn't matter. It might not have port,

432
00:29:14.070 --> 00:29:18.910
it might have nothing and it might have uh, multiple values or variable names.

433
00:29:19.030 --> 00:29:19.370
I mean.

434
00:29:19.370 --> 00:29:24.070
So if port in 20 84, 43 return through as

435
00:29:24.210 --> 00:29:25.990
return, false function,

436
00:29:25.990 --> 00:29:29.270
call port status equal is port,

437
00:29:29.270 --> 00:29:32.970
port open 22 print is port 22,

438
00:29:33.000 --> 00:29:37.910
open port status and here it'll print through.

439
00:29:38.080 --> 00:29:40.870
Cause already we said if port in these,

440
00:29:40.990 --> 00:29:43.860
it'll return through as it'll return false. If not,

441
00:29:43.930 --> 00:29:47.960
none of that it'll return false. So after run this,

442
00:29:48.130 --> 00:29:53.040
it'll return through second function to perform or

443
00:29:53.040 --> 00:29:54.950
vulnerability scan D,

444
00:29:54.950 --> 00:29:59.150
vulnerability scan host vulnerability is equal. Heart bleed,

445
00:29:59.150 --> 00:29:59.990
cell shock spectrum.

446
00:30:00.100 --> 00:30:04.060
It's a list of vulnerabilities for vulnerability and vulnerability scanning.

447
00:30:04.090 --> 00:30:08.420
Host for vulnerability. Vulnerability what the format. So vulnerability scan,

448
00:30:09.160 --> 00:30:13.980
uh, we passed a string which represent the variable host.

449
00:30:14.440 --> 00:30:18.340
So this is a passing through and now this

450
00:30:19.000 --> 00:30:23.940
1 9 2 1 6 8 0 0.1 is now in host and now you

451
00:30:23.940 --> 00:30:25.420
can use it inside this function.

452
00:30:26.450 --> 00:30:29.310
So here it'll be for vulnerability and vulnerability scanning.

453
00:30:29.620 --> 00:30:32.430
This host which is this, well what we,

454
00:30:32.490 --> 00:30:37.150
we pass it here and it would be scanning for that host with

455
00:30:37.430 --> 00:30:39.870
hardware shock inspector and so on. Finally,

456
00:30:40.290 --> 00:30:43.640
we have function to calculate the risk score. D,

457
00:30:43.710 --> 00:30:48.440
calculate risk score and it takes a vulnerability and it takes the variable

458
00:30:48.440 --> 00:30:53.320
called vulnerabilities, risk score equal land. Now you'll ask me what is land?

459
00:30:53.430 --> 00:30:58.200
Land means length and it'll output the length of vulnerabilities.

460
00:30:58.380 --> 00:30:59.110
So lan,

461
00:30:59.110 --> 00:31:03.760
it's a function that will output the length of a list or

462
00:31:03.760 --> 00:31:07.900
something. So LAN and we pass through the vulnerabilities,

463
00:31:08.360 --> 00:31:11.860
the variable times five, return this score.

464
00:31:12.080 --> 00:31:16.380
So here I created a variable called the risk score Equal calculate risk score

465
00:31:16.380 --> 00:31:20.220
vulnerabilities found. So calculate risk score the function.

466
00:31:20.480 --> 00:31:24.100
And I passed through the list that I have, which is heart bleed, spectrum,

467
00:31:24.180 --> 00:31:28.460
meltdown and print risk score. Risk score, basically that's it.

468
00:31:29.560 --> 00:31:32.730
Obviously all of this, uh, just an example,

469
00:31:33.240 --> 00:31:37.250
it's not a real scan or a real way to do this kind of stuff.

470
00:31:37.360 --> 00:31:39.420
It's just a simple, uh,

471
00:31:39.430 --> 00:31:44.220
logic of how to use these kind of functions or the syntax and python

472
00:31:44.930 --> 00:31:48.780
just to get familiar in this kind of stuff in order to use it in a real life of

473
00:31:48.780 --> 00:31:53.140
operation that we will use in your daily life as a cyber analyst,

474
00:31:53.140 --> 00:31:57.780
cyber consultant, and especially in this course when it comes to dark web.

475
00:31:58.560 --> 00:32:03.180
Lastly, we have models. Model is a library contains functions.

476
00:32:03.230 --> 00:32:08.060
Model is a useful to be used in your code model is simply a

477
00:32:08.060 --> 00:32:10.340
python file with an extension pi,

478
00:32:10.940 --> 00:32:14.340
a basic usage of uh, models. Basically

479
00:32:15.880 --> 00:32:18.340
import and model name, for example,

480
00:32:18.560 --> 00:32:22.540
import UN map or input OS or input request

481
00:32:23.460 --> 00:32:28.000
and accessing a specific model function example OS system.

482
00:32:28.800 --> 00:32:32.500
You can open CMD to install a model or shell

483
00:32:33.620 --> 00:32:36.680
you open and type PIP install. And the name of the library,

484
00:32:37.130 --> 00:32:40.030
which is in this case, uh, there's an,

485
00:32:40.310 --> 00:32:45.300
I gave an example about unap PIP install unap. And as we can see in this figure,

486
00:32:45.360 --> 00:32:49.140
the example is to installing unap model, collecting, downloading,

487
00:32:49.200 --> 00:32:53.480
and now it's ready to be used. Thank you for watching this video.

488
00:32:53.680 --> 00:32:54.880
I hope it was useful.

489
00:32:55.600 --> 00:32:59.080
I know it's not the full course of Python or uh,

490
00:32:59.390 --> 00:33:03.120
it's not the full walkthrough, but what I gave you,

491
00:33:03.150 --> 00:33:07.440
it's more than enough to get start or understand at least the next videos.

492
00:33:08.180 --> 00:33:12.580
But I highly suggest for you is to exercise some python,

493
00:33:12.920 --> 00:33:14.060
get to know more Python.

494
00:33:14.710 --> 00:33:17.660
Cause the example in the next videos are a bit advanced,

495
00:33:19.220 --> 00:33:22.320
but just follow along and you'll enjoy it.

496
00:33:22.460 --> 00:33:26.440
So I will see you in the next video where we'll discuss onion links automation

497
00:33:26.650 --> 00:33:30.760
using Python, which will be the first dark web automation and discourse.

498
00:33:31.100 --> 00:33:32.120
See you on the next video.
