Okay, now the program is working.
Okay.
I am listening on this port.
Let's execute this again.
I am coming back to my Kali machine.
It is in connection established here.
If I use dir, it is showing me.
What if I use city?
While I use city and hit enter.
You see, it is showing me this now again.
If I use dir still in this location.
If I use city to this top.
Okay, this pop, you see it is not working okay?
And that is because we are using netcat right now.
Okay.
So we are using the netcat program here to establish the connection or to as a listener actually.
And.
It.
Uh, when I come back here, you see, it gives me the city desk that is not working.
Returned non-zero exit status one.
The good way is to.
Inside the column machine, you need to create your own listener by using socket.
So let's go and create our own listener here.
Okay I have the listener file here.
And now let's use this file to create a listener okay.
In Kali Linux machine instead of using netcat here.
So here again we are going to use socket library.
So you need to import socket okay.
Here let's create a listener object I'm going to create listener.
This is equal to.
We have the socket dot Socket.
Okay, here we have two things.
Okay.
One of them is socket.
Dot.
Uh, a f underscore.
In it, and also we have another thing which is socket dot f underscore.
Not really.
If it was is for xk underscore uh string that is here okay.
Now we have our object which is the listener object.
Now I can use these um, to listen.
Okay.
So let's use it.
We have And listener dot asset socket option.
Here we need to give the socket dot.
Esol underscore.
It is not giving me suggestion.
It is giving me very slowly.
And this is going to be socket which is the last one here.
This one okay.
And the next one is we have another option.
And that is socket.
Uh socket dot is or.
Underscore r e use adder or something like that.
This one.
Okay.
So now we have the socket option.
And we have one more thing here that is to set it to number one.
Okay.
If you go to um socket documentation you will find all this thing there.
And also we need to build the connection.
So let's use again listener dot bind okay.
Which is going to be a connection.
So here we need to give the IP address for the listener.
So the listener is called Linux.
We give it ten 0 to 4.
And also the port which is going to be 444.
And now this will build the connection.
Okay.
This will listen that.
So here you need to give one more one extra parenthesis.
Okay.
The next thing is to accept this, okay?
Accept the connection.
And we are done here now.
And before we accept and after we accept, we can print something, a text or a message or something.
So here I need to print.
For example.
Waiting.
Waiting for incoming connection.
Okay.
And also down here, after it is connected, we can have another text message like connection established
or something like that.
Okay.
Connection established or got a connection.
Got a connection.
Okay, now, if I save this and go back here, let's use Python.
We have listener.py.
While I'm executing this it is giving me an error and that is uh waiting for incoming or waiting for
incoming connection.
And then it is giving me an error.
What is that?
Line seven okay.
Listener dot accept is an error here.
Okay.
So the problem is with accept method.
Okay.
Let's go back here and see the accept method if zero here and go back here.
Yea, but you re-execute this and still it gives me an error.
It says that it actually takes one positional argument, but two were given before it wasn't like this.
Okay, so invalid argument.
Let's see what is the problem.
Okay, the problem is with this.
We don't need to give any argument here.
Okay.
And here after we try to build the connection we need to listen.
Okay I forgot to give this here.
Okay, listen.
Now give zero here.
Save it and go back to your terminal.
Try to execute the program.
Waiting for incoming connection.
Go to your windows machine.
Okay, let's execute this once again.
It says that connection And receive,
uh.
Okay.
We don't need to, uh, send anything from here.
Let me remove this from here.
Now.
Okay.
Got, uh, connection.
Okay, so now you see that we got the connection here.
This message, when this message is printed.
So it is showing that, uh, this part, the listening listener dot accept part has been executed.
So that means the connection is now between the Polly and Linux, and windows is established for a while,
for a small time.
Okay.
And then we got this message.
Got a connection.
So perfect.
Let's go and continue this.