Hello everybody and welcome back into the first tutorial of our actually backdoor coding.
So what we will do right now is we will try to recreate some of the functions and some of the things
that we saw in the previous section which was the metal plate or system hacking section.
Now we saw that in order for us to run our maternity shell on target we had to actually set up a listener
and run the shell on target system.
So this is exactly the same that we all tried to do right now with the code two programs in Python.
One would be the server which will be listening for incoming connections and one will be the payload
or the reverse shell which we have to deliver to the target.
Any way you like whether it is over email or some message or link or if it is just to simply do is B
deliver method.
So here I have some picture right here.
So let me open it which basically shows what we have to do in order to create the server and reverse
shell.
So there is a module or library in Python called socket library.
We will have to import that.
We talked about in the python basics What importing libraries mean and what and how they help us in
our code production.
And we will use that library in order to create a connection between our P.C. and the target b c as
we can see as this server is a program that will run on our killer Linux machine and the client is basically
a reverse shell which we have to deliver and these right here are just some of the functions that we
will have to use in order to properly make a connection between these two pieces as we can see we will
use our three way handshake using DCP in order to make our program.
We will not be coding and UDP backdoor we will use it DCP these first commands.
As it says right here server creating listening socket.
So we have to listen for incoming connections the same thing as we did in the metals play framework
when we use the exploit multi handler and set up a listener on a local host and on local port then we
wait for our target to execute our program and then we get the mortar shell back just in this case we
will not get the metal shell back we will get the shell that we create as we can see as soon as the
target finishes or execute this connect function we will be accepting the connection and establishing
connection we are three way handshake and then we will be able to send and receive commands as long
as we want.
Now another key thing to say right here is that we will use a while loop which we also covered in Python
basics but right now what we will do is we will use an infinite while loop.
We had our simple example of an infinite lot while loop it before.
Basically what we want to do is to be able to execute system commands and Target B C for as long as
we want and then we should specify for example a command which is queue or exit or anything like that.
The string that we will type in in order to actually break the connection and in order to close the
reverse shell connection.
So we will have to put these two functions on both of our codes or both of our programs in a while loops
so they can both send and receive indefinitely as we can see clients sending the data server assuming
the data is when a client uses some function and server uses received function that's how we will receive
the command output that we run on Target B C and we run the command itself or we send the command itself
to the target via the send command or send function that is built into the socket library as we can
see servers sending data and client receiving data after that we have to once we specified our Q command
or an exit command depending on what we were code we should be closing the connection with the target.
So that's how we can close the reverse shell.
Now this is just the basic server and client and type of program.
What we want to do after we actually code the connection we want to actually be able to execute some
more things such as for example running a screen shot on target system and actually getting that screenshot
into our calisthenics machine or a poor example running key logger or making a persistent shell or making
a registry key in order for us to be able to run the shell whatever system reboots or whenever target
system reboots.
So we want to build in all of those functions and make it as close as possible to the metal plate framework.
Metropolitan Shell will try to do that.
Of course we will not use all of the options in Metro protrusions that would take too long to code and
possibly would break somewhere since right now we will not be running a properly written code.
We only want to write our code that actually works.
It doesn't matter if it is pretty or not for us we want it to work and we don't want it to break.
So simple as that.
Now what I said before is that we actually coded the while loop for these instructions were not for
those instructions about recorded something similar.
So right now I'm in my python programs.
Let me just enlarge this so you can see it a little bit better.
Let me just find out which program was the while loop.
Let me just get one by one so I can find it actually.
So possibly six nodes those classes cat Python 3 maybe that is for.
So it's Python for.
So here it is.
If I now know Python 4 not be why here we can see a simple Use a while loop that we will actually use
something similar in our program.
So we can as we said the x value to be true and while true we will run this program so we will run it
forever until the user types in Q which then after that we'll break the break the loop and exit the
program.
So we want to actually deploy something similar to this.
So now without actually delaying this let's actually get started into coding a server and a simple server
and a simple backdoor for the beginning.
So that would be about it for this tutorial and I hope I see you in the next one where we start coding
by.