php使用curl伪造来源ip和refer的方法示例
发布:smiling 来源: PHP粉丝网 添加日期:2021-09-16 11:03:16 浏览: 评论:0
这篇文章主要介绍了php使用curl伪造来源ip和refer的方法,涉及curl参数设置伪造来源相关操作技巧,需要的朋友可以参考下。
本文实例讲述了php使用curl伪造来源ip和refer的方法,分享给大家供大家参考,具体如下:
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){
- $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, true);
- curl_setopt($ch2, 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实例代码2:
- <?php
- $postData = array(
- "user" => "root",
- "pwd" => "123456"
- );
- $headerIp = array(
- 'CLIENT-IP:88.88.88.88',
- 'X-FORWARDED-FOR:88.88.88.88',
- );
- $refer = 'http://www.phpfensi.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);
Tags: curl伪造来源ip refer
- 上一篇:PHP 计算两个特别大的整数实例代码
- 下一篇:PHP实现搜索时记住状态的方法示例
相关文章
- ·php错误提示:Call-time pass-by-reference has been deprecated(2013-12-04)
- ·HTTP_REFERER 与 HTTP_USER_AGENT的使用方法(2014-09-18)
- ·php提示Call-time pass-by-reference has been deprecated错误(2014-09-21)
推荐文章
热门文章
最新评论文章
- 写给考虑创业的年轻程序员(10)
- PHP新手上路(一)(7)
- 惹恼程序员的十件事(5)
- PHP邮件发送例子,已测试成功(5)
- 致初学者:PHP比ASP优秀的七个理由(4)
- PHP会被淘汰吗?(4)
- PHP新手上路(四)(4)
- 如何去学习PHP?(2)
- 简单入门级php分页代码(2)
- php中邮箱email 电话等格式的验证(2)