13

Is there any way to anonymize http requests through the command line? In other words, is it possible to wget a page without the requester's IP showing up?

Dervin Thunk
  • 3,429
  • 4
  • 23
  • 21

1 Answers1

19

One method of annoymizing HTTP traffic from the command line is to use tor. This article discusses the method, titled: How to anonymize the programs from your terminal with torify.

General steps from article

  1. You can install the tor package as follows:

    Fedora/CentOS/RHEL

    $ sudo yum install tor
    

    Ubuntu/Debian

    $ sudo apt-get install tor
    
  2. Edit this file /etc/tor/torrc so that the following lines are present and uncommented:

    ControlPort 9051
    CookieAuthentication 0
    
  3. Start the tor service

    $ sudo /etc/init.d/tor restart
    
  4. Testing setup

    Real IP

    $ curl ifconfig.me 67.253.170.83

    anonymized IP

    $ torify curl ifconfig.me 2>/dev/null 46.165.221.166

    As you can see the ifconfig.me website thinks our IP address is now 46.165.221.166. You can tell tor to start a new session triggering a new IP address for us:

    $ echo -e 'AUTHENTICATE ""\r\nsignal NEWNYM\r\nQUIT' | nc 127.0.0.1 9051
    250 OK
    250 OK
    250 closing connection
    
    $ torify curl ifconfig.me 2>/dev/null
    37.252.121.31
    

    Do it again to get another different IP

    $ echo -e 'AUTHENTICATE ""\r\nsignal NEWNYM\r\nQUIT' | nc 127.0.0.1 9051
    250 OK
    250 OK
    250 closing connection
    
    $ torify curl ifconfig.me 2>/dev/null
    91.219.237.161
    
  5. Downloading Pages

    $ torify curl www.google.com 2>/dev/null
    
  6. Browsing the internet via elinks

    $ torify elinks www.google.com
    

         ss of elinks

References

slm
  • 363,520
  • 117
  • 767
  • 871
  • 1
    Thanks for this ! But do you mind adding an example on how to test tor 9050 socks without using torify ? I'm trying to use `curl --socks5` or even socks4 or socks4a, but never worked. It just freezed. – Bertie Jun 01 '14 at 14:20
  • @slm: sorry, i finally got it working. It's just because of i have environment http_proxy of localhost:4001 after installing anon_proxy. Removing the environment variables and redoing curl --socks5 worked out fine. I just deleted my question. Thank you for your answer. – Bertie Jun 01 '14 at 15:27