您好,欢迎访问一九零五行业门户网

年关了,抛一个模拟ip刷票的php程序

1 php 2 $ip = $_get['ip'] ? $_get['ip'] : '1.1.1.1'; 3 $iparr = explode(., $ip); 4 $iparr[3] = $iparr[3] + 1; 5 if ( $iparr[3] > 254 ) 6 { 7 $iparr[3] = 1; 8 $iparr[2] = $iparr[2] + 1; 9 }10 if ( $iparr[2] > 254 )11 {12 $iparr[2] = 1;13 $iparr[1] = $iparr[1] + 1;14 }15 if ( $iparr[1] > 254 )16 {17 $iparr[1] = 1;18 $iparr[0] = $iparr[0] + 1;19 }20 if ( $iparr[0] > 254 )21 {22 exit();23 }24 $ip = implode(., $iparr);25 // 此处设置投票的id26 $post_data = 'vid=8';27 28 // 投票的地址29 $url = 'http://www.xxx.com/api.php?m=vote&a=voteto';30 $user_agent = mozilla/4.0;31 32 $headers['client-ip'] = $ip;33 $headers['x-forwarded-for'] = $ip;34 35 $headerarr = array();36 foreach ( $headers as $n => $v )37 {38 $headerarr[] = $n . ':' . $v;39 }40 41 $ch = curl_init();42 curl_setopt($ch, curlopt_post, 1);43 curl_setopt($ch, curlopt_url, $url);44 45 curl_setopt($ch, curlopt_httpheader, $headerarr); // 构造ip46 curl_setopt($ch, curlopt_referer, http://www.baidu.com/ ); // 构造来路47 curl_setopt($ch, curlopt_header, 1);48 49 curl_setopt($ch, curlopt_useragent, $user_agent);50 curl_setopt($ch, curlopt_postfields, $post_data);51 52 ob_start();53 curl_exec($ch);54 $result = ob_get_contents();55 ob_end_clean();56 57 echo $result;58 echo ' ';59 ?>
使用范围:所有限制ip地址的投票网站。投票数可到254*254*254*254。
如何防范该类刷票行为:在获取客户端ip的时候优先使用:
$ip = getenv('remote_addr');
用remote_addr可以有效控制模拟ip投票,除非使用代理才能绕过去,但是用web实现代理,速度就很慢了。
其它类似信息

推荐信息