Chat with Tor and socat

It is easy to setup a simple chat over Tor using the socat utility. To receive incoming messages you first need to setup a Tor hidden service . Add this to the end of your /etc/tor/torrc file:

HiddenServiceDir /var/lib/tor/hidden-chat/
HiddenServicePort 2330 127.0.0.1:2330

After restarting Tor check the /var/lib/tor/hidden-chat/hostname file for your hidden service .onion address.

Use socat to setup a listener on port 2330, now incoming connections to ADDRESS.onion:2330 will show up on your terminal. Run this on the system where you setup the hidden service.

socat TCP4-LISTEN:2330,bind=127.0.0.1,reuseaddr READLINE

Now people can send you anonymous messages by running the following on the cmdline:

socat READLINE SOCKS4A:127.0.0.1:ADDRESS.onion:2330,socksport=9050

This uses the SOCKS4A protocol to talk to Tor without leaking any DNS lookups. All communications will be encrypted by the Tor network, and the receiver doesn’t have any way to discover who you are, or you them.