#Linux socat tutorial password
(sleep 5 echo PASSWORD sleep 5 echo ls sleep 1) | The "file" might also be a listening UNIX domain socket (do not use a seek option then). Socat transfers data from file /tmp/readdata (implicit address GOPEN), starting at its current end (seek-end=0 lets socat start reading at current end of file use seek=0 or no seek option to first read the existing data) in a "tail -f" like mode (ignoreeof). This is an example for unidirectional data transfer (-u).
Socat -u /tmp/readdata,seek-end=0,ignoreeof. Please note that there can only be one connection at a time, because TCP can establish only one session with a given set of addresses and ports. So we get a connection to the victims XWindow server and, if it does not require MIT cookies or Kerberos authentication, we can start work. Socat pretends to be invoked by socksuser nobody, and requests to be connected to loopback port 6000 (only weak sockd configurations will allow this). Socat then speaks with the SOCKS4 server that might permit sourceport 20 based connections due to an FTP related weakness in its static IP filters. This path corresponds to local XWindow display :1 on your machine, so XWindow client connections to DISPLAY=:1 are accepted. With UNIX-LISTEN, socat opens a listening UNIX domain socket /tmp/.X11-unix/X1. Socat UNIX-LISTEN:/tmp/.X11-unix/X1,fork \ raw and echo set ttyS0's terminal parameters to practicable values, crnl converts to correct newline characters.
#Linux socat tutorial serial
Opens an interactive connection via the serial line, e.g. Socat makes alias1 your local source address (bind), cares for correct network line termination (crnl) and sends at most 512 data bytes per packet (mss). Because mail.sh inherits stdin and stdout while socat does not use them, the script can read a mail body from stdin. The fdin and fdout options tell socat to use these FDs for communication with the program. It is programmed to "speak" SMTP on its FDs 3 (in) and 4 (out). Mail.sh is a shell script, distributed with socat, that implements a simple SMTP client. Socat and myscript communicate via a pseudo tty (pty) myscripts stderr is redirected to stdout, so its error messages are transferred via socat to the connected client. For EXECuting the program, the child process chroots to /home/sandbox, sus to user sandbox, and then starts the program /home/sandbox/bin/myscript. The client must match the rules for daemon process name "script" in /etc/hosts.allow and /etc/ny, otherwise it is refused access (see "man 5 hosts_access"). Socat TCP4-LISTEN:5555,fork,tcpwrap=script \ĮXEC:/bin/myscript,chroot=/home/sandbox,su-d=sandbox,pty,stderrĪ simple server that accepts connections (TCP4-LISTEN) and forks a new child process for each connection every child acts as single relay. Further logging is directed to syslog with facility local2. With -lmlocal2, socat logs to stderr until successfully reaching the accept loop. It provides a little security by sudoing to user nobody after forking it only permits connections from the private 10 network (range) due to reuseaddr, it allows immediate restart after master processes termination, even if some child sockets are not completely shut down. This example handles an almost arbitrary number of parallel or consecutive connections by forking a new process after each accept(). TCP4:TCP port forwarder, each side bound to another local IP address (bind). With TCP4-LISTEN it listens on local port "socat -d -d -lmlocal2 \ Socat TCP4-LISTEN:Installs a simple TCP port forwarder. The port is specified by service name (www), and correct network line termination characters (crnl) instead of NL are used. http_history socat prints messages about progress (-d -d). TCP4:This is similar to the previous example, but you can edit the current line in a bash like manner (READLINE) and use the history file. Socat -d -d READLINE,history=$HOME/.http_history \ The stdin terminal parameters are not changed, so you may close the relay with ^D or abort it with ^C. Socat - TCP4:Transfers data between STDIO (-) and a TCP4 connection to port 80 of host This example results in an interactive connection similar to telnet or netcat. To send file fro the server: socat TCP:hostname:port filename On the server-side: socat TCP-LISTEN:port filename
Socat READLINE,history=$HOME/.cmd_history /dev/ttyS0,raw,echo=0,crnl Socat TCP-LISTEN:80,fork TCP:To forward terminal to the serial port COM1: To forward local http port to remote http port: Socat /dev/ttyS0,raw,echo=0,crnl /dev/ttyS1,raw,echo=0,crnl To link serial port ttyS0 to another serial port: