Answer the question
In order to leave comments, you need to log in
Tor: how to check if ip has changed?
I wrote a script that sends a signal to the torus about the change of intermediate links.
function tor_new_identity($tor_ip='127.0.0.1', $control_port='9051', $auth_code=''){
$fp = fsockopen($tor_ip, $control_port, $errno, $errstr, 30);
if (!$fp) return false;
//авторизация
fputs($fp, "AUTHENTICATE $auth_code\r\n");
$response = fread($fp, 1024);
list($code, $text) = explode(' ', $response, 2);
if ($code != '250') return false;
//отправляю сигнал для смены промежуточных звеньев
fputs($fp, "signal NEWNYM\r\n");
$response = fread($fp, 1024);
list($code, $text) = explode(' ', $response, 2);
if ($code != '250') return false;
fclose($fp);
return true;
}
function get($url,$proxy) {
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL,$url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER,1);
curl_setopt($ch, CURLOPT_PROXYTYPE, CURLPROXY_SOCKS5);
curl_setopt($ch, CURLOPT_USERAGENT, 'Mozilla/5.0 (Windows; U; Windows NT 5.1; ru; rv:1.9.0.1) Gecko/2008070208');
curl_setopt($ch, CURLOPT_PROXY, "$proxy");
$ss=curl_exec($ch);
curl_close($ch);
return $ss;
}
if (tor_new_identity('127.0.0.1', '9051')) {
$prox = 'localhost:9050';
$a = get('http://ip.appspot.com/', $prox);
print($a);
}
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question