🖥️socat

➡️This is a command-line reference manual for commands and command combinations that you don’t use often enough to remember it. This cheatsheet explains the socat command with important options and switches using examples.

▁ ▂ ▃ ▄ ꧁ 🔴☠ COMMANDLINE-KUNGFU WITH CHEATSHEETS ☠🔴꧂▅ ▃ ▂ ▁

#                ███████╗ ██████╗  ██████╗ █████╗ ████████╗
#                ██╔════╝██╔═══██╗██╔════╝██╔══██╗╚══██╔══╝
#                ███████╗██║   ██║██║     ███████║   ██║   
#                ╚════██║██║   ██║██║     ██╔══██║   ██║   
#                ███████║╚██████╔╝╚██████╗██║  ██║   ██║   
#                ╚══════╝ ╚═════╝  ╚═════╝╚═╝  ╚═╝   ╚═╝   
                                                          
                

socat "UNIX-LISTEN:/tmp/mysqld.temp.sock,reuseaddr,fork" EXEC:"ssh [email protected] socat STDIO UNIX-CONNECT\:/var/run/mysqld/mysqld.sock"
# Linux socket-to-socket tunnel (MySQL example)

socat "UNIX-LISTEN:/tmp/mysqld.temp.sock,reuseaddr,fork" EXEC:"ssh [email protected] -i /home/user/rsa-keys/id_rsa socat STDIO UNIX-CONNECT\:/var/run/mysqld/mysqld.sock"
# Will not work with password login. You must add your RSA key to the server his authorizedkeys file, or change the ssh command adding the -i option for a custom RSA key. /tmp/mysqld.temp.sock will be created locally by socat, don't create it yourself. The folder it lives must be writable. Connect your MySQL client to this socket, with database and username set properly.

socat -d -d TCP-L:22,reuseaddr,fork SYSTEM:"nc \$SOCAT_PEERADDR 22" 
# Confuse people SSHing to your host with a redirect back to theirs.

socat -v UDP-LISTEN:8161,fork TCP:localhost:8161 
# Encapsulate UDP packets in a TCP stream so it can be tunneled through an SSH tunnel, etc

#==============================##==============================#
# CMD SOCAT						       #
#==============================##==============================#
░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░

  █║▌│║█║▌★ KALI ★ PARROT ★ DEBIAN 🔴 PENTESTING ★ HACKING ★ █║▌│║█║▌

              ██╗ ██╗ ██████╗  ██████╗ ██╗  ██╗███████╗██████╗
             ████████╗██╔══██╗██╔═══██╗╚██╗██╔╝██╔════╝██╔══██╗
             ╚██╔═██╔╝██║  ██║██║   ██║ ╚███╔╝ █████╗  ██║  ██║
             ████████╗██║  ██║██║   ██║ ██╔██╗ ██╔══╝  ██║  ██║
             ╚██╔═██╔╝██████╔╝╚██████╔╝██╔╝ ██╗███████╗██████╔╝
              ╚═╝ ╚═╝ ╚═════╝  ╚═════╝ ╚═╝  ╚═╝╚══════╝╚═════╝

               █║▌│║█║▌ WITH COMMANDLINE-KUNGFU POWER █║▌│║█║▌

░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░