1 00:00:00,300 --> 00:00:02,670 Hello everybody and welcome back. 2 00:00:02,670 --> 00:00:07,190 And right now let us see what we need to specify in this launch thread function. 3 00:00:07,320 --> 00:00:10,590 In order for it to actually launch our threats for us. 4 00:00:10,590 --> 00:00:16,440 So right now what we will actually do is first of all make up def launch under threat. 5 00:00:16,440 --> 00:00:18,720 So let us do that. 6 00:00:18,900 --> 00:00:24,730 First you enter make def launcher underscore threat. 7 00:00:24,990 --> 00:00:27,350 We need to pass the passwords. 8 00:00:27,630 --> 00:00:28,580 The age for threats. 9 00:00:28,590 --> 00:00:33,200 User name for user names and your URL for you or else. 10 00:00:33,210 --> 00:00:36,300 Now these are not as is as you know from before. 11 00:00:36,300 --> 00:00:37,890 These are not really variables. 12 00:00:37,950 --> 00:00:43,360 These are just some of the names that I would use in order to specify what actually goes to these function. 13 00:00:43,590 --> 00:00:47,800 What does go to the function is we specified in the previous video and it is right here. 14 00:00:47,940 --> 00:00:54,340 We basically passed these four things to our function which is the 14th three coded in our options. 15 00:00:54,420 --> 00:01:01,270 So right now in order for us to actually keep a track of our threats let us make a variable called i. 16 00:01:01,290 --> 00:01:05,870 It will be a global variable since you also use it outside of our loop. 17 00:01:05,880 --> 00:01:07,310 Now our variable will be a list. 18 00:01:07,320 --> 00:01:11,220 So we need to specify that to be with the square brackets right here. 19 00:01:11,220 --> 00:01:14,680 So make sure to specify equals and then not the normal bracket. 20 00:01:14,700 --> 00:01:23,310 But the square brackets and we want to append two dead file zero which is what this will do is if you 21 00:01:23,310 --> 00:01:29,460 know what append function does we covered it up so we can just find it what append function does it 22 00:01:29,490 --> 00:01:35,300 basically appends a certain string or something or a number to the end of the list. 23 00:01:35,340 --> 00:01:41,130 Now since our list is empty for now on it will only append the zero to our list. 24 00:01:41,130 --> 00:01:50,970 So right now let us use the while loop to actually see how many passwords we have in our lists. 25 00:01:51,900 --> 00:01:57,690 So in order to do that we know from the previous video that we said passwords to be to read lines from 26 00:01:57,690 --> 00:02:00,840 our file that we specify in the command. 27 00:02:00,840 --> 00:02:06,390 And right now we want to read those passports for as long as they exist for example to the end of the 28 00:02:06,390 --> 00:02:07,300 file. 29 00:02:07,380 --> 00:02:09,240 We can do that with these simple commands. 30 00:02:09,240 --> 00:02:20,660 So while line passwords this basically means it will read all of the passwords for the basically until 31 00:02:20,720 --> 00:02:24,360 it reaches the end of the password list. 32 00:02:24,650 --> 00:02:30,710 And now let's actually set a variable that will actually specify whether we got the password right or 33 00:02:30,710 --> 00:02:32,570 we got the password wrong. 34 00:02:32,570 --> 00:02:33,710 So how do we do that. 35 00:02:33,710 --> 00:02:37,550 Well first of all we need to create our global variable. 36 00:02:37,550 --> 00:02:39,750 We can call it however we want. 37 00:02:40,070 --> 00:02:41,750 Let's call it hit for us. 38 00:02:41,780 --> 00:02:46,490 So it means when it's hit it means we said we found the password. 39 00:02:46,500 --> 00:02:56,480 So global hit and we will set hits to be equal to 1. 40 00:02:56,480 --> 00:03:01,720 Now don't set it to be equal to 1 as our number set it to be equal to 1 As String. 41 00:03:02,270 --> 00:03:09,410 So go back to your function down here and basically all we want to do right now in our while True loop 42 00:03:09,860 --> 00:03:15,710 or not while true while length of the password is globe we want to first of all check if hit equals 43 00:03:15,740 --> 00:03:17,370 to the one. 44 00:03:17,390 --> 00:03:24,380 So if we check that if it does equal to one that means we didn't find the password since basically if 45 00:03:24,710 --> 00:03:26,930 we will set the hit to be equal to zero. 46 00:03:27,050 --> 00:03:33,890 Once we actually hit the password that we actually can log in to our page so what will what we will 47 00:03:33,890 --> 00:03:40,220 do right now is we will actually check out if the number of threads is about the thread specified in 48 00:03:40,220 --> 00:03:42,200 the launcher functions. 49 00:03:42,200 --> 00:03:48,170 So for example let's say a user specifies the threads to be five and we only have three threads in our 50 00:03:48,170 --> 00:03:49,510 function or something like that. 51 00:03:49,520 --> 00:03:56,000 We want to check out that as well but we want to do that we try and accept rule since we can always 52 00:03:56,000 --> 00:04:01,710 hear the keyboard interrupt the same as we coded right here in order to stop the program. 53 00:04:01,730 --> 00:04:08,270 So how can we check if the current number of threads in our ie variable that we specify for our threads 54 00:04:08,570 --> 00:04:15,620 is smaller or bigger than the thread specified from the user with the threads option so we can do that 55 00:04:15,890 --> 00:04:21,290 if I zero in our brackets is smaller than T H. 56 00:04:21,350 --> 00:04:23,030 Now why do we use T H. 57 00:04:23,030 --> 00:04:27,890 We use it because the h is what we specified in our def launch thread options. 58 00:04:27,950 --> 00:04:39,800 So if I is smaller than D.H. who want to type here something function called Pop Tarts WD is the variable 59 00:04:39,800 --> 00:04:47,780 that will put the password dot pop in so where you remember in the basic Python we learned what Pop 60 00:04:47,780 --> 00:04:48,530 function does. 61 00:04:48,530 --> 00:04:54,050 So basically it is used for lists as our passwords variable is actually not a variable it is actually 62 00:04:54,050 --> 00:04:59,450 a list that contains all the passwords in red the line by line. 63 00:04:59,450 --> 00:05:07,070 So what we need to do is equal passwords not pop and then specify zero right here. 64 00:05:08,060 --> 00:05:14,540 So the next thing we want to do is if it is smaller than t h as we specified right here loops first 65 00:05:14,540 --> 00:05:18,290 of all we need to tap this in order to belong to the if loop. 66 00:05:18,290 --> 00:05:24,750 We need to add another thread to this to this basically lists called by. 67 00:05:24,860 --> 00:05:29,240 So let us do that we can do that like this. 68 00:05:29,250 --> 00:05:44,570 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 69 00:05:44,570 --> 00:05:50,900 you is basically referring to the first element of the list itself and all we have to do right now is 70 00:05:50,900 --> 00:05:58,520 actually create a thread on a function or basically thread on our class the predetermined code yet which 71 00:05:58,520 --> 00:06:01,280 will actually run did attack itself. 72 00:06:02,330 --> 00:06:06,380 So how we will call that that class will be request performer. 73 00:06:06,380 --> 00:06:13,490 So we will run a thread we'll just call the variable to be threat equals request underscore performer 74 00:06:14,900 --> 00:06:22,700 and index in that thread or basically we need to pass in that class the password username and the you 75 00:06:22,700 --> 00:06:29,480 are out so we will call the class itself the next video. 76 00:06:29,490 --> 00:06:34,630 But for now that is just past the past WD the user name and the. 77 00:06:34,710 --> 00:06:41,490 You are out for our request performer class and all we have to do after that is something that we are 78 00:06:41,700 --> 00:06:48,780 familiar with is start the thread itself and since we called it the triangle we need to add the accept 79 00:06:48,790 --> 00:06:53,100 rule as well and we need to join the threads at the end of this. 80 00:06:53,130 --> 00:07:02,610 So we will just type here except keyboard interrupt for the keyboard interrupt and we will just print 81 00:07:02,760 --> 00:07:04,550 as usual interrupted. 82 00:07:04,560 --> 00:07:08,160 So we need two exclamation marks. 83 00:07:08,160 --> 00:07:14,860 Just print here interrupted Whoops. 84 00:07:15,180 --> 00:07:22,130 So after that we closed the program with this exit and we have two threads that join in order for our 85 00:07:22,130 --> 00:07:22,860 friends to join. 86 00:07:22,860 --> 00:07:25,300 At the end of this function. 87 00:07:25,500 --> 00:07:33,540 So right now what we are left to do is actually code the class itself in our program and we will do 88 00:07:33,540 --> 00:07:35,070 that in the next video. 89 00:07:35,100 --> 00:07:39,920 And after that we will actually test our program to see if it actually works. 90 00:07:39,930 --> 00:07:42,590 So let's see what we actually need for now. 91 00:07:42,660 --> 00:07:47,820 We made the function that will actually create all of these arguments that we specified with this command 92 00:07:47,820 --> 00:07:48,390 right here. 93 00:07:48,930 --> 00:07:53,970 So with this command right here then it calls the launch of threads and those arguments which will actually 94 00:07:53,970 --> 00:08:00,060 check out the number of threads running and then it will call the thread to start on the class the tool 95 00:08:00,080 --> 00:08:01,120 code in the next video. 96 00:08:01,590 --> 00:08:05,530 Now we will pass the arguments of password username and you are out. 97 00:08:05,790 --> 00:08:08,220 So that is what we coded for now. 98 00:08:09,480 --> 00:08:14,190 It might be a little bit hard to understand at the beginning but you should be good to go once we finish 99 00:08:14,190 --> 00:08:14,460 this. 100 00:08:14,460 --> 00:08:16,480 You will understand this fully. 101 00:08:16,830 --> 00:08:19,500 So that will be about it from this video. 102 00:08:19,530 --> 00:08:23,260 I hope you enjoyed it and I hope I see you in the next one. 103 00:08:23,380 --> 00:08:23,670 My.