Php 如何更改tor ip each curl_init()

Php 如何更改tor ip each curl_init(),php,curl,tor,Php,Curl,Tor,为了解决我的项目,我在我的虚拟工作站(Debian)上安装了tor和privoxy。 我找到了如何使用curl和Tor代理,但我无法在每个curl_init()上更改Ip地址 这是我的密码: #!/usr/bin/env php <?php function get_url($url) { // ensure PHP cURL library is installed if(function_exists('curl_init')) { $timestart=microtime(true)

为了解决我的项目,我在我的虚拟工作站(Debian)上安装了tor和privoxy。 我找到了如何使用curl和Tor代理,但我无法在每个curl_init()上更改Ip地址

这是我的密码:

#!/usr/bin/env php
<?php
function get_url($url)
{
// ensure PHP cURL library is installed
if(function_exists('curl_init'))
{
$timestart=microtime(true);

$ip = '127.0.0.1';
$port = '9050';
$auth = 'rebootip';
$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_FOLLOWLOCATION,true);
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_PROXY, "127.0.0.1:9050");
curl_setopt($ch, CURLOPT_PROXYTYPE, 7);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_VERBOSE, 0);
$response = curl_exec($ch);
$error = curl_error($ch);
print_r($response."\n");
print_r($error."\n");
}
else // PHP cURL library not installed
{
echo 'Please install PHP cURL library';
}
}
echo get_url('http://ipinfo.io/');
#/usr/bin/env-php

要获得不同的出口节点IP地址,请在端口9050、9051、。。。然后在curl_init上,将代理端口更改为另一个可用的Tor客户端


一旦用完当前的Tor客户端列表,就可以重新启动它们以获得另一个退出节点。您甚至可以直接向Tor客户端发送简单的telnet命令来更改退出节点。

您在这里到底想做什么?闻起来有点可疑。这是我安全课程的一个项目。我们的目标是更改每个curl_init()的ip地址。您能否向我们解释一下您正在探测的是什么软件,以及为什么?