Okay.
In the previous lecture, we covered the city command.
Okay.
Now it is time to download a sample txt file.
Okay.
So the sample txt file.
Let me first explain how does it work.
While we're trying to download something.
Okay.
Uh when it is a simple txt file, first we are trying to read the file from backdoor and then send it
here.
Here we will create a new file and write it okay.
So very easy.
So here we need to create a method for writing into a file.
Let's do that.
Give off.
Write again.
So here we need to provide um two thing.
Okay.
One of them is going to be the path.
Okay.
Where, uh, where do we want to save this?
The other one is going to be the content.
Okay.
Content is the data that we read from a reverse vector and write it here.
Okay.
So while we're trying to open a file we use width keyword and then open method which is which come from
with Python when you install the Python.
Okay.
And here let's first give the path where the file located.
And then you need to provide the mode for the file.
So I'm going to be giving a w b means writing as binary.
Okay.
And here we are going to alias this as something like file.
Okay.
So now we uh, we can do a lot of a lot of things with this file that we have.
For example, I'm going to write this.
So I use file dot Right.
Okay.
What do I want to write inside this file?
I want to write the content inside this file.
And at the end, I can return just the text.
For example, let's.
Give this that download successful.
Okay.
So this is the right method.
Let's change this write method to something else like write file okay.
And here.
Uh, down here after we receive the result okay.
We can check it here.
If, if the command okay that we receive from user and the first one that user provide.
For example, they write download something.
If this is equal to this word like download, then let's do something.
If it is equal to download then let's um we have the result here okay.
Result variable.
So I'm going to say result is equal to self.
Dot.
Write file which is a method that we just created.
And here I'm going to give the second.
Option from the thing user enter.
And finally we give the result as content.
So here we have the command okay.
This command will create a list for me.
The first one is going to be download and the second one is a name of a file.
Okay, so we give the name of the file as a path here and the content is equal to result.
What is this result?
This result is something that come from backdoor.
And at the end we can just print this result here.
But if I use decode.
So right here is not going to print that for me because it is a text.
And we don't need to use decode with text but with other command it is going to show them as okay.
Okay.
So now it is completed.
Let's go back to Backdoor in Windows Machine to handle this here too.
So in here we are going to create a method named via read file Okay.
Because here we're going to read file.
So let's create that file here.
That method here.
And in here we're going to give only the path.
Okay.
So to read a file again we need to first open that file.
I use open method and then give the path path.
And the mode is going to be RB means read as binary.
And let's alias this as a file.
After we read it, we need to return.
Okay so let's use return.
We have the file dot read method that will.
This will read the whole content.
So now we have this method this function or method.
Here we need to use it somewhere in here.
Okay.
So down here again I need to check this so I use live data.
The first data okay we receive.
If this is equal to to download.
Okay download.
Then then we can do something.
For example we can read the second option that come from listener.
Okay.
So let's have this command result.
It is equal to self dot.
We have just created the read file method here.
And then in here we are going to just give the data.
And number one why data number one.
Because then the first keyword or the first index from the list is download.
So the user will enter for example download name of the file and the name of the file will be right
in here.
And then we will add it here.
And then we will read that and then return it from here.
And we give it to here it is, it will start to command result.
And at the end we return the command result from here to listener.
So let me save this and go back here.
Try to run this program.
It is waiting for incoming connection.
And here again let's run this.
So let's use dir method to see what is inside this okay.
You may ask why it is showing this as binary.
That is because I removed the dot decode from here from printing okay.
And here you see we have a sample dot txt file okay.
So I want to read this I want to download this file.
Uh, here.
Okay.
For example, in here, inside this reverse factor.
Okay.
You see, right now here is the file I want to download that right here.
So let's use download keyword.
And then name of the file.
What is the name of the file.
It is sample dot txt.
So sample dot txt hit enter.
You see download is successful.
And let's go back here.
You see a new file is added.
When I open that we have seen the data which is inside here.
And let's go back to windows machine.
And that is here.
If I open this this is the same thing that is added on the Linux.
So here now you have your backdoor program that is able to download files the files from victim computer.
So thanks for watching.