OK, Senator, we did bash let's go over Python basics, so Python is one of the most utilized scripting
languages in that community, if not the most utilized.
This is due to its simplicity and power because it's pretty much like almost like English kind of it's
a little bit easier than the Bashkim thing is.
And it's very, very powerful.
You can literally do anything that you could imagine with Python.
So it's very easy to pick up and it's going to drastically help you with your acting career, any career
that you have in cybersecurity generally, because Python is used typically, you know, to automate
processes, you know, in gigantic enterprises.
And it's very, very valuable to know Python.
So we're going to go over the basics.
And since, you know, a majority of the experts that you're going to see are written in Python, being
able to read it and, you know, know what's going on and how to modify it, it's going to be key.
There are some basic Python syntax.
So Python scripts in Lennix start similarly to the bad ones, except this time is going to say user
in Python.
That's going to tell the system to interpret this as a python script when it runs.
So if you want to declare a variable here, which is variable name equals value, when X is variable,
you just type the variable name.
If you want to print something out on the screen.
So he's an echo.
In this case, we would use print and then we would put the parentheses signs and whatever text that
we want to put inside of it.
OK, so let's talk about creating functions in Python.
So if you want to create a function, you start with def and then the function name with the provinces
and then colon, and you would then start defining your function.
And if you want to call the function in Python, you need a function name followed by two parentheses
and of all the function.
So if you want to create a function that actually takes in an argument, you would just do the naming
of function and you will put the argument right there inside of the parentheses you would use that you
would access that variable, you know, with the ARG one variable in this case because it was passed
in in parentheses.
And then as you pass on those parentheses, you would be able to use inside of that function.
So, yeah, this just prints out.
So this one principle, you know, you passed in and whatever the argument is right there.
So all this function from the command line would probably look like function, the function name, and
then you have the in parentheses and inside the quality will put my name.
And that would be the argument that you passed in.
So let's actually go and try this out.
OK, so I'm going to do a new file.
So the python peepy function.
There we go.
So let's start with our command.
So is countersign at some point as viewers are so experienced, Python so now knows that this is a Python
script.
So A.F. and then our function name, let's say it is to you, just name, keep it simple and then our
colon and then we're going to start to make our function.
So it would just, you know, if we wanted to print something out, so.
My name is Anthony.
There you go.
So that's the function right there.
So then I would be able to call the function like this, you know, right away.
So now we can do C.H. Mod plus X PI function and now we do dogpile function and say, my name is Anthony
there.
We created a simple function.
OK, so let's say that we wanted to pass something into dysfunction.
So we'll go up here and in parentheses, input, maybe name and we would take our name right here where
we have it right now and we do plus name and then less.
When we call the function we would actually, you know, probably want.
So this Anthony.
So now, right now, let's try to run it.
That's slash PI function.
My name is Anthony.
There we go.
So now we passed a function and we passed in something into Python.
OK, so if you want to capture user input in Python, you would just set it up like a variable.
So the variable name right here is user input.
And then that method from Python is input, parentheses and then input is what is going to print out
on the screen and wait for you to actually type in your input.
And you can print this by printing the variable with the print command.
That would be a lowercase period there as well.
So now let's actually go over and try to do this, started new files of the PI input.
So we're going to insert our common user in Python.
So now that's a user's keyboard like it was in their user input equals input.
I say insert your age and make sure we have parentheses around that and let's make sure that we spell
input.
Right.
And then we're going to print.
User input.
There we go.
So I was very quick siege mod.
Plus x pi and put Bam that slash PI input and see your age.
Ask me how old I am.
Let's say I'm 28 because I am.
Yeah now I'm 28.
So now we know how to cash and put it in, print it out.
OK, so just like Bashour and give you an example of a conditional statement in Python as well, similar
to the other one.
So in Python, this is how you would type this.
You would say, you know, if for example, five is greater than 10, you print out, five is greater
than 10 in text or else print five is less than 10.
So in that case, is it five is not greater than 10.
You're going to print out five is less than ten, which makes sense because five is less than ten.
So this is otherwise a little bit simpler when it comes to, you know, making the conditional statement.
So you kind of seeing that python is very simplistic in a way.
So now let's talk about for loops.
So this is another iterate through maybe lists of different things.
So like for this example, right here, we have a list right here called Fruits.
We have apple and a banana and then cherry.
So if we want to access all those values inside of that list, we would say for X in fruits colon and
then we're printing X.
So X in this case is, you know, each individual, one of those.
So for each individual thing inside this list, inside the fruits list, we're going to print it out
on the screen.
There's another way that you can use for loops as you print out every letter in a string.
So right here in this next one, we have four X in and then parentheses my string.
So it'll take each one of those characters, including the space, and print it out on the screen.
OK, so one thing that you're going to notice, Python is used for a lot.
You're going to be noticing that you're like some of the experts that you're looking at, they're going
to be connecting to, you know, something called sockets.
And this is just simply creating, you know, connections over specific ports.
Think back to our networking section, to another computer using Python.
It's very important, understand, because, you know, it's going to allow you to quickly connect to
ports on the go or be able to understand and explain changes.
You know, if you need to like you need change porridge, change something, maybe some syntax is wrong.
We'll do it.
So here's an example, Python script for, you know, connect to a port.
So you see our recommended top.
So then we have import socket and then we have IP as a variable and then it says more input.
So let's say that actually to put the IP address.
So it takes it as more input and then you have the port which you taken as input into port in.
And this is also a user captured input.
And then we have another variable that's going to be this is the line at the nexus to the port.
So socket socket.
And then these commands right in here is going to allow you to connect to a socket.
So the way that we would actually make this connection is using the stamey.
So if s that connect underscore X and then you put those two variables in there, the IP in the port,
then we will present, you know, port and then say that that port is actually close.
So this is a way to check to see if you can actually get to this port.
If you can get to it, then I would say that it was open.
But in this case, you know, if you can't get to it, it would say that it's closed.
So that's like a basic overview of, you know, how you would actually connect to, like different ports
if you wanted to, like, you know, maybe do like a manual port scan, which you will probably never
want to do.
But if you wanted to do something like that, you know, you will be able to check to see if a port
is open.
If you want to check on a fly, you can have this script handy and you could check that.
OK, so you kind of already see me do this and I've kind of already gone over it.
But, you know, if you want to just go over really quickly individually, if you want to execute any
script the same as a file, you're going to want to go to, you know, the directors and it's time to
send in the script name and then just hit enter.
And you're going to be good to go.
See, you've already seen me do that many times.
And if you're going along with me, you've probably known as well.
So you know how to write and execute scripts now.
So we've got all of the bases and Linux bash in Python.
So what's next?
So now that we, you know, have some of those important, you know, scripting basics down and the
bases down, we're going to quickly go over how you can maintain your privacy in a nice and safe so
no one can really be watching.
You know, we're going to go over, you know, some applications and techniques that you can use to
remain anonymous and safe on the web.
So.
I appreciate you for watching his lecture and I will see you guys in the next segment.