TOR 隐藏服务并不总是可以通过 cURL 访问。需要多次尝试

I l*_*ode 5 bash shell-script curl tor

当我尝试使用 cURL 访问 TOR 上的隐藏服务时,由于某种原因,我无法 100% 地访问该网站。很多次都会返回"curl: (7) Can't complete SOCKS5 connection to 0.0.0.0:0. (5)"

我可以做些什么来配置 cURL 以便更好地与 TOR 配合使用吗?这是我得到的输出:

root@Dexter:~# curl --proxy socks5h://localhost:9050 http://5ztppjwojkuslibm.onion/
curl: (7) Can't complete SOCKS5 connection to 0.0.0.0:0. (5)
root@Dexter:~# curl --proxy socks5h://localhost:9050 http://5ztppjwojkuslibm.onion/
curl: (7) Can't complete SOCKS5 connection to 0.0.0.0:0. (5)
root@Dexter:~# curl --proxy socks5h://localhost:9050 http://5ztppjwojkuslibm.onion/
curl: (18) transfer closed with 1 bytes remaining to read
<h1>This is a test page to see if I can run a hidden tor service!</h1><h3>Looks like it's working!</h3>root@Dexter:~# 
root@Dexter:~# curl --proxy socks5h://localhost:9050 http://5ztppjwojkuslibm.onion/
curl: (18) transfer closed with 1 bytes remaining to read
<h1>This is a test page to see if I can run a hidden tor service!</h1><h3>Looks like it's working!</h3>root@Dexter:~# 
Run Code Online (Sandbox Code Playgroud)

小智 0

可能是你的网络环境问题。

\n\n

我以duckduckgo洋葱网站https://3g2upl4pq6kufc4m.onion为例,它在AWS EC2或本地网络环境中都运行良好。

\n\n
$time curl -I --proxy socks5h://localhost:9050 https://3g2upl4pq6kufc4m.onion/\nHTTP/1.1 200 OK\nServer: nginx\nDate: Tue, 17 Jul 2018 13:51:35 GMT\nContent-Type: text/html; charset=UTF-8\nContent-Length: 5499\nConnection: keep-alive\nETag: "5b4d156e-157b"\nStrict-Transport-Security: max-age=0\nX-Frame-Options: SAMEORIGIN\nContent-Security-Policy: default-src https: blob: data: \'unsafe-inline\' \'unsafe-eval\'; frame-ancestors \'self\'\nX-XSS-Protection: 1;mode=block\nX-Content-Type-Options: nosniff\nReferrer-Policy: origin\nExpect-CT: max-age=0\nExpires: Tue, 17 Jul 2018 13:51:34 GMT\nCache-Control: no-cache\nAccept-Ranges: bytes\n\n\nreal    0m2.235s\nuser    0m0.048s\nsys 0m0.016s\n
Run Code Online (Sandbox Code Playgroud)\n\n

提取<title>信息

\n\n
curl -fsL --proxy socks5h://localhost:9050 https://3g2upl4pq6kufc4m.onion | grep \'title\'\n    <title>DuckDuckGo \xe2\x80\x94 Privacy, simplified.</title>\n
Run Code Online (Sandbox Code Playgroud)\n