शैडोइंग अभ्यास: Python For Ethical Hacking & Cybersecurity Basic Intro - वीडियो के साथ अंग्रेजी बोलना सीखें

पाठ बनाया जा रहा है...
1
So now that you have an interest in cybersecurity, what comes next is usually the question of what kind of programming do I need to know?
2
So in this video, what we're going to cover is the Python
3
that I think you need to know as you're entering into cybersecurity.
4
This is an introductory course into Python for the purpose of cybersecurity.
5
I have tried to keep it as streamlined as possible to
6
keep you away from having to watch a six hour course on Python for cybersecurity
7
that is just full of stuff that I think you're not really going to need in the future.
8
So this is a beginner course.
9
And if you have any questions as you're going through it, please leave some questions down in the comments or you want to cover something more in depth,
10
please let me know because I don't know exactly what it is
11
that you guys want to know and what you want to learn.
12
And so be curious and then let me know so I can try to help you out.
13
So I'm regularly seeing videos on YouTube that says Python for hackers or Python for penetration testing.
14
And in these videos, they don't actually teach you anything.
15
So my goal in this course, in this video, is for you to come out with some understanding of Python, be able to write your own for loops,
16
be able to understand variables, lists, strings, and functions, and for you to come out with the ability to write maybe your own recon tool.
17
It will take some practice
18
and maybe you're going to have to watch this video several times in order to fully grasp these concepts.
19
But my hope is that when you finish this, that you will be able to come out with a knowledge of Python, modify exploits that you find online,
20
and maybe even write your own tools.
21
All right, before we dive into this course, I want to take a second and ask you to please subscribe to my channel.
22
I have said this before, I don't get anything from doing these videos.
23
I don't get anything from putting out these courses for you.
24
My channel is not big enough and so the one thing
25
that really keeps me encouraged in making these videos is when you guys comment and when you guys subscribe to my channel.
26
So please subscribe and with that let's go ahead and jump into the course.
27
I decided to go ahead and show you guys how to install PyCharm on your Linux VM.
28
If you have a Mac or Windows, it's really straightforward.
29
You just go to the JetBrains, you download PyCharm.
30
I'll have this link in the description and you'll click Windows, Mac, or Linux, and then you'll just hit download and it will automatically start to download unless you're on Linux.
31
So I have had to do this for several virtual machines that I've had.
32
It won't download.
33
And so what you have to do is right click the direct link and you'll copy link.
34
then you will you will go to your terminal
35
and you'll run a wget wherever you want this file to be saved so
36
if you want its own pycharm folder put it in its
37
own pycharm folder for me it is in my downloads
38
and you can save it wherever you want you'll hit enter
39
this might take a little bit depending on your speed
40
that you your internet speed
41
and then you're going to unzip it wherever you downloaded it with this command right here
42
and then it will unzip a bunch of files will come out
43
and then you will be able to cd into the folder
44
so for me i will cd into my downloads
45
because that's where it is and then i'll go into pycharm
46
and then i'll ls inside here and i'll go into my bin
47
and then this is the executable i want to launch in order to launch pycharm
48
so i will type in bash and then I will type in PyCharm.sh and it will automatically launch PyCharm for me.
49
So this is how you get PyCharm on Linux.
50
If you are wanting it on your Linux, I usually write everything on my Mac and then if I need to run the code over on Linux,
51
I will pull it over to my Linux machine and run it over here.
52
So with that, we will get started in the next section.
53
All right, we are ready to start our python course
54
so we're going to start out very simply with a string a string is a
55
sentence that is a data type
56
so we're going to have several different data types coming up
57
but a string looks very simple it is what i think of as a sentence in english so you just have
58
hello world a string is always going to be stored inside of quotations
59
so if we were to print this it would print right here hello world for us
60
and if we change it it's going to change along with us
61
so this is really simply this is a string
62
and we can store strings inside variables
63
which is going to be coming up in the next section
64
but first before we go on you will see sometimes
65
that you need a string on a new line especially
66
if you're going to export something into a csv file you're going to want things on new lines
67
and at the end of your string you can type something like this and then say hello world
68
number two and then we can print this and we have hello world
69
and hello world number two and if I wanted to get rid of
70
that space I would do it this way so we have hello world
71
and hello world number two another way to go about printing this would be like this so print print
72
and then we put our quotations and we say hello
73
and then we can add this like this hello world just like
74
that and now if we were to print it we have hello world hello world number two
75
and then hello world you see there's no space right here this is something
76
that i run into regularly and I just had happened the other day.
77
There's two different ways you can put a space right here
78
and I'm gonna show you the easiest way first is just to add a space right there, rerun it and now you have a space.
79
But I think it's helpful to know more than one way to do this
80
so you can add another quotation and put a space in there and add another plus sign.
81
So you can run it this way and you still have that space
82
and it's really important to know this right here
83
because sometimes you'll be running a for loop
84
and everything is just smashed together and you want to space in there
85
and you can add spaces simply just by doing this.
86
So what I'm showing you right now, you may be thinking this is not ever going to be helpful
87
and I wouldn't be showing it to you if this wasn't helpful
88
and it's something you're going to run into in the future.
89
So this is a very streamlined course and I'm showing you just what you need to know in the world of cybersecurity.
90
Now we're going to be covering something called a variable
91
and a variable holds the place of some kind of data that we're going to want to use later.
92
So we'll go ahead and comment this out
93
and on a Mac it is command and then question mark and so we'll comment that out.
94
So now if we run our program there's no output and we're going to look at a variable.
95
So a variable can be something like this, name, and then the name Jim.
96
This name is going to hold whatever is right here.
97
So this is our variable, which is going to represent the name Jim.
98
So if we come down here and we print, and then we type in name, and then we run this,
99
it's going to print what is stored inside this variable.
100
When we look at variables, one of the things you're going to want to be able to do, especially in the world of cybersecurity, if you ever want to write your own tool,
101
is you're going to be saving variables, only they're going to be input variables.
102
So if we were to go like this and we say name equals input,
103
and then we type what is your name, and then we'll want a space right here.
104
So when we type in the prompt, it has a space.
105
we'll comment this out and then we'll print name.
106
So we're going to print the variable, whatever the user inputs here.
107
So now we can say, what is your name?
108
And we can say Tom.
109
And when we hit enter, it prints Tom.
110
And there's something else that's really cool that I use all the time.
111
It's called an F string.
112
And what you do is you add an F at the beginning of your string, but you can print variables inside your string.
113
So we'll go ahead and put name inside here.
114
And so we can say hello, and then the name.
115
So we'll say, run this.
116
What is your name?
117
Tim.
118
And it puts out hello, Tim.
119
So this is an F string.
120
This is something you're going to want to know this is something I use all the time
121
and in the next coming up videos we're going to look at data types
122
and how we can pull information out of a specific string
123
and this comes becomes really useful whenever you run a script on a victim machine or on your target machine
124
or your target server you'll you may get a lot of output that you don't really need
125
and this is a good way to start extracting data.
126
So we'll start that here in just a moment.
127
Okay, it is time to draw out some information from our string.
128
So what we can do here is we can save a variable
129
and we'll call this variable name and we can put inside of our name tommy.
130
So we have tommy here and let's say we want to grab just this m right here.
131
What we can do with this is we can say print.
132
We want to print our name
133
and then we add some square brackets just like this and when you're running python it always starts at zero.
134
So it goes zero one two And so that first M is going to be 2, just like this.
135
And so if we run this, it's going to print that M for us.
136
And just to show you, if we want to print the T, we would enter a 0 here.
137
And this is one of the most basic ways to draw out information.
138
And it's going to get a lot more complex as we go.
139
But this is what the square brackets do when you see them.
140
And when we start to tackle lists and arrays, these square brackets become a really useful tool to remember.
141
So as we continue to go through this, I want to pause right here.
142
And I want you to go ahead and play around in your own text editor and print some, make some print statements, make them on new lines,
143
add in some spaces, make some inputs and actually practice gathering information
144
and maybe have two or three inputs and have it print things back
145
and forth and you have a little conversation with your text editor.
146
So I want to go ahead
147
and give you this challenge for you to go ahead
148
and play around with the things you've learned so far and try and really ingrain this information into your mind.
149
These are the foundations of Python programming and you need to know and understand how they work.
150
You're going to notice is you can name variables whatever you want
151
and I name my variables really poorly mostly
152
because the programs I write I write for myself
153
and I am not working with a team of developers
154
but maybe you will someday and
155
when you name your variables you can name them whatever you want
156
and you'll want to make them names
157
so other people can understand what is going on so
158
if you look at some of the code I've written in
159
past videos I do this right here I name everything like this
160
and it is not really the best way to go about naming these
161
so I'll name one guy one and I'll go guy two
162
and he'll equal Bob and then I'll come down here
163
and I'll print guy two and then I run this
164
and then I have Tim and Bob you can you can name variables whatever you want.
165
Literally you can go whatever I want and you can make this a variable
166
and then you can come down here
167
and you can print whatever you want right there and you can name variables whatever you want.
168
So I would recommend getting in a good habit of making your variables something
169
that you can recognize and it's a very bad habit
170
that I have because I make my variables so that people cannot read what I have done.
171
So this is something I'm trying to get better at, but I probably won't because this is a bad habit that has formed over many years.
172
But I want you to have a good habit of naming your variables, something that you can understand and other people's can understand.
173
So as you go through and work through your challenge, try to name your variables, different things that you will be able to understand in six months after
174
you have written a program and you need to go back and edit it.
175
Okay, I have created this little challenge here for you.
176
If you want, you can go ahead and pause the video
177
and open up your text editor and see if you can create this little program right here.
178
So we want to one, create an input with a greeting.
179
So just say, hello, what is your favorite food?
180
Let them put it in and then and then take another input
181
and say what is your favorite hobby and store
182
that also in a variable
183
and then we're going to print with an f string their favorite food
184
and their hobby so if you want to give this a go you can go ahead
185
and give it a try if not we will start it now
186
so we're going to start out with create an input with a greeting So we'll just say print hello,
187
and then we're going to take an input, but we got to save it as a variable.
188
So we'll save this as food, and it's going to equal an input.
189
And we're inside the input.
190
We're going to have the question, what is your favorite food?
191
Space.
192
I see that we have a typo here on all three and then that's going to be saved as their food.
193
Then we're going to say input
194
and this is going to be we'll just save this as hobby
195
and we're going to take in input and we're going to say what is your favorite hobby?
196
Question mark space and then we're going to print with an f-string all of this together
197
and we'll say print your favorite food is
198
and then if you remember we need our f-string here
199
and we should grab our curly braces
200
and say food
201
and your favorite hobby is curly braces hobby now
202
when we run this if we did everything right it should print for us this final statement after we give these inputs.
203
So we say run and it says hello what is your favorite food
204
and we'll just say chips what is your favorite hobby running
205
and it says your favorite food is chips and your favorite hobby is running.
206
So this is a simple input form
207
and it's going to print out with our variables
208
that we have stored and this is a good practice because
209
when you write a program for a tool maybe that you develop in the future, you are going to want to know how to do inputs.
210
So that way you can take the input, save it in a variable, and then later do something with it.
211
So later on in the course, I'm going to give you a practical example of taking input and then running it in a program.
212
That is really helpful.
213
And I will cover that when we are ready for it.
214
All right, so we have covered the string so far.
215
This integer is a whole number.
216
So if we say int, we have a number of seven floats.
217
We're not really going to use these a whole lot in the world of cybersecurity.
218
They have a point within the number.
219
So 3.14 would be an example of a float to date.
220
I cannot remember a single time I have used a float in cybersecurity.
221
Usually that's more towards data science or something of that nature.
222
A boolean is true false.
223
You will want to remember boolean.
224
We'll cover these a bit in the future.
225
When we do our while loops, we'll be using the true false.
226
So these are some of the different data types.
227
And just to get an idea of what these look like,
228
if we save a variable and we make it a float and we say like one,
229
two, three, and then we print this, it will tell us what we have.
230
So we can come down here and we can say print
231
and then we can put type and then we can put in our variable
232
and when we run this it will tell us
233
that we have a float and
234
if we put in an integer it will tell us that we have an integer and then so on and so forth.
235
We can do this with an
236
and then we can also do this with a string
237
and we can hit run
238
and it tells us we have a string sometimes we will do something like this and then
239
we have this saved as a string here and then
240
when we go to add this to something else we can get an error
241
and it's because we have a string and we'll be trying to add together a string and a
242
integer and it won't work.
243
So we'll go variable two equals three.
244
And then when we say variable three equals variable one plus variable two, we're going to get an error.
245
And it's going to tell us that you can you can't add these together.
246
So this is one version of how these matter.
247
another version of this is let's say we want to print
248
and we say we have an integer right here
249
and we want to add it to a string
250
and we can go like this
251
and we say 70 what do you think is going to happen it tells us we can't add these together
252
but if we take this and we turn this into an integer, what will happen now?
253
Now it works.
254
So this is the difference.
255
So this is an integer, this is a string, unless we declare it to be an integer.
256
And you can do the same thing with floats.
257
So I'm not going to cover those.
258
And then what happens if we do this right here?
259
What do you think the output will be?
260
And the answer is 7070.
261
So this is the difference between integers and strings and how they work with numbers and data.
262
So if we wanted to, we can turn both of these into integers.
263
And this is the last example.
264
I promise I don't want to bore you with adding these together.
265
And then we say enter and we're back to 140.
266
So this is a little bit of strings, integers, and booleans.
267
And we'll kind of skip floats because I don't think really need them
268
but it's worth mentioning so you know they're here and with
269
that we will continue on with our next challenge okay
270
so we have these numbers here number one two three four five saved as num one
271
and then num two
272
and then num three what i want you to do is to write this to your console
273
or write this to your text editor
274
and then i want you to add this variable plus this variable and see what the output is.
275
And then I want you to take the second number in num1, so it would be this 2 right here,
276
and I want you to add it to the second number in num3, which is this 7.
277
So your output should be 9.
278
I want to see if you can figure that out.
279
And then the third challenge is to take num2 and change num2 into a float and print the type
280
to the console so that way the console tells us that it is a float.
281
So if you'd like to go ahead and pause
282
and give this a try you can do that now or we will go ahead and tackle this right now together.
283
So what we are going to do just first is we're just going to print
284
and we're going to say we're going to turn this into an integer
285
and we're going to go and write in num1 and then we'll add
286
this as an integer and then we will say num2
287
and this needs to be closed off
288
or we are we will get an error
289
and this should print it for us
290
so it tells us here is the total if we add those together
291
and then the second challenge is to add the second number
292
so we'll just take this just a heads up copy
293
and paste and programming is always a bad idea because
294
if I have a bug here I just now copied
295
and pasted it and I have two of them but what we're going to do is we're going to take this
296
and we're going to put in our square brackets and
297
if you remember it says zero one so we're going to say one
298
and then we're going to say one I guess I didn't really need this and then we'll print this
299
and our output is nine so now we've grabbed the second numbers
300
and then our third challenge is to change number two into a float
301
so that it prints float so what we want to do here is just say print
302
and then we're going to tell it we want a type
303
and we want to print out the type of num2 and then above that we're going to just type in num2.
304
You can do this two different ways.
305
I'm going to do it this way.
306
I'm going to say num2 equals num2 and we'll just go like this
307
and we'll type float and we'll close this off and now
308
if we print this it tells us it is a float
309
and we will continue on with our Python course in the next section.
310
Okay, we are going to do a walkthrough of if, elif, and else statements.
311
So this is the instructions for the little program I'm going to write.
312
But when I finish this program, I'm going to give you a challenge to do something similar on your own.
313
So I'm only going to give one example here
314
and you're going to need to pay attention and maybe watch this walkthrough twice and then go on and try the challenge.
315
So the first thing we're going to do is if you are under five, you are a kid.
316
So our if statement is going to first need an input from the user
317
that is going to tell us what is their age.
318
So we'll just say we have a variable
319
and we want it to be an integer and integer and we want an input.
320
and we're going to ask them, what is your age?
321
Question mark, space, and we have to have that space, otherwise it's really ugly in the terminal.
322
And then we're going to start our if statement.
323
So we're going to say, if you, this person's, their input,
324
which is their variable, is less than the age of five,
325
then we want it to print that they are a kid
326
so print you are a kid now one thing we want to do is
327
if they hit the age of five we'll need an equal sign here otherwise I'll just show you
328
if we say we'll need an else statement
329
so this doesn't air out actually we'll just let it air out we'll say what is your age
330
and they say five and we get no output because they,
331
this doesn't include five, remembering that the computer starts at zero, and then it's going to stop at four.
332
So if we want to include five in as you're as a kid, we'll need that the variable is less than or equal to a five.
333
Now, if we put the five in here, it will print for us, you are a kid.
334
So what we need to do next is we're going to type in elif
335
because we're going to make an elif statement
336
and we're going to say the variable is less than 15
337
and the reason we don't have to worry about anything under 5 is
338
because it will catch this if statement
339
and then this whole program we write after this will stop
340
and the computer will actually skip it
341
so we don't need to worry about adding anything else in here
342
and we can say actually if you are less than or equal to 15, then we are going to print,
343
you are a big kid.
344
And then for the final elif, we will say the variable,
345
and we will say if it is greater than or equal to 21, and that's ugly and we will say print
346
and we're gonna print you are a bigger kid
347
and now we're gonna put in an else statement
348
and in our else statement we're going to print anything that's over 21 we're just gonna print you are old
349
so now if we run this and we rerun the program we run it
350
and we say how old are you
351
and we say three we get your kid
352
if we say 13 we get your big kid
353
if we say 18 we see you're a bigger kid and
354
if we say you are 44 we get you are old now
355
because we're going to be using this as a tool for us to be able to write tools
356
and modify tools I'm not going to cover this because I think that it's not really necessary for cybersecurity.
357
But if somebody were to run this and they put in the letter A, it's going to crash our program because the letter A is not a number.
358
It's not an integer.
359
So what we'd have to do is we would have to make this
360
so that if they put this in and it was an A, it would print, enter a number, and then rerun.
361
But we're not going to do that because it's not really necessary for cybersecurity.
362
It's just something to be aware about.
363
Now, what's coming up is your challenge.
364
Let me delete all this and I will write up your challenge for you in the next section.
365
Your challenge here is to take the temperature from the user
366
and then tell them if it is less than 20 degrees you need boots
367
and this is from the US so I'm running in Fahrenheit not Celsius
368
and if it's less than 30 you will need a coat
369
if it's less than 70 you will need a jacket
370
if it's over 70 it is nice outside so take this input
371
or take this information and make a program with if elif
372
and else statements okay so here is how i would go about doing this i would take an input
373
and it will say what is the temp outside and this is this will need to be an integer
374
because we're going to be comparing this as a number.
375
So we'll say if var is less than 20,
376
then we're going to print, and you need boots. and we'll say elif
377
bar is less than 30 print you need a coat
378
and then we're going to use one more
379
elif here elif
380
var is less than 70
381
print you need a jacket
382
and then finally we'll do else and it's above 70 then it's nice out
383
and we don't actually need to put anything in there
384
because this is an else statement
385
so everything that's above 70 will automatically print it is nice outside
386
so when we run this if we put 12 we need boots if it's 22 we need a coat
387
and if it is 65 we need a jacket and
388
if it's 85 in my opinion it's perfect outside
389
so this is the if and elif
390
and the else statements we're going to be moving into for loops
391
and later we're going to look at nested if statements
392
and they'll look something like this if it's less than 20 and then And we can say if it is,
393
if var is less than, we'll say it's actually, it's greater than 25.
394
Then we can print you need boots.
395
And then we'll print something like gloves.
396
So nested if statements look something like this.
397
and you can have nested if statements just so you're aware of it.
398
So if we say it's 26, it will, oh, because we're hitting this one,
399
we'll hit, we'll say this is 15.
400
So if we say that the temperature is 16, we hit you need gloves and you will need boots.
401
so this is a nested
402
if statement we'll cover these a little more in the future
403
i don't know how much you will need these nested
404
if statements i use them every now and then
405
so it's nice to know that you can run nested if statements
406
but for now we're going to move on to our for
407
loops before we get into for loops too far i want to show you why for loops are important
408
and i also want to show you why lists are important
409
which we're going to be going over here in just a
410
minute after we get the basic understanding of a for loop so this is a program i've shown it before
411
it don't worry about what it looks like it looks kind of complicated
412
but it's really not what happens is you put in a repo
413
that you would like to target on github to go and search for all of the usernames,
414
passwords, and files that just shouldn't be made to the public.
415
So in this case, it's looking for pass for passwords on GitHub.
416
But what we have down here is a for loop.
417
So this for loop right here, we have an empty list, which we're going to cover in a second.
418
And it goes out to GitHub right here, and it will go through all these links
419
everything you can click on
420
and it's going to narrow it all the way down to the repositories
421
and it will click this link
422
and then it will click to it'll click the file
423
and then it will click the raw then it copies this entire thing
424
and it puts it into a text it puts it into a csv file
425
and then checks for the word password so that's the program itself
426
but what's important to remember is what happens is it goes out
427
and it pulls all the links and puts them in a list.
428
Then it goes through this for loop and it takes all of these
429
and it says for every one of these items that is inside of the links, which is actually this variable that I have up top,
430
it's going to do something.
431
So for loops are very important.
432
You can see I have another one right here.
433
So for loops, we are going to need them.
434
Lists, you are going to need them as well.
435
And I just wanted to show you this
436
because sometimes what happens is you'll be going through trying to learn something
437
and I'm showing you something very elementary and you are like, why do I need to know a program that tells me to put on a jacket?
438
This is all building up to something
439
that is going to be able to help you build tools
440
and more specifically if you're new just be able to read through exploits
441
and be able to edit them
442
because you're going to need to know how to read python
443
and edit exploits as you grow in the world of cyber security
444
so here is a very basic for loop
445
and i'm going to show you it in a string because we've already covered strings
446
and what this all this does is we have our variable string right here that is holding
447
hello world and so the way the for loop works is it says for i in string
448
so this i right here is going to be another variable
449
that holds one letter each time the for loop runs this i is going to represent one letter
450
and in a list it's going to represent each item in the list
451
so this will run i'm gonna run it
452
so you can see what this looks like the way it runs is it goes for i in string
453
so it's going to grab the first letter
454
which is going to be the h and then it prints it
455
but the for loop is not over so it runs the loop again
456
and it'll grab the e and it'll print just the e on a new line
457
and then it goes through
458
and it runs every single time until it is out of things to run and then it closes the loop.
459
So this is how for loops work.
460
I'd like for you to go ahead and write out your own for loop
461
and maybe put something different in here and try to get an understanding of how it works.
462
And if we wanted this to print all of this together,
463
you would have to store this into a new variable and then print it outside the for loop down here like this.
464
and this is where we would print our new variable
465
and we're going to cover this in lists because this is something
466
that you will need to do in the future
467
so go ahead play around with the for loop write one get an understanding of how it works
468
if this doesn't make sense re-watch it
469
and hopefully it makes sense i know after teaching for loops to several different students
470
that for loops sometimes can be hard to understand
471
but they are really useful and something you need to learn
472
so we're going to be covering lists in the next section we're going to be looking at lists
473
and a list is something that is going to be useful
474
because we're going to be appending to lists all the time within our for loops
475
so a list can look like this my list equals square bracket and lists always go inside
476
of square brackets and we can say item 1
477
and then comma item 2 and then we can do an item 3
478
so we have our list here and
479
if we want to run a for loop through this list
480
we will say for I in in my list print i
481
and now if we run this it will run item one item two item three
482
so this is a list we will be using these in the coming lessons
483
and they will be helpful for you in the future as
484
you've seen in this program I have two lists right here and they are used regularly to append to.
485
So lists is something you will need to know.
486
So go ahead, make your own list and see
487
if you can loop through your list and maybe try and just print something like this later.
488
Just print the item two.
489
So you'll have item one, two, three, and then print number two and see if you can remember how to do that.
490
If you have forgotten, it would look something like this.
491
Print, and then we can say my list, and then we can put this in square brackets, and we'd say zero, one, and then we have a one,
492
and now we could print this, and we have one, two, three, two.
493
So that is going to be it for the list.
494
We're going to move on, and we're going to start using lists in a more comprehensive manner.
495
so we're going to try a while loop now
496
and the way we're going to do a
497
while loop is by using a boolean i like to set a variable
498
and then set it to true and then at the end of the
499
while loop i will set it to false
500
so the way this works is make a variable
501
and we'll just say variable actually we'll name it on that's a good way to name the variable
502
and we'll say on equals
503
true and then we'll say while on and we'll make a variable
504
and we'll just call it variable because I don't know what to name it
505
and we will take an input and we will say continue running while loop
506
and then we will put y we'll put a y
507
or a no so would you like the while loop to continue yes
508
or no and then we can say
509
that we can go do something like this
510
and then we can set a variable up here
511
and say i equals zero just so you can see how many times this is running
512
and then we'll say i plus equals one
513
and then this should just continue to run and then we'll put an
514
if statement say if the variable equals equals in then we'll say that on equals
515
false and this will kill our for loop so now
516
if we run this it'll say would you continue continue running the
517
while loop and we will say yes yes yes and then
518
when we say no it'll kill the
519
while loop I forgot to print I forgot to print our I
520
so that we could see this so now we can say
521
would you like to continue yes yes and you can see our variable every time the I the for loop runs
522
our I gets added to one
523
so our for loop has run now it says seven times eight times nine 10
524
and then when we're done we can say no and we can end it.
525
We are going to be starting functions
526
and just to be clear I have not pre-written any of the code we're about to go over
527
or mostly anything we've gone through in this course.
528
That's why you've seen me make mistakes and
529
so as we start functions i'm going to try
530
and make this a little more realistic for us so that
531
when we are thinking through functions
532
and writing code in the realm of cyber in the realm
533
of cyber security you can start to get an idea of how this can be used
534
so we're going to start with functions
535
and a function just calls something very specific that we want to happen
536
so we can just say we'll call it my function
537
and then the way your function is going to start is with a def my function
538
and then we close it off like this
539
and then down here we want our function to do something very specific
540
so we can say print and then we can say it worked
541
and the way a function gets called is usually somewhere further down inside the code something happens
542
and it triggers this function back up above it for it to actually do something
543
so what would happen in order to call this is we would just say my function now
544
when we run this
545
when the computer reaches this right here this closing bracket right
546
here I usually like to think of this as the call sign for the function.
547
So if we run this, it's going to print it worked.
548
And this will become more clear as we write more of these.
549
But this is the basic concept of functions.
550
And one thing we can do with functions is we can pass through variables.
551
So we can say something along the lines of I.
552
And then we can say I.
553
We'll make it a different variable we'll say variable equals i plus three
554
and then we can say print
555
and then we can say we want to print our variable
556
and so in our function we can pass information through like this
557
so when we say my function we can now say input
558
and then we can say what would you like to add and
559
because this is a string we're going to need to make this into an integer i guess we can go
560
and make it an integer right here and we can say int
561
and then we can close this off now
562
when we run this it's going to ask us what would we like to add
563
and we can say three enter and it'll say three plus three equals six
564
so this is a very basic function
565
so we take some kind of input right here this is where we call our function
566
so now this function is being triggered
567
but we want to pass something into our function some kind of variable
568
or some kind of information that we've grabbed somewhere else
569
and what happens is it can now use this inside the
570
function this you may be thinking like in what case would I possibly ever need to use this
571
and so I'm going to just show you my github dumpster diving tool once again
572
that I've used multiple times on this channel this right here where it's grabbed a repo.
573
I call this function and it's going to loop through to see every single file inside of the repo.
574
Is it a Python file?
575
Is it a JavaScript file?
576
Is it an XML file?
577
And what happens is when I pass this repo through,
578
it now is able to use this variable that has come from somewhere else inside this function.
579
And then I do the same thing up here.
580
I pass through a variable inside of a function.
581
So this is really important to know and you will use it.
582
And we're going to go ahead and give another example.
583
And actually, before we give another example, I want you to try and write your own function and see if you can get it to take an input.
584
So let's take the input and make it the first letter of your name.
585
So I'll write out the instructions.
586
You want the, we'll say first letter of your name and you want to take this as an input
587
so we'll say input and then you want to call a function
588
that adds your first letter to the rest of your name.
589
So here's your instructions.
590
You're going to make a function and then it's going to take a variable
591
and that variable is going to be the first letter of your name
592
and then you're going to add that to the rest of your name.
593
So I hope this makes sense and I'll go ahead and walk you through what this would look like.
594
So we'll go def my function
595
and then we are going to call this function we're going to pass through let's use i as our variable
596
so that stops giving us whenever this is giving us an error
597
and i can't stand looking at it i type in pass
598
and that will not give us the error and we'll come back
599
and delete that in a second and we're going to call my function
600
and we're going to take another input and we're going to say what is the first
601
letter of your name question mark now we can delete this
602
and we're going to come back up here
603
and we're going to use this and we're going to say
604
that my function and we're going to take this input
605
and it's going to be a pass through as i and so down here we're just going to say
606
my first name is Ryan, so we will say I, we'll call it the variable equals I plus,
607
and then we can put the rest of this inside of a string, and we can say something like this,
608
and then we can print our variable.
609
So when we run this, if I put an R in here, it'll print out my name
610
so I hope you're able to figure this out maybe try
611
to come up with another way to write a function
612
and practice writing functions and see if you can get the hang of it
613
and in the next section we're going to go over something
614
that will show you how this can be really helpful in
615
building your own tool okay I hope you have played around with functions
616
and you are now ready to try and become a little more advanced and we're going to try and
617
gear it towards cybersecurity now and I hope you're familiar with maybe the in map scan
618
and some other tools so we'll just use an in map scan right now
619
and we'll just say like we're going to call a function
620
and we'll call it in map and this is going to take a variable
621
and we'll actually call it the IP
622
because we're going to take an IP address and the way I like to run my in map scans is with the,
623
they'll look something like this, in map dash a like this,
624
and then we're going to pass in the IP address, and then I like it to be verbose.
625
Now, in order to get this to run, we would have to import a module called OS, but we're not ready for that.
626
So, this is just to show you how the functions will work
627
and so I will wrap this entire thing inside of curly braces I got dashes in here
628
that shouldn't be there I don't know why I did that
629
and then we'll wrap this inside curly braces this is not supposed to be inside curly braces
630
that is supposed to be inside of quotes we'll make this in f string
631
and we'll say our variable equals instead this would be an os command
632
if we were actually going to run this in our linux machine
633
or windows whatever you choose to use as your hacking vm
634
and now what we do is we'd come down here
635
and we would say something like in map to call our function
636
and then we're going to take an input and we're going to say what ip would you like to scan
637
and then right here we are going to print running in map scan against and
638
then we will put in the IP address
639
and this will need to be an f string
640
so the way this sorry that will not be the IP
641
that will be against the variable so it will tell us
642
that it is running the in map scan right here okay
643
so when we run this we can say what's who would we like to scan against
644
and we'd say 192.168 point something point something else then we run this it'll print running in map scan against
645
and then it gives us the output right here
646
so this would be a way that
647
if you were trying to write your own tool to automate
648
your recon this would be one of those ways you would use a function in order to automate your recon
649
and there's a lot more you can do with this ip address
650
and you could pass it into multiple different tools
651
and then you have written your own tool
652
so this is how we can use functions in cyber security
653
that are really helpful for us and And whenever you're going for a certification, it'll be really helpful for you to be able to read through functions and maybe modify them,
654
especially in exploits because vulnerabilities and exploits change over time.
655
And you will need to be able to change
656
and modify different exploits that you come across on Google in order to gain access to a machine.
657
Before we end this course, I want to give you a little bit of an introduction into making your own tools.
658
And then I want to challenge you to add to this recon tool that I'm about to show you.
659
And you can start to build your own tool for recon.
660
And it'll help you remember the Python code that we've gone over so far in this course.
661
So I've gone ahead and connected to Hack the Box and launched the Box Devel.
662
Devel and so I want to just show you what OS system does
663
so we'll import OS system you've seen this before
664
and this is just our operating system it just means we're
665
going to be able to tell our Linux machine to carry
666
out commands the exact same way you would inside of a terminal
667
so we're going to make a function and we're going to call it recon
668
and we're going to pass through an IP address really
669
if you remember this is just a variable
670
that we're going to be passing through into the function
671
and then we're going to call our function down here
672
and we'll just call it recon and then we're going to ask for an input
673
and then we're going to say what ip would you like to scan
674
and then we'll put a question mark and a space there so that way it's not all smashed together.
675
Now inside of here what we can do to make this program run our recon
676
and automate it for us is we can type os system
677
and then we can put in here we're going to make this an f string what we want to do.
678
So we're going to run an in map scan
679
and we're going to run it on all port
680
or we're going want all outputs we're going to run it on all ports
681
and just in case it is blocking the ping we'll put the p
682
and you don't have to put this in here it's optional
683
and then we are going to put in the ip address
684
that we run through and i really like to run everything as verbose so this
685
when we run this you'll be able to see it'll say what ip would you like to scan
686
and i'll put in the ip address
687
and it will now start the scan for us
688
so this is the same thing we would see inside the
689
terminal we're going to see port 80 port 21 is open
690
and at the end of the scan it will tell us everything
691
that has happened on this scan now you can add to
692
this we'll stop this you can add to this same scan
693
when it gets done running the in map scan you can come down here and maybe you want to
694
look for different directories and so you could go os dot system and we're going to make an f string
695
and we can add in maybe we want it to run derb
696
and we want it to run on the same ip address
697
that we've already passed in
698
and it will now launch this right here as soon as it gets done with in map
699
and the cool thing about this is
700
if you have your own recon tool set up you can go ahead
701
and run the program send over the ip address
702
and then you can leave and it will automatically run your recon or maybe
703
while your recon tool is running you can do other more manual enumeration maybe it has port 80 open
704
and you see that real quick with the in map scan
705
and you want to start looking at what's on port 80
706
and it will run your in map scan it will run your durbuster for you
707
and maybe you want to run wfuzz
708
or maybe you want to run sublister i want you to go ahead
709
and start off with what i have given you right here
710
and you can add to this tool with the information that you have learned so far

