Wednesday 15 May 2013

php - Facing issue while using Tor with Curl -



php - Facing issue while using Tor with Curl -

facing issue while using tor curl:

i having script :

$ch = curl_init();<br> curl_setopt($ch, curlopt_url, "http://whatismyip.org");<br> curl_setopt($ch, curlopt_proxy, "127.0.0.1:9050");<br> curl_setopt($ch, curlopt_proxytype, curlproxy_socks5);<br> curl_setopt($ch, curlopt_returntransfer, 1);<br> curl_setopt($ch, curlopt_verbose, 0);<br> $response = curl_exec($ch);<br> $errno = curl_error($ch);<br> print_r($errno);<br>

when using facing error:

can't finish socks5 connection 0.0.0.0:0. (6)

and when using script:

$proxy = "127.0.0.1";<br> $port = "9050";<br> $url = "http://whatismyip.org";<br> $ch = curl_init();<br> curl_setopt ($ch, curlopt_url, $url);<br> curl_setopt ($ch, curlopt_header, 0);<br> curl_setopt ($ch, curlopt_proxytype, 7 );<br> curl_setopt ($ch, curlopt_proxy, $proxy.':'.$port );<br> ob_start();<br> curl_exec ($ch);<br> curl_close ($ch);<br> $result = ob_get_contents();<br> ob_end_clean();<br> var_dump($result);<br>

facing issue:

tor not http proxy

it appears have configured web browser utilize tor http proxy. not correct: tor socks proxy, not http proxy. please configure client accordingly. see https://www.torproject.org/documentation.html more information.

if 1 know solution please assist me.

thanks in advance.

this code i'm using without incident:

$ch = curl_init(); curl_setopt($ch, curlopt_url, $url); curl_setopt($ch, curlopt_returntransfer, true); curl_setopt($ch, curlopt_proxy, "http://localhost:9150/"); curl_setopt($ch, curlopt_proxytype, 7); curl_setopt($ch, curlopt_timeout, 120); $result = curl_exec($ch);

the visible differences see localhost vs loopback, prepended http on curlopt_proxy, , various technical differences (verbose, etc). recommend setting timeout if you're going curl onion sites, since in experience you'll run loadblocks leave connection hanging.

also, sure proxy on right port! depending on how you're using tor, proxy on port 9050, 9051, 9150, or 9151. utilize netstat or similar utility (bundled xampp me) or process hacker 2 (network tab) see what's on port. tor.exe should on 1 of above ports. utilize proxy.

i know had problem in past. luck!

edit: total test code play with:

<?php $url = (isset($_request['url']) ? $_request['url'] : "http://msydqstlz2kzerdg.onion/search/"); $ch = curl_init(); curl_setopt($ch, curlopt_url, $url); curl_setopt($ch, curlopt_returntransfer, true); curl_setopt($ch, curlopt_proxy, "http://localhost:9150/"); curl_setopt($ch, curlopt_proxytype, 7); curl_setopt($ch, curlopt_timeout, 120); $output = curl_exec($ch); $curl_error = curl_error($ch); curl_close($ch); print_r($output); print_r($curl_error); ?>

php curl proxy socks opentor

No comments:

Post a Comment