Tor and Onion Services

What is Tor?

Tor is a peer-to-peer overlay routing system that achieves a particular type of anonymity known as unlinkability: an adversary can identify at most one of a source/destination pair, but not both. Tor achieves unlinkable communication by routing traffic through a circuit: a sequence of overlay hosts known as Tor relays. There are typically three relays in a circuit: an entry node (who communicates with the source), a middle node, and an exit node (who communicates with the destination). The source node is responsible for choosing which Tor relays to include in a circuit, and for constructing the circuit. Tor’s default circuit chooses relays almost uni- formly at random, preferring higher-bandwidth nodes and avoiding choosing multiple nodes from the same subnets.

Install Tor

sudo apt update
sudo apt install automake gcc libevent-dev libssl-dev asciidoc make zlib1g-dev
git clone https://github.com/torproject/tor.git
cd tor
sh autogen.sh
sudo ./configure
sudo make
sudo make install
Next, edit the torrc (Tor configuration file).
cd /usr/local/etc/tor/
sudo cp torrc.sample torrc
To start and stop Tor:
tor
sudo killall tor

What are Onion Services?

In addition to connecting to external servers, Tor supports hidden services, which allow users to host services anonymously.

Create Your Own Onion Service

Follow the below-listed instructions to create your own Onion Service. First install Apache and setup a sample website. sudo apt install apache2
cd /var/www/html
sudo nano index.html (set-up a sample website here)
Next, edit the torrc file to host a service (located in /usr/local/etc/tor/torrc). Add the following lines to torrc.
HiddenServiceDir /usr/local/var/lib/tor/hidden_service/
HiddenServicePort 80 127.0.0.1:80
Then, start Apache and launch Tor.
sudo /etc/init.d/apache2 start
tor
Test the hidden service by accessing the .onion address (stored in /usr/local/var/lib/tor/hidden_service/hostname) through a Tor Browser.
Download the source code from Github
Checkout the Bento Poster!