人妻丰满熟妇AV无码片,岛国AV无码免费无禁网站,丰满岳乱妇一区二区三区,男插女高潮一区二区

linux 安裝 tor

技術(shù)分享 2019-10-01 00:00:00
tor 已經(jīng)不能用
如果在國外可以用

安裝:yum install tor

設(shè)置 /etc/tor/torrc 開放 ControlPort 和 DataDirectory

service tor start


php 更新 ip

if (tor_new_identity('127.0.0.1', '9051')) {
echo "Identity switched!";
}

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; //can't connect to the control port

fputs($fp, "AUTHENTICATE $auth_code\r\n");
$response = fread($fp, 1024);
list($code, $text) = explode(' ', $response, 2);
if ($code != '250') return false; //authentication failed

//send the request to for new identity
fputs($fp, "signal NEWNYM\r\n");
$response = fread($fp, 1024);
list($code, $text) = explode(' ', $response, 2);
if ($code != '250') return false; //signal failed

fclose($fp);
return true;
}




測試:


function tor_wrapper($url) {
$ua = array('Mozilla','Opera','Microsoft Internet Explorer','ia_archiver');
$op = array('Windows','Windows XP','Linux','Windows NT','Windows 2000','OSX');
$agent = $ua.'/'.rand(1,8).'.'.rand(0,9).' ('.$op.' '.rand(1,7).'.'.rand(0,9).'; en-US;)';

# Tor address & port
$tor = '127.0.0.1:9050';
# set a timeout.
$timeout = '10';
$ack = curl_init();
curl_setopt ($ack, CURLOPT_PROXY, $tor);
curl_setopt ($ack, CURLOPT_PROXYTYPE, CURLPROXY_SOCKS5);
curl_setopt ($ack, CURLOPT_URL, $url);
curl_setopt ($ack, CURLOPT_HEADER, 0);
curl_setopt ($ack, CURLOPT_USERAGENT, $agent);
curl_setopt ($ack, CURLOPT_RETURNTRANSFER, 1);
curl_setopt ($ack, CURLOPT_FOLLOWLOCATION, 1);
curl_setopt ($ack, CURLOPT_TIMEOUT, $timeout);
while(true){
$syn = curl_exec($ack);
if(curl_errno($ack) or curl_error($ack)){
continue;
} else {
return $syn;
}
}
}
# example:
$wrapped = tor_wrapper("http://www.google.com/");
echo $wrapped;
咨詢小瓶科技
咨詢我們
頂部