1 00:00:00,330 --> 00:00:02,760 Hello everybody and welcome back. 2 00:00:02,760 --> 00:00:08,640 And in the previous video we called the launcher threat functions function pardon me which actually 3 00:00:09,000 --> 00:00:10,580 checks out the number of threads running. 4 00:00:10,590 --> 00:00:16,950 And it also starts a thread on our class request performer which we need to actually call right now. 5 00:00:16,950 --> 00:00:22,410 Now that class will take an argument of threat and we need to code the part of the code in that class 6 00:00:22,440 --> 00:00:25,540 which will actually run the attack itself. 7 00:00:25,620 --> 00:00:31,050 So we will do that up here so let us call coded right here. 8 00:00:31,050 --> 00:00:34,980 We will call it class request performer. 9 00:00:35,610 --> 00:00:37,560 And it will take the input of threat. 10 00:00:37,590 --> 00:00:43,590 So basically it will take an option is threat make sure to call it the same as you call it right here. 11 00:00:43,590 --> 00:00:48,930 So request performer makes needs to be the same name as it is right here. 12 00:00:48,930 --> 00:00:56,940 So all we have to do right now as is the every class we actually code we need to set the function in 13 00:00:56,940 --> 00:01:01,170 it which will specify the variables that we will use in this class. 14 00:01:01,170 --> 00:01:05,730 They all need to have the prefix of self dot and then the name of the variable. 15 00:01:05,730 --> 00:01:08,060 So let us see how we can do that. 16 00:01:08,070 --> 00:01:16,380 So Def underscore underscore and it underscore underscore and here we pass the self argument as in the 17 00:01:16,440 --> 00:01:21,770 every class and we need to specify the three arguments that we actually passed in our request to perform 18 00:01:21,850 --> 00:01:27,580 a class which is name user and you are out after that. 19 00:01:27,590 --> 00:01:30,920 In this function we need to initiate all of these variables. 20 00:01:30,950 --> 00:01:38,180 So first of all we will do the threat to be red dot in it since that is the argument that the class 21 00:01:38,180 --> 00:01:40,190 takes itself into port. 22 00:01:40,190 --> 00:01:42,700 Do yourself in the brackets right here. 23 00:01:42,710 --> 00:01:46,920 So this is a little bit of new syntax for you but you will get used to it. 24 00:01:46,940 --> 00:01:51,320 The one that we do know is the self that password. 25 00:01:51,320 --> 00:02:00,680 We need to set that to be named split groups since name actually corresponds to the password and the 26 00:02:00,680 --> 00:02:02,880 user is using them to specify. 27 00:02:02,900 --> 00:02:07,550 Now you might be asking why are we using the name that split option. 28 00:02:07,550 --> 00:02:13,620 Well basically the password that we actually read for from our file. 29 00:02:13,730 --> 00:02:17,820 They all have the slash and at the end of there weren't. 30 00:02:17,880 --> 00:02:22,400 Now discretion in programming language actually represents on your line. 31 00:02:22,400 --> 00:02:27,380 So we need to actually speak to our password or our text or string or however you want to call it from 32 00:02:27,380 --> 00:02:34,640 that character minus our slash n which represents a new line so we can do that with the DOT split option 33 00:02:34,910 --> 00:02:41,240 and then we can just open up the brackets and in the double quotes type here slash or backslash and 34 00:02:42,830 --> 00:02:44,450 then close the double quotes. 35 00:02:44,600 --> 00:02:51,770 And in order for our program to actually know which part of the split we want to use whether the first 36 00:02:51,770 --> 00:02:58,910 or second one we need to specify the first one which we can specify with the open square brackets zero 37 00:02:59,780 --> 00:03:01,220 since once just plead the. 38 00:03:01,430 --> 00:03:05,660 Let me just show you right here how that would look like. 39 00:03:05,750 --> 00:03:13,410 So basically you have a password called test and then since it is having on your line it has the characters 40 00:03:13,490 --> 00:03:19,850 backslash and we did the splits so we split these two and we want to select to use the first part which 41 00:03:19,850 --> 00:03:21,440 is part right here. 42 00:03:21,440 --> 00:03:27,650 And since we know that counting in programming starts you know we specify here test which is basically 43 00:03:27,770 --> 00:03:29,540 representing these 0 right here. 44 00:03:30,380 --> 00:03:31,640 So let me just delete this now. 45 00:03:31,640 --> 00:03:33,310 So our program can actually run. 46 00:03:35,060 --> 00:03:38,480 And right now since we initiated the password what to be. 47 00:03:38,480 --> 00:03:44,780 Now we need to initiate the user name so self that user name will just be user which is specified right 48 00:03:44,780 --> 00:03:57,850 here and also the cell that your health will be you are URL and then let's print the actual the actual 49 00:03:58,150 --> 00:03:59,710 password that we are using currently. 50 00:03:59,710 --> 00:04:07,200 So let us do this with the dash and plus s the password for example and then plus dash. 51 00:04:07,210 --> 00:04:13,960 So right now we go to the init function in our class which is basically hosting or having our variables 52 00:04:13,990 --> 00:04:15,010 right here. 53 00:04:15,010 --> 00:04:19,990 And what we want to do is finally call the Ron function which will actually run the attack itself on 54 00:04:19,990 --> 00:04:22,180 our on our target. 55 00:04:23,230 --> 00:04:24,640 So how can we do that. 56 00:04:24,760 --> 00:04:26,880 We can actually name a function. 57 00:04:26,950 --> 00:04:32,520 Make sure that that function actually belongs to this class right here since we will actually use the 58 00:04:32,530 --> 00:04:37,900 variables from here in that class if you code the function to be right here it will not belong to that 59 00:04:37,900 --> 00:04:40,390 class and we will not be able to run our program. 60 00:04:40,600 --> 00:04:47,230 So that run and run will take self as an argument since it belongs to our class. 61 00:04:47,230 --> 00:04:52,720 And basically we need to add the global hit variable that we coded in the previous videos. 62 00:04:52,720 --> 00:04:58,390 Now the reason why we need to add it is because of right now we'll check if the global heat is equal 63 00:04:58,390 --> 00:05:01,550 to zero to 0 or 1 if it's equal to 1. 64 00:05:01,870 --> 00:05:07,720 Basically that means the past 14 and fork if we get the state's code of 200 for our program which means 65 00:05:07,720 --> 00:05:13,870 we actually successfully loaded and logged into a page we will set him to be zero and then it will terminate 66 00:05:13,900 --> 00:05:22,380 our program so let me show you what I mean by that in case you don't understand it the US remove this 67 00:05:22,380 --> 00:05:24,300 selection right here. 68 00:05:24,360 --> 00:05:27,470 We need to select that we use the global hit comment. 69 00:05:27,600 --> 00:05:28,020 Pardon me. 70 00:05:28,020 --> 00:05:35,790 Variable and we need to check as usual if kids equals equals to one. 71 00:05:35,810 --> 00:05:39,290 So right now we will actually run our program itself. 72 00:05:39,290 --> 00:05:45,140 As I said we need to use the requests library since it allows us to send the packet with the user name 73 00:05:45,140 --> 00:05:46,250 and password too. 74 00:05:46,340 --> 00:05:51,700 And we do basic authentication with just one line. 75 00:05:52,000 --> 00:06:01,970 So right here we want to run the try and accept option as in every every other basically command that 76 00:06:01,970 --> 00:06:04,340 we use or a function that we use. 77 00:06:04,400 --> 00:06:11,600 And right here we will need to code our request so let's name our request to be just are and we use 78 00:06:11,640 --> 00:06:16,340 the library requests and we use dot get. 79 00:06:16,880 --> 00:06:18,760 Now why do we use that get. 80 00:06:18,770 --> 00:06:25,310 Well basically if you remember from our purpose of inspecting all of our basic authentication we were 81 00:06:25,310 --> 00:06:31,250 sending a get request while sending the basic authentication with user name and password. 82 00:06:31,280 --> 00:06:34,630 That's why we here also need to use get the option. 83 00:06:35,090 --> 00:06:41,750 So in the get option we need to specify basically two things or three things. 84 00:06:41,750 --> 00:06:46,780 Technically we need to specify the euro to which we are sending the packet. 85 00:06:47,000 --> 00:06:52,070 And we also need to specify the authentication which will actually have the user name and password in 86 00:06:52,070 --> 00:06:53,000 brackets. 87 00:06:53,030 --> 00:06:54,940 So how do we do that. 88 00:06:54,980 --> 00:06:56,240 Well simply just type here. 89 00:06:56,240 --> 00:07:01,210 The first argument or option to be self not you are. 90 00:07:01,440 --> 00:07:08,660 We use the self remember that we use the self because we are still in the class and then we need to 91 00:07:08,660 --> 00:07:10,510 specify the authentication. 92 00:07:10,820 --> 00:07:18,030 So authentication right here which will actually equal two open brackets and then sell the user name 93 00:07:19,460 --> 00:07:22,420 and also sell the password. 94 00:07:22,430 --> 00:07:25,360 Then we closed two brackets since we have two brackets open. 95 00:07:25,490 --> 00:07:33,200 So all we have to specify is this and we can send or we can actually check if the packet has received 96 00:07:33,320 --> 00:07:40,340 are status code of 200 with which means we actually successfully load the page or it didn't. 97 00:07:40,340 --> 00:07:47,360 So we will run a simply false command so if our DOT status code which is a function in the request library 98 00:07:47,360 --> 00:07:53,810 that allows us to check the status code of a get request and if it equals equals to two 200. 99 00:07:53,810 --> 00:07:58,260 That means that the password is correct and that we actually guessed the password. 100 00:07:58,310 --> 00:08:04,700 So what we need to do is specify here shift to be zero so we can actually terminate our code as you 101 00:08:04,700 --> 00:08:08,590 remember in this part right here in the launch thread function. 102 00:08:08,630 --> 00:08:11,960 We were also checking if heat equals equals to 1. 103 00:08:11,960 --> 00:08:16,080 Now if heat equals equals zero this will not actually. 104 00:08:16,130 --> 00:08:24,090 This will not actually run anymore so all we have to do right now is actually go back up. 105 00:08:24,120 --> 00:08:27,680 Let me just go and find where we stopped. 106 00:08:27,680 --> 00:08:29,300 So it is right here. 107 00:08:29,300 --> 00:08:32,940 So if heat equals equals to zero we found passwords. 108 00:08:32,940 --> 00:08:36,100 So that's what we want to actually print shops. 109 00:08:36,140 --> 00:08:42,200 Now we actually if our state's code because the 200 we set the heat to be equal to zero and we want 110 00:08:42,200 --> 00:08:44,450 to print the password so print 111 00:08:47,030 --> 00:08:57,710 plus password found and then let's set that password to be basically the let's add the strength to it 112 00:08:57,740 --> 00:09:02,950 which would be the strength of our password that we use for this current iteration of this loop. 113 00:09:03,020 --> 00:09:04,910 So sell that password. 114 00:09:04,910 --> 00:09:09,740 This means we found successfully the password and all we want to do right now is actually say start 115 00:09:09,760 --> 00:09:10,540 exits. 116 00:09:10,580 --> 00:09:17,920 So actually the program else so else the in case our state's code isn't 200. 117 00:09:18,040 --> 00:09:26,020 We want to run the else and we actually want to print the or let's do it like this 118 00:09:31,800 --> 00:09:42,750 we can get this lost cell phone password plus is is not valid. 119 00:09:43,620 --> 00:09:46,250 So this would basically print these two nation marks. 120 00:09:46,260 --> 00:09:49,770 Need to add our current password and a footprint add. 121 00:09:49,770 --> 00:09:57,940 Also after the password is not valid so after we'd check that the password is invalid what we want to 122 00:09:57,940 --> 00:10:03,790 do is actually remove the thread from the counter and our counter is basically get the variable that 123 00:10:03,790 --> 00:10:05,620 we specify in the launcher function. 124 00:10:06,040 --> 00:10:07,140 So how can we do that. 125 00:10:07,140 --> 00:10:09,300 We can do it simply with this. 126 00:10:09,640 --> 00:10:15,280 So zero equals I of zero minus one. 127 00:10:15,280 --> 00:10:19,600 The same that we specified here to adding to the counter which was plus 1. 128 00:10:19,600 --> 00:10:26,790 We need to now remove it from the counter which minus one and here in the after we try this we need 129 00:10:26,790 --> 00:10:34,360 to take an exception which we can do exception and then comma E and then we can actually print that 130 00:10:34,370 --> 00:10:37,710 that or in case that that or shows up. 131 00:10:37,710 --> 00:10:42,870 So basically this is it for this program. 132 00:10:42,870 --> 00:10:49,530 This should actually work I believe in the next video we will test the program itself and then we will 133 00:10:49,530 --> 00:10:56,280 actually add something else as a help option in order to print to the user our available options. 134 00:10:56,280 --> 00:10:57,930 So hope you enjoyed this video. 135 00:10:57,960 --> 00:11:00,640 I hope I see you in the next one where we will be testing this program. 136 00:11:00,720 --> 00:11:01,670 And take care. 137 00:11:01,950 --> 00:11:02,250 But.