5

I am attempting to download a file from a hidden service using curl. I downloaded the Tor client and launched it and from another terminal executed this:

curl --socks5 socks5://127.0.0.1:9050 https://check.torproject.org > /tmp/output.txt

After listing the contents of tmp I catted the file along with grepping for 'browser'. I found congratulations this browser is configured to use Tor. However when I attempt to connect to a hidden service it fails to resolve the hostname which i checked within Tor browser and it loads. I tried using --socks5-hostname localhost:9050 and it downloaded the page just fine from the hidden service. Why is this?

3 Answers 3

3

According to man curl:

--socks5 <host[:port]>
       Use the specified SOCKS5 proxy  -  but  resolve  the  host  name
       locally.

This means --socks5 will use local resolver which CANNOT resolve .onion names UNLESS you configured it to do so and configured tor relay to do IP address allocation for hidden services.

--socks5-hostname has this information in the man page:

--socks5-hostname <host[:port]>
       Use  the  specified  SOCKS5 proxy (and let the proxy resolve the
       host name).

This lets tor and its socks proxy do the resolution and handle the .onion name hence the connection succeeds.

1

Install torsocks. This is a wrapper that will allow command line tools like curl to use the Tor service in Linux.

Example:

torsocks curl yz7lpwfhhzcdyc5y.onion

1
  • But, torsocks will install/run a tor executable as well. Check that you don't have conflicts. I spent a day learning this.
    – LDysic
    Commented Sep 25, 2019 at 22:39
1

curl -x socks5h://127.0.0.1:9050 http://2gzyxa5ihm7nsggfxnu52rck2vv4rvmdlkiu3zzui5du4xyclen53wid.onion

Or in your .curlrc: proxy=socks5h://127.0.0.1:9050 and just curl <onion address here>

The "h" in "socks5h" stands for "hostname" and routes DNS over the socks proxy. It has the same effect as adding the --socks5-hostname switch. The answer from @tomek explains why socks5://127.0.0.1:9050 will fail with a .onion address.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .