Socat is a command line based utility that establishes two bidirectional data streams and transfers between them. This data can take many forms such as files, pipes, devices (terminal or modems), or sockets (UNIX, IPv4, IPv6, TCP, SSL etc). The streams can be constructed from a large and diverse selection of data sinks, sources and address options, which allows Socat to be highly flexible in its usage. It is for this reason that it and similar tools are often referred to as multipurpose relays.
Using Socat with Tor
Below is an example of utilising Socat to relay traffic from a remote server. While the example shows how to connect to an
.onion service, these steps work the exact same way for clear-net facing servers and connections.
Suppose you would like to connect to an IRC network called
To use pipe Socat via Tor for this connection, simply use the command:
socat TCP4-LISTEN:4242,bind=127.0.0.1,fork SOCKS4A:localhost:examplename.onion:6667,socksport=9050
Note: If you are using Tor browser for your connection you will need to use port
How it works
This command informs Socat to build a connection between your local system on port 4242 and examplename.onion on port 6667, via your Tor SOCKS proxy on port 9050. Simply connect to localhost on port 4242 to utilise it.