a weblog about programming, hacking, linux, and other randomness

My Photo
I'm a Programmer, Hobby Hacker, and Linux Freak.

Wednesday, January 7, 2009

Torify Torrentflux-b4rt

Torrentflux-b4rt is a web based transfer control client. Nothing is more convenient than starting a new download from anywhere, at anytime. Whether it be from a work computer, a friend's computer, or a phone, having this installed on your server is a godsend.

"Tor is a software project that helps you defend against traffic analysis. Though some consider the use of bittorrent over Tor to be counter to the goals of the Tor project, this article does not seek to answer the questions about the validity of any protocol over the Tor network but merely how to do it. Also, be aware that the BT protocol itself my reveal a nodes real IP. Be informed about the technologies you use."

Installation of Torrentflux-b4rt is beyond the scope of this article. Please see How to Setup Ubuntu Torrent Server.

Package Installation
  • Install the Tor and Privoxy packages.
    sudo apt-get install tor privoxy
  • Edit the Privoxy config file to forward requests to Tor
    sudo nano /etc/privoxy/config
  • Uncomment or add the the following line in the Forwarding section:
    forward-socks4a / localhost:9050 .
  • Save and close the file while remembering to restart the Privoxy service.
    sudo /etc/init.d/privoxy restart
Custom BitTornado Client Hack
  • Edit the following file located in the Torrentflux-b4rt directory:
    sudo nano /html/bin/clients/tornado/BitTornado/zurllib.py
  • Add the following to the connect() method defined within the btHTTPcon class:
    self.host = '127.0.0.1'
    self.port = 8118
  • The full method should now read:
    def connect(self):
    # proxy hack start
    self.host = '127.0.0.1'
    self.port = 8118
    # proxy hack end
    HTTPConnection.connect(self)
    try:
    self.sock.settimeout(30)
    except:
    pass
  • Now alter the the _open() method defined within the urlopen class:
    self.connection.request('GET', scheme + '://' + netloc + url, None, { 'User-Agent': VERSION, 'Accept-Encoding': 'gzip' } )
You can test if your trackers are being routed through Tor by enabling the logfile option in /etc/privoxy/config.
tail -50f /var/log/privoxy/logfile
Mon DD HH:MM:SS.mmm Privoxy(437c4950) Request: vip.tracker.thepiratebay.org/announce?info_hash=%198un61bQ%102%7B%0Are%93C%9BD%93%A9%F6%C4%DB%AC%D8&peer_id=T13I-----e.0jIFpqnF7&port=49297&uploaded=138199040&downloaded=686426112&left=50331648&no_peer_id=1&compact=1&key=UKf9P-

Update: zurllib Patch File

Patch: (864 b) zurllib.patch
md5: 7bbb38bdf74a1dbdf7517d129af22e11

Copy patch to /html/bin/clients/tornado/BitTornado/ directory and type:
patch -p0 < zurllib.patch
The custom BitTornado source included with TorrentFlux hasn't been updated in quite some time. If this patch doesn't work for you please comment and I'll try to supply a new one quickly.

0 comments:

Post a Comment