Hello everybody and welcome back.
And right now let us see what we need to specify in this launch thread function.
In order for it to actually launch our threats for us.
So right now what we will actually do is first of all make up def launch under threat.
So let us do that.
First you enter make def launcher underscore threat.
We need to pass the passwords.
The age for threats.
User name for user names and your URL for you or else.
Now these are not as is as you know from before.
These are not really variables.
These are just some of the names that I would use in order to specify what actually goes to these function.
What does go to the function is we specified in the previous video and it is right here.
We basically passed these four things to our function which is the 14th three coded in our options.
So right now in order for us to actually keep a track of our threats let us make a variable called i.
It will be a global variable since you also use it outside of our loop.
Now our variable will be a list.
So we need to specify that to be with the square brackets right here.
So make sure to specify equals and then not the normal bracket.
But the square brackets and we want to append two dead file zero which is what this will do is if you
know what append function does we covered it up so we can just find it what append function does it
basically appends a certain string or something or a number to the end of the list.
Now since our list is empty for now on it will only append the zero to our list.
So right now let us use the while loop to actually see how many passwords we have in our lists.
So in order to do that we know from the previous video that we said passwords to be to read lines from
our file that we specify in the command.
And right now we want to read those passports for as long as they exist for example to the end of the
file.
We can do that with these simple commands.
So while line passwords this basically means it will read all of the passwords for the basically until
it reaches the end of the password list.
And now let's actually set a variable that will actually specify whether we got the password right or
we got the password wrong.
So how do we do that.
Well first of all we need to create our global variable.
We can call it however we want.
Let's call it hit for us.
So it means when it's hit it means we said we found the password.
So global hit and we will set hits to be equal to 1.
Now don't set it to be equal to 1 as our number set it to be equal to 1 As String.
So go back to your function down here and basically all we want to do right now in our while True loop
or not while true while length of the password is globe we want to first of all check if hit equals
to the one.
So if we check that if it does equal to one that means we didn't find the password since basically if
we will set the hit to be equal to zero.
Once we actually hit the password that we actually can log in to our page so what will what we will
do right now is we will actually check out if the number of threads is about the thread specified in
the launcher functions.
So for example let's say a user specifies the threads to be five and we only have three threads in our
function or something like that.
We want to check out that as well but we want to do that we try and accept rule since we can always
hear the keyboard interrupt the same as we coded right here in order to stop the program.
So how can we check if the current number of threads in our ie variable that we specify for our threads
is smaller or bigger than the thread specified from the user with the threads option so we can do that
if I zero in our brackets is smaller than T H.
Now why do we use T H.
We use it because the h is what we specified in our def launch thread options.
So if I is smaller than D.H. who want to type here something function called Pop Tarts WD is the variable
that will put the password dot pop in so where you remember in the basic Python we learned what Pop
function does.
So basically it is used for lists as our passwords variable is actually not a variable it is actually
a list that contains all the passwords in red the line by line.
So what we need to do is equal passwords not pop and then specify zero right here.
So the next thing we want to do is if it is smaller than t h as we specified right here loops first
of all we need to tap this in order to belong to the if loop.
We need to add another thread to this to this basically lists called by.
So let us do that we can do that like this.
So I 0 0 which is the first element of our lists equals I of 0 plus 1 so this I have 0 I need to remind
you is basically referring to the first element of the list itself and all we have to do right now is
actually create a thread on a function or basically thread on our class the predetermined code yet which
will actually run did attack itself.
So how we will call that that class will be request performer.
So we will run a thread we'll just call the variable to be threat equals request underscore performer
and index in that thread or basically we need to pass in that class the password username and the you
are out so we will call the class itself the next video.
But for now that is just past the past WD the user name and the.
You are out for our request performer class and all we have to do after that is something that we are
familiar with is start the thread itself and since we called it the triangle we need to add the accept
rule as well and we need to join the threads at the end of this.
So we will just type here except keyboard interrupt for the keyboard interrupt and we will just print
as usual interrupted.
So we need two exclamation marks.
Just print here interrupted Whoops.
So after that we closed the program with this exit and we have two threads that join in order for our
friends to join.
At the end of this function.
So right now what we are left to do is actually code the class itself in our program and we will do
that in the next video.
And after that we will actually test our program to see if it actually works.
So let's see what we actually need for now.
We made the function that will actually create all of these arguments that we specified with this command
right here.
So with this command right here then it calls the launch of threads and those arguments which will actually
check out the number of threads running and then it will call the thread to start on the class the tool
code in the next video.
Now we will pass the arguments of password username and you are out.
So that is what we coded for now.
It might be a little bit hard to understand at the beginning but you should be good to go once we finish
this.
You will understand this fully.
So that will be about it from this video.
I hope you enjoyed it and I hope I see you in the next one.
My.