Implementing a reverse shell with sockets
A shell is a program that can work as an interface with the system and the services that it provides us. There are two kinds of connections to perform a successful attack: reverse and direct connection:
- A direct shell on the target machine is one that listens for the connection request, that is, it runs software that acts as a server listening on a specific port, waiting for a client to establish a connection, to hand you the shell. This is a bind shell where the listener is configured and executed on the target machine.
- In a reverse shell attack, a remote system is forced to send a connection request to an attacker-controlled system listening for the request. This creates a remote shell to the target victim’s system. In this case, it’s the target machine that connects to the server and a listener is configured and executed on the attacking machine.
In a reverse shell, it is necessary that the attacker...