这篇文章给大家介绍如何在php中使用curl伪造ip和refer的来源,内容非常详细,感兴趣的小伙伴们可以参考借鉴,希望对大家能有所帮助。
10年积累的成都网站设计、做网站经验,可以快速应对客户对网站的新想法和需求。提供各种问题对应的解决方案。让选择我们的客户得到更好、更有力的网络服务。我虽然不认识你,你也不认识我。但先网站设计制作后付款的网站建设流程,更有甘井子免费网站建设让你可以放心的选择与我们合作。php curl伪造来源ip和来路refer实例代码1:
//随机IP function Rand_IP(){ $ip2id= round(rand(600000, 2550000) / 10000); //第一种方法,直接生成 $ip3id= round(rand(600000, 2550000) / 10000); $ip4id= round(rand(600000, 2550000) / 10000); //下面是第二种方法,在以下数据中随机抽取 $arr_1 = array("218","218","66","66","218","218","60","60","202","204","66","66","66","59","61","60","222","221","66","59","60","60","66","218","218","62","63","64","66","66","122","211"); $randarr= mt_rand(0,count($arr_1)-1); $ip1id = $arr_1[$randarr]; return $ip1id.".".$ip2id.".".$ip3id.".".$ip4id; } //抓取页面内容 function Curl($url){ $ch3 = curl_init(); $user_agent = "Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/29.0.1547.66 Safari/537.36";//模拟windows用户正常访问 curl_setopt($ch3, CURLOPT_URL, $url); curl_setopt($ch3, CURLOPT_TIMEOUT, 10); curl_setopt($ch3, CURLOPT_HTTPHEADER, array('X-FORWARDED-FOR:'.Rand_IP(), 'CLIENT-IP:'.Rand_IP())); //追踪返回302状态码,继续抓取 curl_setopt($ch3, CURLOPT_HEADER, true); curl_setopt($ch3, CURLOPT_RETURNTRANSFER, true); curl_setopt($ch3, CURLOPT_FOLLOWLOCATION, true); curl_setopt($ch3, CURLOPT_NOBODY, false); curl_setopt($ch3, CURLOPT_REFERER, 'http://www.baidu.com/');//模拟来路 curl_setopt($ch3, CURLOPT_USERAGENT, $user_agent); $temp = curl_exec($ch3); curl_close($ch3); return $temp; }
php curl伪造来源ip和来路refer实例代码2:
"root", "pwd" => "123456" ); $headerIp = array( 'CLIENT-IP:88.88.88.88', 'X-FORWARDED-FOR:88.88.88.88', ); $refer = 'http://www.baidu.com'; $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, 'http://localhost/phpdemo/test.php'); //伪造来源refer curl_setopt($ch, CURLOPT_REFERER, $refer); //伪造来源ip curl_setopt($ch, CURLOPT_HTTPHEADER, $headerIp); //提交post传参 curl_setopt($ch, CURLOPT_POSTFIELDS, $postData); //...各种curl属性参数设置 $out_put = curl_exec($ch); curl_close($ch); var_dump($out_put);
1、执行速度快。2、具有很好的开放性和可扩展性。3、PHP支持多种主流与非主流的数据库。4、面向对象编程:PHP提供了类和对象。5、版本更新速度快。6、具有丰富的功能。7、可伸缩性。8、功能全面,包括图形处理、编码与解码、压缩文件处理、xml解析等。
关于如何在php中使用curl伪造ip和refer的来源就分享到这里了,希望以上内容可以对大家有一定的帮助,可以学到更多知识。如果觉得文章不错,可以把它分享出去让更多的人看到。