php使用curl伪造来源ip和refer的方法示例

发布时间:2022-04-30 发布网站:脚本宝典
脚本宝典收集整理的这篇文章主要介绍了php使用curl伪造来源ip和refer的方法示例脚本宝典觉得挺不错的,现在分享给大家,也给大家做个参考。

本文实例讲述了PHP使用curl伪造来ip和refer的方法分享给大家供大家参考,具体如下:

PHP curl伪造来源ip和来路refer实例代码1:

<PRe class="brush:PHP;"> //随机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","60","202","204","59","61","222","221","62","63","64","122","211"); $randarr= mt_rand(0,count($arr_1)-1); $ip1id = $arr_1[$randarr]; return $ip1id.".".$ip2id.".".$ip3id.".".$ip4id; } //抓取页面内容 function Curl($url){ $ch2 = 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($ch2,CURLOPT_URL,$url); curl_setopt($ch2,CURLOPT_TIMEOUT,10); curl_setopt($ch2,CURLOPT_HTTPHEADER,array('X-FORWARDED-FOR:'.Rand_IP(),'CLIENT-iP:'.Rand_IP())); //追踪返回302状态码,继续抓取 curl_setopt($ch2,CURLOPT_HEADER,true); curl_setopt($ch2,CURLOPT_RETURNtransfer,CURLOPT_FOLLOWLOCATION,true); curl_setopt($ch2,CURLOPT_NOBODY,false); curl_setopt($ch2,CURLOPT_REFERER,'http://www.baidu.COM/');//模拟来路 curl_setopt($ch2,CURLOPT_USERAGENT,$user_agent); $temp = curl_exec($ch2); curl_close($ch2); return $temp; }

脚本宝典总结

以上是脚本宝典为你收集整理的php使用curl伪造来源ip和refer的方法示例全部内容,希望文章能够帮你解决php使用curl伪造来源ip和refer的方法示例所遇到的问题。

如果觉得脚本宝典网站内容还不错,欢迎将脚本宝典推荐好友。

本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。