Torsocks acts as a network wrapper around linux applications. This allows them to work on the Tor network where that might not normally be possible. If the application that you are working with already has functionality that allows it to take advantage of a SOCKS5 proxy, then you can use Tor’s built in proxy to do that. However if the application doesn’t have that functionality, you can try to use Torsocks instead.

Note: A word about anonymity. The point of the Tor network is to be anonymous. If you want to maximize anonymity, use the Tor Browser. However, sometimes you need to do things that the Tor browser can’t do easily. In this post, I’m going to focus on using Torsocks with curl (cURL) and wget. Both of these tools are miminal web clients. While they can be fingerprinted as being not Tor Browser, the actual amount of metadata they provide is pretty tiny and it would be incredibly difficult to de-anonymize someone using them for basic downloads.

The first thing that you need to do is to install the tor daemon and torsocks to your linux distro. Here are a couple of example of how to do that:

Debian/Ubuntu

sudo apt install tor torsocks

openSUSE

sudo zypper in tor torsocks

You can then enable and start the tor daemon by running:

sudo systemctl enable --now tor

Once the systemd service is started, you can use torsocks. There is no reason to edit the torrc file or anything else. Let’s get the current weather using curl and torsocks:

torsocks curl wttr.in
Weather report: Amsterdam, Netherlands

     \  /       Partly cloudy
   _ /"".-.     +7(5) °C       
     \_(   ).   ↘ 15 km/h      
     /(___(__)  10 km          
                0.5 mm         
                                                       ┌─────────────┐                                                       
┌──────────────────────────────┬───────────────────────┤  Fri 05 Jan ├───────────────────────┬──────────────────────────────┐
│            Morning           │             Noon      └──────┬──────┘     Evening           │             Night            │
├──────────────────────────────┼──────────────────────────────┼──────────────────────────────┼──────────────────────────────┤
│  _`/"".-.     Light rain sho…│      .-.      Light drizzle  │  _`/"".-.     Patchy rain po…│  _`/"".-.     Patchy rain po…│
│   ,\_(   ).   +7(4) °C       │     (   ).    +6(3) °C       │   ,\_(   ).   +6(4) °C       │   ,\_(   ).   +6(3) °C       │
│    /(___(__)  ↖ 20-30 km/h   │    (___(__)   ↖ 17-24 km/h   │    /(___(__)  ↘ 14-20 km/h   │    /(___(__)  ↘ 14-21 km/h   │
│      ‘ ‘ ‘ ‘  10 km          │     ‘ ‘ ‘ ‘   2 km           │      ‘ ‘ ‘ ‘  10 km          │      ‘ ‘ ‘ ‘  10 km          │
│     ‘ ‘ ‘ ‘   0.2 mm | 100%  │    ‘ ‘ ‘ ‘    0.7 mm | 100%  │     ‘ ‘ ‘ ‘   0.0 mm | 67%   │     ‘ ‘ ‘ ‘   0.0 mm | 62%   │
└──────────────────────────────┴──────────────────────────────┴──────────────────────────────┴──────────────────────────────┘
                                                       ┌─────────────┐                                                       
┌──────────────────────────────┬───────────────────────┤  Sat 06 Jan ├───────────────────────┬──────────────────────────────┐
│            Morning           │             Noon      └──────┬──────┘     Evening           │             Night            │
├──────────────────────────────┼──────────────────────────────┼──────────────────────────────┼──────────────────────────────┤
│               Overcast       │  _`/"".-.     Patchy rain po…│  _`/"".-.     Patchy rain po…│  _`/"".-.     Patchy rain po…│
│      .--.     +4(0) °C       │   ,\_(   ).   +4(0) °C       │   ,\_(   ).   +3(-2) °C      │   ,\_(   ).   +2(-2) °C      │
│   .-(    ).   ↓ 18-25 km/h   │    /(___(__)  ↓ 17-24 km/h   │    /(___(__)  ↓ 18-25 km/h   │    /(___(__)  ↙ 19-26 km/h   │
│  (___.__)__)  10 km          │      ‘ ‘ ‘ ‘  10 km          │      ‘ ‘ ‘ ‘  10 km          │      ‘ ‘ ‘ ‘  10 km          │
│               0.0 mm | 0%    │     ‘ ‘ ‘ ‘   0.0 mm | 84%   │     ‘ ‘ ‘ ‘   0.0 mm | 89%   │     ‘ ‘ ‘ ‘   0.0 mm | 68%   │
└──────────────────────────────┴──────────────────────────────┴──────────────────────────────┴──────────────────────────────┘
                                                       ┌─────────────┐                                                       
┌──────────────────────────────┬───────────────────────┤  Sun 07 Jan ├───────────────────────┬──────────────────────────────┐
│            Morning           │             Noon      └──────┬──────┘     Evening           │             Night            │
├──────────────────────────────┼──────────────────────────────┼──────────────────────────────┼──────────────────────────────┤
│     \   /     Sunny          │     \   /     Sunny          │     \   /     Clear          │     \   /     Clear          │
│      .-.      0(-6) °C       │      .-.      +1(-4) °C      │      .-.      0(-4) °C       │      .-.      0(-5) °C       │
│   ― (   ) ―   ↙ 21-31 km/h   │   ― (   ) ―   ↙ 21-28 km/h   │   ― (   ) ―   ↙ 16-25 km/h   │   ― (   ) ―   ↙ 14-23 km/h   │
│      `-’      10 km          │      `-’      10 km          │      `-’      10 km          │      `-’      10 km          │
│     /   \     0.0 mm | 0%    │     /   \     0.0 mm | 0%    │     /   \     0.0 mm | 0%    │     /   \     0.0 mm | 0%    │
└──────────────────────────────┴──────────────────────────────┴──────────────────────────────┴──────────────────────────────┘

Follow @igor_chubin for wttr.in updates

I’m not in Amsterdam, so why did it give me the weather for Amsterdam? Because that’s where the Tor exit node is. If I change the url for the weather from torsocks curl wttr.in to torsocks curl wttr.in/chicago, I will get the weather for Chicago. This is just a very simple example of how to use torsock with curl.

wget works the same way. Let’s get an ebook copy of the US Constitution from Project Gutenberg in epub format.

torsocks wget https://www.gutenberg.org/ebooks/5.epub.noimages -O uscontitution.epub
--2024-01-05 09:01:50--  https://www.gutenberg.org/ebooks/5.epub.noimages
Resolving www.gutenberg.org (www.gutenberg.org)... 152.19.134.47, 2610:28:3090:3000:0:bad:cafe:47
Connecting to www.gutenberg.org (www.gutenberg.org)|152.19.134.47|:443... connected.
HTTP request sent, awaiting response... 302 Found
Location: https://www.gutenberg.org/cache/epub/5/pg5.epub [following]
--2024-01-05 09:01:50--  https://www.gutenberg.org/cache/epub/5/pg5.epub
Reusing existing connection to www.gutenberg.org:443.
HTTP request sent, awaiting response... 200 OK
Length: 69326 (68K) [application/epub+zip]
Saving to: ‘uscontitution.epub’

uscontitution.epub                              100%[======================================================================================================>]  67,70K  --.-KB/s    in 0,05s   

2024-01-05 09:01:50 (1,25 MB/s) - ‘uscontitution.epub’ saved [69326/69326]

In this example, I just used wget as a downloader against the url of the ebook and I used the -O flag to specify the filename that I wanted it saved to.

One final note, if the website that you want to use curl, wget, or any other tool or application against does not allow Tor users, then this will not work. There’s no silver bullet to getting around those IP blocks.