Torifying Socat

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 examplename.onion.

To use pipe Socat via Tor for this connection, simply use the command:

    socat TCP4-LISTEN:4242,bind=,fork SOCKS4A:localhost:examplename.onion:6667,socksport=9050

Note: If you are using Tor browser for your connection you will need to use port 9150.

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.

See also

Last modified 13 months ago Last modified on Sep 22, 2019, 10:35:56 AM