How to Proxify Applications with Tor, Torsocks and Torify

By | August 17, 2020

Many applications do not directly support the use of socks proxy. It is not possible to configure them in anyway to use a proxy server.

Torsocks enables such applications to use the Tor Socks proxy.

It automatically routes all network requests made by a certain application through the Tor proxy.

The manual page defines Torsocks as following:

Shell wrapper to simplify the use of the torsocks library to transparently allow an application to use a SOCKS proxy.

Install Tor and Torsocks

Torsocks gets installed along with the tor package on ubuntu for example

$ sudo apt-get install tor

Configure Tor ControlPort so that you can monitor its status using other programs like Nyx.

Edit the following

$ sudo nano /etc/tor/torrc

And un-comment the Control Port line:

## The port on which Tor will listen for local connections from Tor
## controller applications, as documented in control-spec.txt.

ControlPort 9051

Now restart Tor.

$ sudo service tor restart

Now check whether Tor control port is open or not using netstat command:

$ sudo netstat -plnt | fgrep 905
[sudo] password for enlightened:
tcp        0      0 127.0.0.1:9050          0.0.0.0:*               LISTEN      31285/tor
tcp        0      0 127.0.0.1:9051          0.0.0.0:*               LISTEN      31285/tor
$

As you can see 9050 is the Socks proxy port which is open, and 9051 is the Tor control port which is also open.

Install Nyx

Nyx is a command-line monitor for Tor. With this you can get detailed real-time information about your relay such as bandwidth usage, connections, logs, and much more.

Along with Tor it is also recommended that you install Nyx. It allows you to monitor the status of Tor service and how much bandwidth is being used by Tor.

$ sudo apt-get install nyx

Now run nyx with sudo

$ sudo nyx

You should see some output similar to this:

Proxify applications

After you are done installing Tor and Nyx, its time to proxify applications to make them communicate via the Tor network.

Lets say you want to fetch a remote url using the curl command. It would look something like this when not using any proxy server:

$ curl https://api.ipify.org?format=json
{"ip":"122.163.63.58"}

The url https://api.ipify.org?format=json shows our own ip address. When not using any proxy it will show our real ip address.

Now use it with torsocks.

$ torsocks curl https://api.ipify.org?format=json
{"ip":"192.160.102.164"}

Now the ip is changed because the url was opened through the tor proxy.

Conclusion

Check the Torsocks project homepage to find out what applications work well with torsocks.
https://github.com/dgoulet/torsocks

For example pidgin works with torsocks. You could proxify Piding with torsocks like this:

$ torsocks pidgin

If you have any feedback or questions, let us know in the comments below.

About Silver Moon

A Tech Enthusiast, Blogger, Linux Fan and a Software Developer. Writes about Computer hardware, Linux and Open Source software and coding in Python, Php and Javascript. He can be reached at [email protected].

2 thoughts on “How to Proxify Applications with Tor, Torsocks and Torify

  1. mtyamantau

    Thanks for this. It helps a lot for routing separate processes to the Tor network without going through SOCKS proxy configuration and socat.

Leave a Reply

Your email address will not be published. Required fields are marked *