Okay, now the program is working.
But still, there is a problem.
Let me show you that I am executing or running the listener here.
And then on Windows Machine I am running the backdoor.
Coming back here, having the connection.
Now I am running a simple command.
You see that we have this here.
Now, for example, my, uh, my job is finished and I want to exit.
So I use ctrl c.
You see, we have an error here, which is not very good.
And also on windows machine, you see that still it is running.
So I need to do something that when I exit from Kali Linux this must be exited to that.
If I use ctrl C here again you see it gives me a very big error here.
That is not very good.
Okay.
So let's go and handle this in both sides.
So in color Linux.
Here you see we are receiving the input from user.
Okay.
Right here I'm going to use a function called split.
So that with split we are going to change this string to kind of list or something like that.
So we have the command.
This command is going to be equal to command dot split okay.
And here I'm going to split this with a space.
Very good.
Now let me print this so you could see what is going on here okay.
So let's comment this I don't want to see I don't want to be this to be executed.
So.
Here let's run this and let's come back to Windows 10.
Run the program from here as well.
Come back here.
For example, I am going to provide dir, which is a very simple command.
You see, it gives me a dictionary.
For example, I use City Desktop and you see it is giving me two elements within a list.
First one is city, the second one is a desktop.
So here we can access this by using its index.
Okay.
Very easy.
Now let's go back here or let me use Ctrl C here and come back here and comment this.
Sorry.
And also remove this print statement from here.
Now here into in the execute remotely function okay.
Here we can do a check with an if statement, and we can check if the first if the first element that
we receive okay, which has an index zero.
If you receive that and that is equal to a keyword for example exit, then we can close the connection.
Okay.
So let's use that if uh if so we have that into command uh variable.
And also we have the command variable here.
So we use command here.
And we use index zero because I want to access the first one.
So if it is equal to anything like exit or close you can name it anything you want.
So you can use it in your program.
If it is equal to this then we can close the connection.
So use self dot connection dot close.
This will close your connection.
And also let's use exit function here.
This will exit the Python program.
And also one more thing Here.
You see, we are sending something here.
And while we are sending, we need to use, uh, this one.
That means we are sending the first element.
Okay, so this is it.
And also let's go back to windows.
Uh, here in windows again we need to handle this okay.
On run function.
Right here okay.
So again here we need to check if the command is equal to the same thing we provide there okay.
If command is equal to exit and lets you solve that connection dot close and also exit the python.
That is it.
But still there is an error.
Let me show you that as well.
And.
I will show you that.
Okay?
Practically.
Now let me use.
Clear.
Okay.
Waiting for connection.
Let's use Ctrl C here.
Right now it is running.
Let's go back to Kali machine.
Okay.
We have a connection.
Now let's use dir and hit enter.
It is working okay.
The simple command is working.
But I'm trying to use exit here.
Okay.
Now when I use exit, it did exit it.
Okay.
But in Windows machine, when I come back here, you see that it's still running.
Let me use Ctrl C here.
Now I'm going to exit that.
That is because while we are sending the Sending the exit from there.
Okay, that comes as a byte.
Okay.
And here we are checking it as a string.
So we need to add a B at the beginning.
Okay.
Let's use single code here.
It's better.
Now I'm saving this and I am going back to Cali machine.
And let's run this again.
Now let's go back to.
Cali mission.
Okay.
I use simple command like dir.
It's working and I use exit.
It is working.
Let's go back to Windows Machine and see that it's also exited.
So perfect.
Now you created a very simple.
I did a very simple command here that is exiting the program.
Okay.
So thanks for watching.