परिस्थिति

जब आप साइबर सुरक्षा में रुचि रखते हैं, तो एक बहुत ही सामान्य सवाल यह होता है कि आपको किस प्रकार की प्रोग्रामिंग सीखने की जरूरत है। इस वीडियो में, एक ऐसे शुरुआती पाठ्यक्रम का परिचय दिया गया है, जो साइबर सुरक्षा के लिए आवश्यक पाइथन प्रोग्रामिंग पर केंद्रित है। यह ऐसा पाठ्यक्रम है जिसे देखकर आप पाइथन के बुनियादी पहलुओं को समझ सकते हैं और अपने खुद के टूल बनाने की क्षमता विकसित कर सकते हैं।

उपयोगी शब्द समूह और गठजोड़

  • पाइथन प्रोग्रामिंग: साइबर सुरक्षा में महत्वपूर्ण कौशल।
  • वेरिएबल, लिस्ट और स्ट्रिंग: प्रोग्रामिंग की बुनियादी संरचनाएं।
  • फॉर लूप्स: स्वचालित संचालन के लिए उपयोगी।
  • रिकॉन टूल: नेटवर्क की जानकारी इकट्ठा करने के लिए।
  • टर्मिनल कमांड: लिनक्स सिस्टम में कार्य करने का तरीका।

