Skip to content

How to use Peasant with Tor and Firefox for browsing

René Klačan edited this page Jun 16, 2014 · 2 revisions
  1. Requirements

Before start you should have Tor and Firefox installed on your system.

  1. Tor

Script for lauching multiple Tor instances

#!/bin/bash

# source: http://blog.databigbang.com/distributed-scraping-with-multiple-tor-circuits/

base_socks_port=9050
base_control_port=8118

# Create data directory if it doesn't exist
if [ ! -d "data" ]; then
  mkdir "data"
fi

# 9050-9090, 8118-8158
for i in {0..40}
do
  j=$((i+1))
  socks_port=$((base_socks_port+i))
  control_port=$((base_control_port+i))
  if [ ! -d "data/tor$i" ]; then
    echo "Creating directory data/tor$i"
    mkdir "data/tor$i"
  fi
  # Take into account that authentication for the control port is disabled. Must be used in secure and controlled environments

  echo "Running: tor --RunAsDaemon 1 --CookieAuthentication 0 --HashedControlPassword \"\" --ControlPort $control_port --PidFile tor$i.pid --SocksPort $socks_port --DataDirectory data/tor$i"

  tor --RunAsDaemon 1 --CookieAuthentication 0 --HashedControlPassword "" --ControlPort $control_port --PidFile tor$i.pid --SocksPort $socks_port --DataDirectory data/tor$i
done
  1. Peasant

Lets assume that Peasant installation is succesfully behind us.

Now let's create script that will create single proxy that will handle forwarding to Tor instances

require 'peasant'

nodes = (9050..9090).map { |port| { host: '127.0.0.1', port: port } }
Peasant::Server.run host: '127.0.0.1', port: 9999, nodes: nodes

And run it!

  1. Firefox

Go to Preferences -> Advanced -> Connection -> Settings.

Select manual proxy configurations and put "127.0.0.1" into the SOCKS Host and "9999" into the Port and close it.

Visit http://wtfismyip.com/text and feel free to press CTRL + F5 and you will see that you have a new IP.

So if you are visiting casual site with lot of assets then every single asset is loaded via different Tor connection (different IP).