Using CURL with TOR as a Proxy on CentOs
Asked Answered
B

2

11

I want to use Tor as a proxy for HTTP-requests with curl or wget on a CentOS Machine. I used this How-to and I looked for some answers on stackexchange and stackoverflow. https://medium.com/the-sysadmin/using-tor-for-your-shell-script-fee9d8bdef5c#.9ixz30jbn

If I typing into my shell 'tor' I get this:

Aug 31 21:01:29.871 [notice] Tor v0.2.8.6 running on Linux with Libevent 2.0.22-stable, OpenSSL 1.0.2h and Zlib 1.2.8.
Aug 31 21:01:29.871 [notice] Tor can't help you if you use it wrong! Learn how to be safe at https://www.torproject.org/download/download#warning
Aug 31 21:01:29.871 [notice] Read configuration file "/home/wmjio5f6/.linuxbrew/etc/tor/torrc".
Aug 31 21:01:29.909 [warn] ControlPort is open, but no authentication method has been configured.  This means that any program on your computer can reconfigure your Tor.  That's bad!  You should upgrade your Tor controller as soon as possible.
Aug 31 21:01:29.937 [notice] Opening Socks listener on 127.0.0.1:9050
Aug 31 21:01:29.939 [notice] Opening Control listener on 127.0.0.1:9151
Aug 31 21:01:29.000 [notice] Parsing GEOIP IPv4 file /home/wmjio5f6/.linuxbrew/Cellar/tor/0.2.8.6/share/tor/geoip.
Aug 31 21:01:30.000 [notice] Parsing GEOIP IPv6 file /home/wmjio5f6/.linuxbrew/Cellar/tor/0.2.8.6/share/tor/geoip6.
Aug 31 21:01:30.000 [notice] Bootstrapped 0%: Starting
Aug 31 21:01:31.000 [notice] Bootstrapped 80%: Connecting to the Tor network
Aug 31 21:01:32.000 [notice] Bootstrapped 85%: Finishing handshake with first hop
Aug 31 21:01:32.000 [notice] Bootstrapped 90%: Establishing a Tor circuit
Aug 31 21:01:32.000 [notice] Tor has successfully opened a circuit. Looks like client functionality is working.
Aug 31 21:01:32.000 [notice] Bootstrapped 100%: Done

Where is my error, or wich command is the right?

Baun answered 31/8, 2016 at 19:10 Comment(1)
see also Torsocks curl vs curl --socks5Headon
M
16

You've made no mistake. That output indicates that Tor launched, connected to the network and is running. You'll probably want to figure out how to daemonize it, or run it in the background (nohup tor &).

The line Opening Socks listener on 127.0.0.1:9050 tells you that it's SOCKS (proxy) port is listening on port 9050. This is the port you want applications like curl or wget to proxy through.

As shown in the article you linked, you just need to run curl using Tor's SOCKS port.

curl -s --socks5-hostname 127.0.0.1:9050 http://www.showmyip.gr
Malawi answered 1/9, 2016 at 16:32 Comment(0)
D
1

On RHEL/RHEL-clones, the tor package is available from a a torproject repository. After it's enabled you can install and start the tor service like this:

dnf install tor
systemctl start tor

Note that the tor service provides a SOCKS proxy for routing TCP traffic through the Onion network. Thus, each program whose TCP traffic you want to send through tor you have to configure such that is explicitly uses that proxy.

With curl, you can use the --proxy option like this:

curl --proxy socks5h://localhost:9050 'https://wtfismyip.com/yaml'

NB: The 'h' in socks5h means that also DNS requests made by curl go through the tor network.

For programs that don't support socks5h proxies natively - such as wget - you can use torsocks like this:

rm -f yaml
torsocks wget 'https://wtfismyip.com/yaml'
cat yaml

FWIW, Fedora, a kind of RHEL upstream distribution, has the tor package included in its main repository.

Dann answered 20/5, 2023 at 15:5 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.