• 年关了,抛一个模拟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 // 此处设置投票的id
    26 $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); // 构造IP
    46 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 '<meta http-equiv="refresh" content="1;url=http://localhost/phpk/post.php?ip=' . $ip . '"> ';
    59 ?>

    使用范围:所有限制ip地址的投票网站。投票数可到254*254*254*254。

    如何防范该类刷票行为:

    在获取客户端ip的时候优先使用:

    $ip = getenv('REMOTE_ADDR');

    用remote_addr可以有效控制模拟ip投票,除非使用代理才能绕过去,但是用web实现代理,速度就很慢了。

  • 相关阅读:
    web架构
    网站开发的学习交流 系统架构 负载均衡
    数据库连接
    OpenCV4【12】边缘检测
    python基础_格式化输出(%用法和format用法)
    Python之telnetlib模块
    根据文字或图片来生成用于Banner输出的字符画
    Python3 range() 函数用法
    Python psutil cpu_percent调用说明
    @staticmethod和@classmethod的用法
  • 原文地址:https://www.cnblogs.com/xpbb/p/3520190.html
Copyright © 2020-2023  润新知