Hello everybody.
And welcome back to our broad forcing basic authentication part right now.
We coded a simple banner we imported the functions and the libraries that we will need.
And we also made a simple name equals main part of the program that will run our first function.
Now what we want to do is we want to make this start function actually run all the other functions.
So we will code everything important in this Start function.
Then after that we need to also make a function that will actually launch our threads.
Basically since we'll will be using threads to perform this and then we will need to make a function
which will actually check if our if our actual authentication was successful or not.
Basically what that means is if we actually got the password right or we didn't.
So let us see how we can do that.
Now the first thing that we actually want to do in our staff function is a simple banner printing.
So we want to print the banner first that every running of this and what we want to do is basically
first of all count how many arguments we actually want to have.
So what do we want to have we want to have the argument where we will specify the user name who want
to argue to have the argument for specify the password.
We want to have the argument where we will specify the.
You are out to the website that we are trying to brute force in our case we will test on my router.
Make sure to test on the website that you have permission to test on.
And also we want to specify the basically the threats option.
How many threats we actually want to run so let us see how we can do that.
Basically let us try something like this.
So we will run the try and acceptable right here.
So try and we will use the get up the library that we imported so we will use two variables to store
this.
So ops and arguments equal get opt out get opt and then are we might come up and then between the double
quotes what we want to specify is basically the letters that we will use for our arguments.
So for example let's for the user use you we for the euro let's load W for The File which we need to
store our passports so we need to make an option where we will actually pick a file for our password
list.
Let's use the F option so f for file and the four threads.
So what our program will need to do will specify the URL will W will specify the user name for the brute
forcing we the file that has passwords that we want to use for brute forcing will be f and then the
number of threads will be deep but before we actually finish this command we need to separate them with
two dots so separate each one of them with two dots and close the brackets.
So right now this should be finished but since around the tri command we need to accept.
So we want to use the any get up error which we can do with this command so except get opt not and get
opt out or we are just basically can print for example error on arguments and then we close this and
then we can use this dot exit in order to close our program so let's see what we need for now.
Basically what we tried we actually gave to these two variables.
We actually get to opt to use to get up library and we set the number of things that we want to specify
with our options.
We said the user name file your URL and threats.
And we also printed the try and accept a statement which will actually print etcetera on our comments
if we forget to specify some argument or something like that.
Now what we want to do right now is actually specify what you to each of these options.
Each of these options are since our code doesn't really know that we want to specify have to be a file
with passwords we need to tell that to our program.
So how we can do that we can do that simply with this.
So let me just.
Just PRESENTER And we'll do that all in these start functions.
So make sure to be still in start function and we want to use what we gave to these two variables.
So for ops we use the for loop for ops comma ARG in options or basically not.
So basically what we used for opt and the arc of which is basically are variables that we do not really
have.
This is just variables named that I picked and in op so I could have just type here I.
But it would make any sense so let's just leave this in orbit which is this that we said to this variable
to be variable to be we want to actually select what each of that will be.
So for example if opt equals equals minus you let's do it like this.
So minus you which is for the user then let's say user equals arc.
Now let's do that for all of these other options as well
so the next thing would be else if OP equal equals w or minus W is that is how we both specify the commands.
There w is for the EU or so your l will be equal to mark then.
Else if option equals equals to minus f or let me use the single quote since I started everything else
with the single quotes the let's call it Dick Show or however we want to call it equals arc.
You can just use dictionary dictionary or file name.
So for example let's use the pass list.
Maybe that is easier for you to actually understand than dictionary and we want to set that to also
be equal to the arguments so and else if for the last one.
Opt equals equals and then codes minus Steve.
We want to set threads to be equal to arg.
So what we did right here is we specified what will which the letter means so user it will be minus
your.
You are a minus W D past list will be minus F for the file and then minus t will be threads
so what we want to actually do right now is we want to actually first of all open the file for readings
since we can't really brute force the passwords if we do not open default to read it.
Now we will open the model just make a simple password that links and password file the triple use for
this doesn't really matter.
We'll have to open it and then we will have to code a function that will actually take an input of our
passwords threads user names and you are out.
So let us see how we can actually do this so all we have to do right now in this function is actually
open the file so we will do that with try and accept rule.
So we actually can prompt users with the narrower if the file for example doesn't exists even the specified
the wrong name for a file.
Our program will crash.
So we want to run the try and acceptable so we'll just type your F equals open and then we need to specify
the name of the file to be passed lists since we specified minus f option to be equal to past lists.
So make sure to name it the same right here and all we want to do is open the file loops for reading
since we will be reading from that file for our passwords.
Now there is an option to read each line by line.
So in Python that is called read lines.
So we want the passwords variable so passwords will be equal to f dot read lines.
So for example if we have a program or file with password that is basically five passwords long the
passwords variables will be each line of that we need to specify that in order for our program to know
or to you that it has to use only one password while both forcing.
So let us now call the.
Or code the accept function.
So basically we want to print can't open that file or let the sexually ad this read here to be as an
error.
Let's also do it right here so it doesn't look like this.
We will print all of the errors.
We did double exclamation marks and we'll print one did find the password with the plus mark so we can
actually differentiated and all we want to do right now is actually call this is not exit in order to
close our program since we since the user didn't specify the correct command or pardon me.
The correct program.
And right now what we have to do after this we set our options to be good.
So we set all of this we open the file we read passwords.
Line by line.
And what we want to do now is actually a lunch hour threads that we use in order to brute force.
So we will call a function lunch or threads or threads which doesn't exist.
We will have to code it in the next video but for now on let us just see what we have to pass to that
function.
And basically what we do have to pass is the things it will use in our program which is passwords and
what we want to pass to this launch address is basically passwords which is basically the password that
we read from this program right here for the We the option f dot read lines.
We also want to pass the threads number of threads that we will use.
We said that right here we need to pass the user name or we call it user.
OK.
So we called it on the user.
So we will need to specify user here as well.
And the last thing we need to specify is these you are out now where the code as I said this function
in the next video.
Right now we successfully coded all of these options right here.
We need to code the launcher that function in the next video which will launch our threats which will
help us brute force our target faster.
We will use the threat of start to function in that uh from the uh threat library in order to do that.
And then we will have to code a class that we will use in order to actually perform the attack itself.
So I hope you enjoyed this video and I hope I see you in the next one.
Bye by.