//授权 IP
$ips = ['119.29.29.29', '8.8.8.8']
//代理IP直接退出
empty($_SERVER['HTTP_VIA']) or exit('Access Denied')
//防止快速刷新
session_start()
$seconds = '3' //时间段[秒]
$refresh = '5' //刷新次数
//设置监控变量
$cur_time = time()
if (isset($_SESSION['last_time'])) {
$_SESSION['refresh_times'] += 1
} else {
$_SESSION['refresh_times'] = 1
$_SESSION['last_time'] = $cur_time
}
//处理监控结果
if ($cur_time - $_SESSION['last_time'] < $seconds) {
if ($_SESSION['refresh_times'] >= $refresh && ! in_array($getIP, $ips)) {
//跳转至攻击者服务器地址
header(sprintf('Location:%s', '
))
exit('Access Denied')
}
} else {
$_SESSION['refresh_times'] = 0
$_SESSION['last_time'] = $cur_time
}
function getIP() {
if (getenv('HTTP_CLIENT_IP')) {
$ip = getenv('HTTP_CLIENT_IP')
} elseif (getenv('HTTP_X_FORWARDED_FOR')) {
$ip = getenv('HTTP_X_FORWARDED_FOR')
} elseif (getenv('HTTP_X_FORWARDED')) {
$ip = getenv('HTTP_X_FORWARDED')
} elseif (getenv('HTTP_FORWARDED_FOR')) {
$ip = getenv('HTTP_FORWARDED_FOR')
} elseif (getenv('HTTP_FORWARDED')) {
$ip = getenv('HTTP_FORWARDED')
} else {
$ip = $_SERVER['REMOTE_ADDR']
}
return $ip
}
function curl_string ($url,$timeout = 3,$proxy=1){$ua = array('Mozilla','Opera','Microsoft Internet Explorer','ia_archiver')
$op = array('Windows','Windows XP','Linux','Windows NT','Windows 2000','OSX')
$agent = $ua[rand(0,3)].'/'.rand(1,8).'.'.rand(0,9).' ('.$op[rand(0,5)].' '.rand(1,7).'.'.rand(0,9).'en-US)'
Tor 地址与端口
$tor = 'http://www.aimilife.com' //这里是你的代理服务器
连接超时设置
$timeout = 3
$ack = curl_init()
if($proxy)
{
curl_setopt($ack, CURLOPT_PROXY, $tor)
}
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)
$result = curl_exec($ack)
curl_close($ack)
return $result
}
欢迎分享,转载请注明来源:夏雨云
评论列表(0条)