Skip to main content

practical_examples

socat -u STDIO TCP4:127.0.0.1:9999
# all the data received by keyboard will be sent to the specified address,
# this can be used for simple keyloggers
# the -u ensures that the communication is unidirectional and no data from the
# second address will be sent back to STDIO
socat TCP4:127.0.0.1:2222 TCP4:127.0.0.1:9999
# this will forward all the traffic from port 2222 to port 9999
# and all traffic from port 9999 to port 2222, so a bidirectional
# traffic flow, the two ports are connected
# notice that port 2222 must be already open
socat -u TCP4:127.0.0.1:2222 TCP4:127.0.0.1:9999
# this will forward all the traffic from port 2222 to port 9999
# notice that this is a unidirectional channel, no traffic can go the
# other way from port 9999 to port 2222
# notice that port 2222 must be already open
socat TCP-LISTEN:8080,fork,reuseaddr TCP:google.com:443
# in this way we use our machine as a forwarder to google.com on port 443
# so everytime somebody tries to access our IP on port 8080 it will be
# redirected to google.com