आपकी शैडोइंग चुनौती

अब, आइए एक छोटा सा कार्य करें। वीडियो में प्रस्तुत संवाद को ध्यान से सुनें और उसके बाद इस संवाद को अपनी आवाज में दोहराने का प्रयास करें। इसे अंग्रेजी शैडोइंग के रूप में देखें। यह न केवल आपकी उच्चारण क्षमता को सुधारने में मदद करेगा, बल्कि आपके आत्मविश्वास को भी बढ़ाएगा। आप निम्नलिखित वाक्यांशों का उपयोग कर सकते हैं:

  • “पाइथन से संबंधित प्रश्न पूछें।”
  • “कोड को संशोधित करने की क्षमता।”
  • “वीडियो के विभिन्न हिस्सों को कई बार देखें।”

इस प्रक्रिया में नियमितता बनाए रखें और आप निश्चित रूप से अपनी अंग्रेजी बोलने की क्षमता में सुधार करेंगे। इस तकनीक को shadowspeaks के रूप में जाना जाता है और इसे अपनाने से आपकी संवाद क्षमता में महत्वपूर्ण बढ़ोतरी होगी।

शैडोइंग तकनीक क्या है?

शैडोइंग (Shadowing) एक विज्ञान-समर्थित भाषा सीखने की तकनीक है जो मूल रूप से पेशेवर दुभाषिया प्रशिक्षण के लिए विकसित की गई थी। विधि सरल लेकिन शक्तिशाली है: आप मूल अंग्रेज़ी ऑडियो सुनते हैं और तुरंत इसे ज़ोर से दोहराते हैं — जैसे वक्ता की छाया 1-2 सेकंड की देरी से। शोध से पता चलता है कि यह उच्चारण सटीकता, स्वर, लय, जुड़ी हुई ध्वनियाँ, सुनने की समझ और बोलने की प्रवाहशीलता में काफ़ी सुधार करता है।

शैडोइंग तकनीक: पूरी चरण-दर-चरण गाइड पढ़ें →