1 00:00:00,360 --> 00:00:01,050 Welcome back. 2 00:00:01,350 --> 00:00:02,990 Let's continue with our programs. 3 00:00:03,360 --> 00:00:08,820 So in the previous video, we managed to establish a connection between these two programs or we didn't 4 00:00:08,820 --> 00:00:14,220 really manage to establish, but we created a part of code that will establish the connection once we 5 00:00:14,220 --> 00:00:15,100 run these programs. 6 00:00:15,850 --> 00:00:22,780 Now, let us go to our server program first and let's figure out this target communication function. 7 00:00:23,460 --> 00:00:29,880 Remember, this function will send the comments to the target system that we want to execute, and it 8 00:00:29,880 --> 00:00:33,210 will also receive the response of the target system. 9 00:00:34,200 --> 00:00:40,170 So let us it up here and we're just going to start it and then we are going to go to the pacta program, 10 00:00:40,710 --> 00:00:46,080 first thing that we're going to do is we are going to initiate the function to define and then target 11 00:00:46,080 --> 00:00:47,430 underscore communication. 12 00:00:48,840 --> 00:00:51,390 As we can see, it takes no parameters. 13 00:00:51,690 --> 00:00:57,870 And what we are going to do straightaway inside of this function is we are going to enter an infinite 14 00:00:57,870 --> 00:00:58,830 while loop. 15 00:00:59,310 --> 00:01:04,470 What we will essentially do here is we're going to ask for a command from the user of this program and 16 00:01:04,470 --> 00:01:10,280 then we're going to send that command to the payload and go back to the beginning of this file to loop 17 00:01:10,290 --> 00:01:11,640 once we receive the response. 18 00:01:12,480 --> 00:01:14,870 Let me show you what they mean inside of here. 19 00:01:14,880 --> 00:01:20,970 The first thing that we want to do is we want to initiate a comment since we don't know what command 20 00:01:20,970 --> 00:01:21,960 we want to execute. 21 00:01:21,990 --> 00:01:28,080 We're just going to use an input statement that will allow the user of this program to type in the command. 22 00:01:28,830 --> 00:01:30,890 And we're going to write it like this. 23 00:01:31,050 --> 00:01:32,210 Let's make it pretty. 24 00:01:32,370 --> 00:01:37,230 Let's make it look like a terminal and use this sine percent. 25 00:01:37,230 --> 00:01:41,190 S and you're going to see why we are using this percent as in just a second. 26 00:01:41,850 --> 00:01:48,540 So after three percent as type two dots and then empty space and add a single quote at the end, and 27 00:01:48,540 --> 00:01:53,580 here you can add another percent and string of I.P. address. 28 00:01:54,060 --> 00:01:58,320 And if you don't know Python, you're probably wondering what even happened here. 29 00:01:59,130 --> 00:02:06,360 Well, this is a statement that will print out and once we type this percent s it will get exchanged 30 00:02:06,510 --> 00:02:08,780 with this string of IP address. 31 00:02:09,450 --> 00:02:15,780 And remember, our IP is simply the IP address of the target system that we initiated in this line right 32 00:02:15,780 --> 00:02:16,050 here. 33 00:02:16,500 --> 00:02:22,050 So what this will print is it will print the shell and then after it the IP address of the target machine 34 00:02:22,050 --> 00:02:23,040 and then two dots. 35 00:02:23,250 --> 00:02:26,190 And here we will be able to type in our comment. 36 00:02:26,940 --> 00:02:29,970 We just made it look a little bit prettier once we run the program. 37 00:02:31,240 --> 00:02:37,390 So the next thing that we want to do is then send that comment and we're going to use a function that 38 00:02:37,390 --> 00:02:41,290 I'm going to call a reliable send, and this function also doesn't exist. 39 00:02:41,560 --> 00:02:44,730 It will take one parameter, which will be the command itself. 40 00:02:44,740 --> 00:02:46,720 So we're sending the command to the target. 41 00:02:46,960 --> 00:02:52,090 Now, this reliable function is something the code in the next lecture for now, just picture it as 42 00:02:52,090 --> 00:02:55,390 the function that will send this command to the target system. 43 00:02:56,440 --> 00:03:02,440 Then right here, after we send the comment, we want to check out what this comment was, for example, 44 00:03:02,890 --> 00:03:10,480 this type, if comment equals equals to quit, then this will initiate to our program that we want to 45 00:03:10,510 --> 00:03:13,960 exit out of the shell and we want to exit this program. 46 00:03:13,960 --> 00:03:18,320 So we're just going to break out of this while loop and that will end our program. 47 00:03:18,700 --> 00:03:24,130 So remember, once you type quit, that means you want to stop communicating with the target system 48 00:03:24,130 --> 00:03:27,240 and you want to close this server program. 49 00:03:27,250 --> 00:03:32,500 So we're going to break out the default loop and that will exit out of this target communication function 50 00:03:32,500 --> 00:03:34,830 and then it will exit out of the program. 51 00:03:36,230 --> 00:03:47,000 If it is not quit, so else we're going to type right here, result equals and then reliable underscore 52 00:03:47,000 --> 00:03:51,340 receipt and this function is also something we'll create in the next lecture for now. 53 00:03:51,340 --> 00:03:56,600 And just picture this function right here as a function that will receive the response from the target 54 00:03:56,600 --> 00:03:58,660 after the target runs over comment. 55 00:03:59,090 --> 00:04:07,340 Then we're going to store the response inside of this result variable and we want to print the result, 56 00:04:07,820 --> 00:04:09,000 simple as that. 57 00:04:09,590 --> 00:04:11,020 So let's go through this real quick. 58 00:04:11,030 --> 00:04:14,090 Once again, we're asking for the input of the command. 59 00:04:14,300 --> 00:04:16,430 Then we are sending that command to the target. 60 00:04:16,580 --> 00:04:18,410 We check if the command was quitte. 61 00:04:18,410 --> 00:04:20,540 If it was, then we exit the program. 62 00:04:20,750 --> 00:04:26,900 If it wasn't, then we thought the response of the command that we received using this function to this 63 00:04:26,900 --> 00:04:30,830 result variable and then we print out the result. 64 00:04:30,830 --> 00:04:38,120 For example, if the command was less or dear, that command lists out all of the files and folders 65 00:04:38,120 --> 00:04:43,550 inside of a directory, we would then store this inside of this result variable and then we would print 66 00:04:43,550 --> 00:04:47,070 out all of the files and folders inside the target's directory. 67 00:04:47,930 --> 00:04:48,890 Simple as that. 68 00:04:49,430 --> 00:04:54,020 Now that we did this, let's go to our back door program and code something similar. 69 00:04:56,480 --> 00:05:01,050 Just inside this back door program, we do that using the shell function. 70 00:05:01,880 --> 00:05:07,730 So what I'm going to do is I'm going to go below the connection function and right here I will initiate 71 00:05:07,730 --> 00:05:09,190 this shell function. 72 00:05:09,710 --> 00:05:15,650 And as our target communication function, the shell function will also start with a while loop. 73 00:05:17,060 --> 00:05:20,540 Then what we are going to do is we are going to create the command variable. 74 00:05:20,720 --> 00:05:28,070 And in this program, this command variable will receive the command that our server sent. 75 00:05:28,490 --> 00:05:31,580 So in impacter, we first receive the command. 76 00:05:32,180 --> 00:05:38,060 Then after we receive the command, we check if that command was quite the same thing that we did in 77 00:05:38,060 --> 00:05:44,540 our server and in the same way we are going to exit out of the program by breaking out of this wall 78 00:05:44,540 --> 00:05:45,110 Tulip. 79 00:05:46,040 --> 00:05:52,820 And the other case, we want to execute the comment, but this is something that I'm going to type as 80 00:05:52,820 --> 00:05:53,920 a comment for now. 81 00:05:54,080 --> 00:05:58,600 So here in the statement, we want to execute the comment. 82 00:05:59,090 --> 00:06:03,980 And the reason why I'm not typing it right now is because this execution of command requires another 83 00:06:03,980 --> 00:06:04,490 library. 84 00:06:04,520 --> 00:06:12,000 We're going to touch on as soon as we finish coding these reliable receive functions and reliable functions. 85 00:06:12,020 --> 00:06:18,170 So first, we need to code them and then we're going to go and type the code of the command execution. 86 00:06:19,160 --> 00:06:23,810 So for now, we just started the base of our shell and target communication function and we're going 87 00:06:23,810 --> 00:06:26,040 to continue coating them in the next lecture. 88 00:06:26,570 --> 00:06:27,140 See you there.