How to use Wget with Tor Bundle in Linux

100

Solution 1

on Ubuntu or Debain, install package "torsocks"

sudo apt-get install torsocks

on Mac OS X install via homebrew

brew install torsocks

After that, use wget like this:

torsocks wget http://foo.onion/data.bar

Solution 2

Use Torify, which is a simple wrapper for torsocks and Tor, for example:

$ torify curl ifconfig.me
$ torify wget -qO- -U curl ifconfig.me

Before using, make sure your Tor server is up and running.

See also: How to anonymize the programs from the terminal? at Tor SE

Solution 3

Tor standalone only includes a SOCKS proxy for connecting to the Tor network, and the Tor browser bundle doesn't add any additional proxies.

The usual method of dealing with programs that require an HTTP proxy is to install one of your own, such as Privoxy or Polipo, then chain that proxy to Tor. For instance, in Privoxy's configuration, you would specify:

forward-socks5  /  127.0.0.1:9050 .

Privoxy then listens on port 8118 and you configure your HTTP proxy setting to http://localhost:8118.

Unfortunately it appears that Linux Mint doesn't carry either of these packages in its repositories. You might consider switching distributions, or compiling one yourself.

Solution 4

This is a summary of the excellent answer for the post
How can Wget be configured to work with Torify securely?

Here's how Tails does it:

#!/bin/sh
unset http_proxy
unset HTTP_PROXY
unset https_proxy
unset HTTPS_PROXY

exec torsocks /usr/lib/wget/wget --passive-ftp "$@"

This script is set as the default wget (through dpkg-divert, so that non-torified wget would be hard to accidentally run) and will wrap any call to wget.

The call to wget may need to be modified to the local operating system, for example /usr/bin/wget for Ubuntu.

Remarks:

  1. Unsetting the http{,s}_proxy environment variables stops wget from using a proxy outside of Tor and to avoid using localhost resources that may cause torsocks failure.

  2. Torsocks is a robust method for wrapping applications that don't natively support SOCKS5.

  3. --passive-ftp on the command line (or passive_ftp = on in wgetrc) stops the use of "Active" FTP which might leak some local information to the remote party.

Regarding security, the User-Agent sent by wget will often provide some information that may allow to identify the versions of wget and the operating system. It may be faked with attention (since the server might behave differently for different clients).

Solution 5

torify seemed to work for me:

 torify wget https://www.some_url.com

Here's the access.log entry from my webserver:

207.244.70.35 - - [13/Sep/2018:03:57:25 +0000] "GET / HTTP/1.1" 200 8446 "-" "Wget/1.17.1 (linux-gnu)" "207.244.70.35" response-time=0.02

207.244.70.35 is not my real IP and therefore this command works

Here is a python script that does the same thing that I found here

#! /usr/bin/python3
import subprocess
from subprocess import Popen, PIPE
import sys
import os


# use torify to make a wget 
class Wgettor():
    def __init__(self, url):
        if not self.__is_activated():
            print("Ensure Tor service is running")
            sys.exit()
        else:
            self.url = url
            self.wget()

    # ensure Tor service is running
    def __is_activated(self):
        service_cmd = "service --status-all | grep tor"
        p = subprocess.Popen(service_cmd,
                             shell=True,
                             stdout=PIPE).communicate()[0]
        return "+" in str(p)

    def wget(self):
        prox = [
            "torify", "wget", self.url
        ]
        os.system(" ".join(prox))


if __name__ == "__main__":
    Wgettor("https://www.some_url_here.com")
Share:
100

Related videos on Youtube

H3ll0
Author by

H3ll0

Updated on September 18, 2022

