Skip to content

Instantly share code, notes, and snippets.

@jjuarez
Created December 12, 2014 15:23
Show Gist options
  • Save jjuarez/c89cadd74e4efdc533db to your computer and use it in GitHub Desktop.
Save jjuarez/c89cadd74e4efdc533db to your computer and use it in GitHub Desktop.
socat tips
# To create a classic TCP listening daemon, similar to netcat -l, use a variation of the following command.
socat TCP-LISTEN:8080 stdout
# use remotly a command shell
socat TCP4-LISTEN:1234,reuseaddr,fork 'SYSTEM:/bin/cat /home/infos.txt'
# SSLfy a server
socat OPENSSL-LISTEN:443,reuse‐addr,pf=ip4,fork,cert=server.pem,cafile=client.crt TCP4-CONNECT:localhost:80
# remote logger on server
socat TCP-LISTEN:5555,reuseaddr,fork SYSTEM:"tail -f /var/log/cassandra/system.log",pty
# client
socat -u TCP:88.190.48.140:5555 STDIO
# make a tunnel
socat TCP4-LISTEN:1022,reuseaddr,fork TCP4:host.foo.com:22
# make a tunnel via with a proxy
socat TCP4-LISTEN:2022,reuseaddr,fork PROXY:proxy:machine.toto.fr:22,proxyport=3128,proxyauth=user:pass
# Installs a simple TCP port forwarder. With TCP4-LISTEN it listens on local port "www" until a connection comes in, accepts it,
# The service running on 172.16.245.11:5432 is forward to 172.16.251.139:5666
socat -d -d -lmlocal2 TCP4-LISTEN:5666,bind=172.16.251.139,su=nobody,fork,reuseaddr TCP4:172.16.245.11:5432
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment