Created
November 5, 2015 21:21
-
-
Save JburkeRSAC/b7b306271261fda01c25 to your computer and use it in GitHub Desktop.
Execute curl through Tor via PHP
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$ip = '127.0.0.1'; | |
$port = '9050'; | |
$auth = 'TorCTRLPass'; | |
$command = 'signal NEWNYM'; | |
$fp = fsockopen($ip,$port,$error_number,$err_string,10); | |
if(!$fp) { echo "ERROR: $error_number : $err_string"; | |
return false; | |
} else { | |
fwrite($fp,"AUTHENTICATE \"".$auth."\"\n"); | |
$received = fread($fp,512); | |
fwrite($fp,$command."\n"); | |
$received = fread($fp,512); | |
} | |
fclose($fp); | |
$ch = curl_init(); | |
curl_setopt($ch, CURLOPT_URL, "http://whatismyip.org"); | |
curl_setopt($ch, CURLOPT_PROXY, "127.0.0.1:9050"); | |
curl_setopt($ch, CURLOPT_PROXYTYPE, CURLPROXY_SOCKS5); | |
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); | |
curl_setopt($ch, CURLOPT_VERBOSE, 0); | |
$response = curl_exec($ch); | |
print_r($response); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment