 Right, so hey guys and welcome back to another Python tutorial This video is basically a finish-up tutorial on the backdoor series. We started using Python So in this video, we're going to be finishing up the program that we started relating to creating a backdoor program So the only command that's actually left on finishing this program would be the sending files feature So essentially using this feature, we should be able to send a file from our server to a remote client Based on either localhost or any other network as well So to begin with I'm going to go to the folder destination that I have my server file in and then I'm going to create a test file So I'm just going to call the test file test.txt and put some simple text in there And then at the end of this tutorial what we want to achieve is wirelessly send this file to this slave directory And it should be done via data sending. So that's what we're going to do in today's tutorial First of all, we scroll down to the end of the server file and then we go and create another command So the new command is going to be called send file. So Just do a new command and call it send files. You can do it whatever you want, but I'm just going to keep it like that Then we create we ask the user for the file. So input string, please enter the file name and directory of the file So at this stage the user is going to need to enter the name of the file as well as the as well as the directory in which the file is located so that the file can be read So once the file has been located, we're going to read the file So we're going to create data and we're going to do data equals open We're going to open the file and then we're going to read the bytes from it We need to read bytes because that's the Format using which we can send the data through the socket We can't send it and in any other format. So once it's been read what we want to do is we just do connection dot send data and then we print We'll print the file name. So we do file So now that we've got this here what we want to do next is go ahead and work on the slave program So we're going to add another elif statement here. I'm going to do elif command. I just leave a line as well Come on equals send files Then what we want to do first of all is receive the file. So we do file equals Also, we need to do another statement for the file name. So We need to do another one File name equals Please enter So once the file has been sent successfully we're going to be sending the connection File name dot encode file name over And that way we'll be able to send The file name that you want the file to have as well So first of all we receive the file. So we do file equals We need to create create so we receive the file name we do file name equals s.receive 6000 bytes for now and then we do We open a new file and we call that file new file equals open file name from our right bytes because we're going to be writing data to the file and we do data equals s.receive 6000 Depends on how big your file is but for now I'm just leaving a 6000 buffer and then once we receive that data we do new file dot write data and Then we do file dot close Actually, we need to do new file dot close Also, we need to keep the extension of the file in mind when we're sending the file over So make sure to tap in the extension of the file in the file name as well We're just going to test this really quickly to see if this works and Hopefully it does just go here Get this up here So come on is going to be send file It's probably send files Uh File name and directory of the file. Alright, so the file name is going to be test dot txt And I'd like to call it test dot txt as well Okay, connect your byte like objects required now I have a for under a connection to send Let me just see what went on here. Oh We didn't read the data basically what we need to do next is read the data as well So we do data one equals Oh, actually, we just call this file data Our data equals data dot read because you need to read the data and then we're going to read around seven thousand bytes and That should have sorted that out. We just update this variable here call this file data now And then when we run this again, hopefully it's going to be a success this time Okay, let's get this on this side and send Send files and then the name is test dot txt test dot txt Command received come on not recognized. All right, let's see Well, it's built basically because we didn't really do much here But anyway, let's go ahead and check if we have the file received if we do we should basically have it in here Right, so they didn't seem to do the job. Let me see what went wrong here What we're gonna do is we're gonna print the file name as soon as it's received Our name as well as we're gonna print the data received Just to see if it's actually receiving everything correctly or not Because if it's not that's probably the problem Due to which the error has been caused So all is saying is command received commands not recognized Something wrong with the thing then it's not being triggered or is something like that So in the commands being sent Oh Cuz we're not really I'm sorry about that. It's really stupid on my behalf because we're supposed to send the command to the By the program, but we want all this time, which is why the error persisted So we're gonna do this again Okay, this is some simple text and test at TXT perfect so it should have actually saved the file this time around and as we see right here, it's It's done something wrong, but it's worked out. Okay, just need to make a few changes to the code and the next execution I promise you it should be correct. So We've changed this to file name. Okay, what's being sent to us? Connection don't send file data Okay, okay, I get it So if we send the file later and the file name first that should fix the problem if we do this And I'm gonna have to navigate all the way back to the same folder again because I closed it Go to YouTube workspace Backdoor Right So I'm just gonna delete this file and now when we run this program again Fingers crossed it's gonna work Right, so I'm gonna paste the address in here like we always do and then we're gonna type in the command for sending the files test.txt test.txt And it says it's been transferred successfully So we go here and as we see right here guys We finally succeeded the file has transferred from this area to this area wirelessly So it says this is some sample text This file could be anything literally it could be a game or massive file or anything you like Just make sure to increase the buffer rate While you're reading the file and write while you're reading the file up here So if you could leave a comment about change When a file is big And you have to do the same here as well. So when you're receiving the file if the Alright, the reason we have to change that is otherwise It's gonna cut off some of the data and the data is gonna be corrupted in the file the file is gonna exist in your current directory, but then There's gonna be problems with it because it's not gonna be the complete file because the program doesn't have enough buffer to receive it Anyway guys that was it for today's tutorial Thank you so much for all the support you've shown me throughout this whole series of backdoor programming I hope you really enjoyed it. I'd really like to know if you learn something new leave it in the comments and Just so that we can start our next series Please leave me some ideas in the comments if you want me to do something new or I'm just gonna assume that We should start with the PHP web series now Anyway guys, please make sure to comment like subscribe and help me reach my subscriber target of 1000 and I'll see you in the next one Peace out