Hello everybody and welcome back.
And in the previous video we called the launcher threat functions function pardon me which actually
checks out the number of threads running.
And it also starts a thread on our class request performer which we need to actually call right now.
Now that class will take an argument of threat and we need to code the part of the code in that class
which will actually run the attack itself.
So we will do that up here so let us call coded right here.
We will call it class request performer.
And it will take the input of threat.
So basically it will take an option is threat make sure to call it the same as you call it right here.
So request performer makes needs to be the same name as it is right here.
So all we have to do right now as is the every class we actually code we need to set the function in
it which will specify the variables that we will use in this class.
They all need to have the prefix of self dot and then the name of the variable.
So let us see how we can do that.
So Def underscore underscore and it underscore underscore and here we pass the self argument as in the
every class and we need to specify the three arguments that we actually passed in our request to perform
a class which is name user and you are out after that.
In this function we need to initiate all of these variables.
So first of all we will do the threat to be red dot in it since that is the argument that the class
takes itself into port.
Do yourself in the brackets right here.
So this is a little bit of new syntax for you but you will get used to it.
The one that we do know is the self that password.
We need to set that to be named split groups since name actually corresponds to the password and the
user is using them to specify.
Now you might be asking why are we using the name that split option.
Well basically the password that we actually read for from our file.
They all have the slash and at the end of there weren't.
Now discretion in programming language actually represents on your line.
So we need to actually speak to our password or our text or string or however you want to call it from
that character minus our slash n which represents a new line so we can do that with the DOT split option
and then we can just open up the brackets and in the double quotes type here slash or backslash and
then close the double quotes.
And in order for our program to actually know which part of the split we want to use whether the first
or second one we need to specify the first one which we can specify with the open square brackets zero
since once just plead the.
Let me just show you right here how that would look like.
So basically you have a password called test and then since it is having on your line it has the characters
backslash and we did the splits so we split these two and we want to select to use the first part which
is part right here.
And since we know that counting in programming starts you know we specify here test which is basically
representing these 0 right here.
So let me just delete this now.
So our program can actually run.
And right now since we initiated the password what to be.
Now we need to initiate the user name so self that user name will just be user which is specified right
here and also the cell that your health will be you are URL and then let's print the actual the actual
password that we are using currently.
So let us do this with the dash and plus s the password for example and then plus dash.
So right now we go to the init function in our class which is basically hosting or having our variables
right here.
And what we want to do is finally call the Ron function which will actually run the attack itself on
our on our target.
So how can we do that.
We can actually name a function.
Make sure that that function actually belongs to this class right here since we will actually use the
variables from here in that class if you code the function to be right here it will not belong to that
class and we will not be able to run our program.
So that run and run will take self as an argument since it belongs to our class.
And basically we need to add the global hit variable that we coded in the previous videos.
Now the reason why we need to add it is because of right now we'll check if the global heat is equal
to zero to 0 or 1 if it's equal to 1.
Basically that means the past 14 and fork if we get the state's code of 200 for our program which means
we actually successfully loaded and logged into a page we will set him to be zero and then it will terminate
our program so let me show you what I mean by that in case you don't understand it the US remove this
selection right here.
We need to select that we use the global hit comment.
Pardon me.
Variable and we need to check as usual if kids equals equals to one.
So right now we will actually run our program itself.
As I said we need to use the requests library since it allows us to send the packet with the user name
and password too.
And we do basic authentication with just one line.
So right here we want to run the try and accept option as in every every other basically command that
we use or a function that we use.
And right here we will need to code our request so let's name our request to be just are and we use
the library requests and we use dot get.
Now why do we use that get.
Well basically if you remember from our purpose of inspecting all of our basic authentication we were
sending a get request while sending the basic authentication with user name and password.
That's why we here also need to use get the option.
So in the get option we need to specify basically two things or three things.
Technically we need to specify the euro to which we are sending the packet.
And we also need to specify the authentication which will actually have the user name and password in
brackets.
So how do we do that.
Well simply just type here.
The first argument or option to be self not you are.
We use the self remember that we use the self because we are still in the class and then we need to
specify the authentication.
So authentication right here which will actually equal two open brackets and then sell the user name
and also sell the password.
Then we closed two brackets since we have two brackets open.
So all we have to specify is this and we can send or we can actually check if the packet has received
are status code of 200 with which means we actually successfully load the page or it didn't.
So we will run a simply false command so if our DOT status code which is a function in the request library
that allows us to check the status code of a get request and if it equals equals to two 200.
That means that the password is correct and that we actually guessed the password.
So what we need to do is specify here shift to be zero so we can actually terminate our code as you
remember in this part right here in the launch thread function.
We were also checking if heat equals equals to 1.
Now if heat equals equals zero this will not actually.
This will not actually run anymore so all we have to do right now is actually go back up.
Let me just go and find where we stopped.
So it is right here.
So if heat equals equals to zero we found passwords.
So that's what we want to actually print shops.
Now we actually if our state's code because the 200 we set the heat to be equal to zero and we want
to print the password so print
plus password found and then let's set that password to be basically the let's add the strength to it
which would be the strength of our password that we use for this current iteration of this loop.
So sell that password.
This means we found successfully the password and all we want to do right now is actually say start
exits.
So actually the program else so else the in case our state's code isn't 200.
We want to run the else and we actually want to print the or let's do it like this
we can get this lost cell phone password plus is is not valid.
So this would basically print these two nation marks.
Need to add our current password and a footprint add.
Also after the password is not valid so after we'd check that the password is invalid what we want to
do is actually remove the thread from the counter and our counter is basically get the variable that
we specify in the launcher function.
So how can we do that.
We can do it simply with this.
So zero equals I of zero minus one.
The same that we specified here to adding to the counter which was plus 1.
We need to now remove it from the counter which minus one and here in the after we try this we need
to take an exception which we can do exception and then comma E and then we can actually print that
that or in case that that or shows up.
So basically this is it for this program.
This should actually work I believe in the next video we will test the program itself and then we will
actually add something else as a help option in order to print to the user our available options.
So hope you enjoyed this video.
I hope I see you in the next one where we will be testing this program.
And take care.
But.