Last active
September 11, 2024 17:39
-
-
Save fsodogandji/8521333 to your computer and use it in GitHub Desktop.
socat tips & tricks
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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' | |
#sslify 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 -u OPEN:/var/log/cassandra/system.log,seek-end=1000,ignoreeof TCP-LISTEN:5555,reuseaddr,fork | |
or | |
socat TCP-LISTEN:5555,reuseaddr,fork SYSTEM:"tail -f /var/log/cassandra/system.log",pty | |
#on 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
try:
sudo socat -d -d /dev/ttyUSB0,raw,echo=0,b9600 tcp-listen: 4641,reuseaddr
andsudo socat PTY,raw,echo=0,link=/dev/ttyVUSB0 tcp:192.168.0.24: 4641