Comments

  • H3ll0
    H3ll0 over 1 year

    I have two divs, when one hovers over the text (which are links) of a div, the padding increases from 0 to 5px. My issue is that whenever I hover over the text and the padding increases, the divs move down. Here's the code:

    <div id="container" class="text1">
    <a id="text1style" href="#" style="font-family:arial;font-size:120%;
    text-decoration:none;">Some text</a>
    </div>
    
    <div id="container" class="text2">
    <a id="text2style" href="#" style="font-family:arial;font-size:120%;
    text-decoration:none;">text</a>
    </div>
    
    
    #container {
    position:relative;
    }
    
    
    a:link, a:visited, a:active {
    color:blue;
    }
    
    
    a:hover {
    color:yellow;
    }
    
    
    .text1box {
    left:200px;
    bottom:35px;
    width:243px;
    }
    
    
    #text1style {
    -webkit-transition:color 0.5s;
    -o-transition:color 0.5s;
    -moz-transition:color 0.5s;
    -ms-transition:color 0.5s;
    transition:color 0.5s;
    -webkit-transition:background-color 0.5s;
    -o-transition:background-color 0.5s;
    -moz-transition:background-color 0.5s;
    -ms-transition:background-color 0.5s;
    transition:background-color 0.5s;
    }
    
    
    #text1style:hover {
    padding:5px;
    border-radius:10px;
    background-color:red;
    }
    
    
    .text2 {
    left:455px;
    bottom:57px;
    width:90px;
    }
    
    
    #text2style {
    -webkit-transition:color 0.5s;
    -o-transition:color 0.5s;
    -moz-transition:color 0.5s;
    -ms-transition:color 0.5s;
    transition:color 0.5s;
    -webkit-transition:background-color 0.5s;
    -o-transition:background-color 0.5s;
    -moz-transition:background-color 0.5s;
    -ms-transition:background-color 0.5s;
    transition:background-color 0.5s;
    }
    
    
    #text2style:hover {
    padding:5px;
    border-radius:10px;
    background-color:red;
    }
    

    Updated code: I have applied the padding expansion to the individual links, instead of the div, and this has helped out. I still have two issues: 1) The texts (of links) still shift slightly to the right. 2) When I remove the mouse (i.e: hover ends) you can see that the text has lost padding and border radius as the background (red) fades away.

    How could I resolve these two issues? Many thanks.

    • barlop
      barlop about 12 years
      i've read that both TOR and Vidalia have configuration files, look for the words user or password there and see if it's not as you'd think like maybe there's some username or password there.
    • HarrisJT
      HarrisJT over 7 years
      An ID should only be used once, you can however have multiple classes by doing class="class1name class2name"
    • H3ll0
      H3ll0 over 7 years
      @HarrisJT Please see updated code for alternative resolution.
  • Asher Walther
    Asher Walther about 12 years
    I have the same problem with sputnick-area.net/ip. But nice thinking though, it was a good idea to test that.
  • Gilles Quenot
    Gilles Quenot about 12 years
    See my edited post above
  • barlop
    barlop about 12 years
    could drop the -q too it looka from the man page thta -q is about supressing output. What is -0 ?
  • Gilles Quenot
    Gilles Quenot about 12 years
    -q simply hides the progress meter
  • holms
    holms almost 12 years
    you haven't answered the question =/
  • holms
    holms over 9 years
    doesn't work for me. 05:19:02 libtorsocks(22594): SOCKS server refused connection tor running on 9050 port, and it seems to be this beast does it on 127.0.0.1:80
  • Adam D.
    Adam D. almost 9 years
    This is probably the easiest solution for most people.
  • hanetzer
    hanetzer about 8 years
    -O - redirects to stdout, -q is just the progress meter as mentioned by @Gilles.
  • H3ll0
    H3ll0 over 7 years
    All this does is bug out my link. As soon as I hover over it, it rapidly jumps up and down. These two divs are next to each other, side by side. Please look over my code again.
  • Asons
    Asons over 7 years
    @H3ll0 Updated my answer. Took out the bottom temporary, as they make the boxes disappear in the demo, still, it is the top: -5px that makes up for the padding added when hovering, hence keep them from not move downwards
  • H3ll0
    H3ll0 over 7 years
    I applied it to a link, but now they shift to the right each time I hover.
  • H3ll0
    H3ll0 over 7 years
    Which IDs do I replace with class?
  • H3ll0
    H3ll0 over 7 years
    Your demo shows the text moving to the right. I want the text completely centered, with the padding being the only expansion. Please see the updated code I'll add in a minute.
  • Asons
    Asons over 7 years
    @H3ll0 Updated again, text centered all the time
  • H3ll0
    H3ll0 over 7 years
    Please see my updated code. If you could do the same thing but with this different method I've applied, it should really help. I have added the css to an id I created for the links in the divs, instead of applying the transitions to the divs themselves. As explained in the updated post, I now have a right-shift issue and after-fade problem. Would appreciate your input under these new conditions, thank you.
  • Asons
    Asons over 7 years
    @H3ll0 Added a 2:nd sample as a reply to your question edit
  • palswim
    palswim almost 7 years
    As torify --help says, torify is now just a wrapper around torsocks(1) for backwards compatibility., so this answer is identical to the torsocks answer.
  • palswim
    palswim almost 7 years
    torify --help says, torify is now just a wrapper around torsocks(1) for backwards compatibility.
  • Admin
    Admin almost 2 years
    worked for me thanks