Socat

=== serial ===
# Create virtual serial port , open in two terminals 
# https://www.youtube.com/watch?v=iFmD-CeB96A 
socat -d -d pty,raw,echo=0 pty,raw,echo=0 
dmesg | grep tty 
cat < /dev/pts/11 
echo “test string “ > /dev/pts/12 
 
https://superuser.com/questions/771155/impersonate-a-serial-device-with-socat?rq=1 
=== usb ===
socat and usb 
https://www.lucid-control.com/accessing-usb-io-module-network-linux-socat/ connect network port to usb 
https://jamesthom.as/2021/01/virtual-serial-ports-using-socat/ 
https://serverfault.com/questions/453032/socat-to-share-a-serial-link-between-multiple-processes?rq=1. serial between multiple processes , pipes socat to socat 
https://serverfault.com/questions/360321/forwarding-linux-terminal-from-serial-port-to-tcp-with-socat?rq=1 
https://serverfault.com/questions/154573/serial-port-forwarding-over-tcp-ip-linux-server?rq=1 
https://serverfault.com/questions/384741/forwarding-serial-port-over-network-and-back-to-serial-char-device-on-remote-hos?rq=1 
https://www.domoticz.com/wiki/SharingSerialDevices WIKI 
https://stackoverflow.com/questions/35998803/pppd-over-socat-using-interface-option?rq=1 for realpath of symlink for direct path 
https://stackoverflow.com/questions/5890505/socat-tunnel-ip-through-tty?rq=1
https://stackoverflow.com/questions/27837627/ip-tunnel-over-linux-serial-default-shell?noredirect=1&lq=1
=== server ===
https://serverfault.com/questions/693089/socat-tcp-file-server 
https://serverfault.com/questions/246347/whats-the-difference-between-socat-and-netcat?rq=1 
https://serverfault.com/questions/346481/echo-server-with-netcat-or-socat?rq=1 
https://serverfault.com/questions/414350/access-d-bus-remotely-using-socat?rq=1 
https://serverfault.com/questions/405518/how-to-configure-d-bus-and-ssh-x-forwarding-to-prevent-ssh-from-hanging-on-exit?rq=1 
https://serverfault.com/questions/768942/socat-create-returning-bad-file-descriptor?rq=1 
https://serverfault.com/questions/655715/always-keep-socat-alive?rq=1 
=== netcat ===
https://serverfault.com/questions/651979/how-to-redirect-a-udp-response-with-netcat?rq=1 
https://serverfault.com/questions/207683/listen-to-udp-data-on-local-port-with-netcat?rq=1 
https://serverfault.com/questions/457433/proxy-with-netcat-forever?rq=1 
https://serverfault.com/questions/959699/ssh-connection-using-proxy-instead-of-port-forwarding?rq=1 
=== proxy ===
https://serverfault.com/questions/254855/socat-connect-connect-proxy-two-inbound-tcp-connections-to-expose-a-firewalled 
https://gist.github.com/lene/a517e635de86e73f6a981b0b584fb68a ssh over tor with socks4 
=== socks5 ===
https://github.com/runsisi/socat fork of socat with socks5 support 
=== mkfifo ===
https://unix.stackexchange.com/questions/195880/socat-duplicate-stdin-to-each-connected-client 
refs 
https://stackoverflow.com/questions/17480967/using-socat-to-multiplex-incoming-tcp-connection 
https://gist.github.com/mathieue/3505472 udp multicase 
---------------------------
https://stackoverflow.com/questions/28032549/socat-terminates-after-connection-close?rq=1 
https://stackoverflow.com/questions/36575588/socat-not-closing-tcp-connection?rq=1
=== terminals ===
https://superuser.com/questions/1100342/socat-and-rich-terminal-again?noredirect=1&lq=1 from https://superuser.com/questions/123790/socat-and-rich-terminals-with-ctrlc-ctrlz-ctrld-propagation Signals nor tty ownership cannot be 'magically' carried over a socket.
Over AF_UNIX, you could send the tty file descriptor itself (using sendmsg and recvmsg) and have the receiving side use it (and not the socket) as the subprocess' stdout/stderr. This cannot be done with plain socat, but this method is used internally by e.g. the tmux tool. ssh
https://github.com/darkk/redsocks 
https://github.com/vi/tcpsocks 
https://github.com/vi/websocat Proxy TCP connections to WebSocket connections and back. 
=== tor ===
https://superuser.com/questions/615140/ssh-tunnel-with-socat-and-tor?rq=1 torsocks 
=== system ===
https://stackoverflow.com/questions/1697440/difference-between-system-and-exec-in-linux system() calls out to sh to handle your command line, so you can get wildcard expansion, etc. exec() and its friends replace the current process image with a new process image. With system(), your program continues running and you get back some status about the external command you called. With exec(), your process is obliterated. In general, I guess you could think of system() as a higher-level interface. You could duplicate its functionality yourself using some combination fork(), exec(), and wait(). To answer your final question, system() causes a child process to be created, and the exec() family do not. You would need to use fork() for that. 
The exec function replace the currently running process image when successful, no child is created (unless you do that yourself previously with fork()). The system() function does fork a child process and returns when the command supplied is finished executing or an error occurs. Refs UNIX Systems Programming for SVR4, David Curry 
https://man7.org/linux/man-pages/man3/system.3p.html 
=== gists ===
https://gist.github.com/cfra/752d6e761225fd5bf783b44abe30f707#file-ethernet-socat-ssh-md 
https://gist.github.com/lene/a517e635de86e73f6a981b0b584fb68a socat socks4 over tor 
https://gist.github.com/staaldraad/a3cb590e6ec48c25c55af84eec03b97d socat via proxy(staaldraad) 
https://gist.github.com/staaldraad/f5a9c6acab980a62f981 python listener 
=== links ===
https://www.pentestpartners.com/security-blog/socat-fu-lesson, (https://archive.ph/Zhe1u) uses netsed 
--------------------------------------------------------------------
http://www.dest-unreach.org/socat/doc/socat.html MAN page 
--------------------------------------------------------
#https://github.com/positron-solutions/unixsocks Want to ssh over a tor service but socat doesn't accept unix addresses and you've configured your tor client to serve local clients over a unix socket? This is your tool
#http://www.dest-unreach.org/socat/doc/linuxwochen2007-socat.pdf
#http://www.dest-unreach.org/socat/doc/
#https://github.com/freelan-developers/freelan and http://www.freelan.org/ VPN client
#http://www.pocketnix.org/posts/Linux%20Networking:%20MAC%20VLANs%20and%20Virtual%20Ethernets
#https://www.redhat.com/sysadmin/getting-started-socat
#https://www.linux.com/news/socat-general-bidirectional-pipe-handler/ VPN with single line
#https://github.com/craSH/socat/blob/master/EXAMPLES
https://copyconstruct.medium.com/nonblocking-i-o-99948ad7c957 by Cindy Sridharan
https://copyconstruct.medium.com/socat-29453e9fc8a6 fd by Cindy Sridharan 
https://gist.github.com/ntamas/591513 copy file to dropbox ,uses socat 
https://stackoverflow.com/questions/16956810/how-to-find-all-files-containing-specific-text-string-on-linux?rq=1 
=== pentesting ===
https://gist.github.com/opnchaudhary/3731935 yum repositories 
https://gist.github.com/denji/84b7b6a07b318ca89919 penetration testing cheat sheet 
ssh#dergachev 
posix 
Category:Linux shell scripting