Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Doing https requests through a SOCKS5 proxy (tor) with curl

Tags:

curl

proxy

I have TOR setup on my system (debian) that has been tested and works well. What I am trying to do is proxy HTTPS requests through this setup.

just https works: curl https://www.reg.ru/whois/?dname=google.com

Tor + http work curl --socks5 127.0.0.1:9050 http://stackoverflow.com/

but tor with https does not work:

curl --socks5 127.0.0.1:9050 https://www.torproject.org/download/download.html.en

I get an error curl: (6) Failed to resolve "www.torproject.org" for SOCKS5 connect.

How can I solve this?

like image 389
SKulibin Avatar asked Jul 04 '14 07:07

SKulibin


People also ask

Can you use SOCKS5 on Tor?

SOCKS5 is an Internet protocol used by Tor. It sends the traffic through the Tor network instead of sending it from your IP address into the open network. It is a general purpose proxy that sits at the layer 5 of the OSI model and uses the tunneling method.

How do you use curl with 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.

Does curl go through proxy?

To use a proxy with Curl, you must pass the required proxy address using the -x (or --proxy) command-line option and proxy credentials using the -U (or --proxy-user) command-line switch. Proxy credentials may also be passed in the proxy string and will be URL decoded by Curl.

Does SOCKS5 work with proxy?

Unlike HTTP proxies, which can only interpret and work with HTTP and HTTPS webpages, SOCKS5 proxies can work with any traffic. HTTP proxies are high-level proxies usually designed for a specific protocol. While this means you get better connection speeds, they're not nearly as flexible and secure as SOCKS proxies.


1 Answers

I had a similar problem, and using the option --socks5-hostname instead of --socks5 to specify the proxy for curl solved the issue.

like image 102
Andris Avatar answered Oct 11 '22 13:10

Andris