Tor, torify, and torsocks

Using the Tor Bundle, torify, and torsocks for testing public services

Tor is a great tool for protecting your network traffic by keeping you anonymous. Tools provided by the Tor project can also be really useful for testing your own network.

Tor Bundle

If you go to the Tor Project download page, you'll be able to download and get the Tor Browser Bundle. The bundle includes the Tor software itself, and a patched version of Firefox ESR, preconfigured for use with Tor. The bundle is the recommended way of browsing through the Tor network.

Once the bundle is installed, you can browse your own sites and services from URL's outside your own network. This is really great for making sure your sites are configured properly from the view point of both regular users and also allows you to see your site from the viewpoint of those with more malicious intent.

Torify

In addition to (or instead of) the bundle, you can install the Tor software on your system so you can get access to, among other things, torify. This is a utility that makes it possible to configure applications for use with the Tor network, without having to build in support natively. In addition to the HOWTO, this post on Linuxaria is a short example of how to setup and use torify.

Quick Install Guide

Here's a very quick overview of getting it installed and configured:

OSX

Install Homebrew, if not already installed

$ ruby -e "$(curl -fsSL https://raw.github.com/Homebrew/homebrew/go/install)" 

Install and configure Tor

$ brew install tor $ sudo cp /usr/local/etc/tor/torrc.sample /usr/local/etc/tor/torrc $ sudo vi /usr/local/etc/tor/torrc 

Uncomment the ControlPort 9051 and CookieAuthentication 1 lines, then change CookieAuthentication 1 to CookieAuthentication 0 to disable authentication. DO NOT do this on a shared computer.

Start Tor

$ tor & 

Ubuntu/Debian

Install and configure Tor

$ sudo apt-get install tor $ sudo vi /etc/tor/torrc 

Uncomment the ControlPort 9051 and CookieAuthentication 1 lines, then change CookieAuthentication 1 to CookieAuthentication 0 to disable authentication. DO NOT do this on a shared computer. Then restart tor:

$ sudo /etc/init.d/tor restart 

OSX and Ubuntu/Debian

Make a new "session"

$ echo -e 'AUTHENTICATE ""\r\nsignal NEWNYM\r\nQUIT' | nc 127.0.0.1 9051 

Test torify

This should show you your public IP:

$ curl ifconfig.me 

This should show a completely different IP (and outputs torify error messages to /dev/null):

$ torify curl ifconfig.me 2> /dev/null 

Torsocks

It's important to understand that torify can easily be misused unless you know exactly what you're doing, so there's another program called torsocks which helps preconfigure torify for most socks-friendly applications. The torsocks project homepage explains how to install and use it. It also shows which applications it has been successfully tested for use with.

To get up and running, follow the quick install guide for torify in the previous section, then follow these instructions:

OSX

$ brew install torsocks 

Ubuntu/Debian

The torsocks command should be installed with the tor package from the Ubuntu/Debian repositories.

Test Torsocks

With tor running, the following command should show your public IP address:

$ wget -qO- http://ipecho.net/plain ; echo 

And the following command should return a different IP address:

$ torsocks wget -qO- http://ipecho.net/plain 2> /dev/null ; echo 

NOTE: the torsocks homepage lists wget as not being 100% safe, which is due to probable leaks through http headers.

Final Thoughts

With the Tor Bundle, testing websites on your own network from the eyes of the public becomes really simple, and really easy. With just a little more complexity, torify and torsocks can enhance these abilities by letting you run commandline utilities and scripts anonymously in the eyes of your network!