[乐意黎]php curl 以及refer设置
2016-06-12 11:27
267 查看
echo
"<pre>"
;print_r(
$info
);
die
(
$output
);PHP code?
代码如下 | |
$opt=array('http'=>array('header'=>"Referer: $refer"));$context=stream_context_create($opt);$file_contents = file_get_contents($url,false, $context); |
file_get_contents中stream_context_create就伪造来源的重要参数了,这个什么好说的非常的简单。
CURL方式
代码如下 | |
$ch = curl_init();curl_setopt ($ch, CURLOPT_URL, "http://www.111cn.net");curl_setopt ($ch, CURLOPT_REFERER, "http://www.111cn.net/");curl_exec ($ch);curl_close ($ch); |
curl伪造来源页面非常的简单这是它的优点了,所以我们只要在页面加上curl_setopt ($ch, CURLOPT_REFERER, "http://www.111cn.net/");就可以了。
SOCKET方式
代码如下 | |
$server = 'www.111cn.net';$host = 'www.111cn.net';$target = 'index.php';$referer = 'http://www.111cn.net/'; // Referer$port = 80;$fp = fsockopen($server, $port, $errno, $errstr, 30);if (!$fp){echo "$errstr ($errno)\n";}else{$out = "GET $target HTTP/1.1\r\n";$out .= "Host: $host\r\n";$out .= "Referer: $referer\r\n";$out .= "Connection: Close\r\n\r\n";fwrite($fp, $out);while (!feof($fp)){echo fgets($fp, 128);}fclose($fp);} |
我们再使用
代码如下 | |
<?phpecho "<hr />";echo $_SERVER["HTTP_REFERER"];?> |
代码如下 | |
[one.php]<?php$post_data = array ("user" => "gongwen","pwd" => "123456");$header_ip = array('CLIENT-IP:88.88.88.88','X-FORWARDED-FOR:88.88.88.88',);$referer='http://www.111cn.net';$ch = curl_init();curl_setopt ($ch, CURLOPT_URL, 'http://localhost/curl/two.PHP');//伪造来源referercurl_setopt ($ch,CURLOPT_REFERER,$referer);//伪造来源ipcurl_setopt($ch, CURLOPT_HTTPHEADER, $header_ip);//提交post传参curl_setopt($ch, CURLOPT_POSTFIELDS, $post_data);//加上这个表示执行curl_exec是把输出做为返回值,不会输出到浏览器curl_setopt($ch,CURLOPT_RETURNTRANSFER,1);$out_put=curl_exec ($ch);curl_close ($ch);echo $out_put;[two.php]<?php//请求来源refererecho '[HTTP_REFERER]<br>';echo $_SERVER['HTTP_REFERER'];//请求来源ip//[注]此处的IP打印顺序是目前很多开源系统的IP获取顺序echo '<hr>[IP]<br>';echo $_SERVER['HTTP_CLIENT_IP'];echo '<br>';echo $_SERVER['HTTP_X_FORWARDED_FOR'];echo '<br>';echo $_SERVER['REMOTE_ADDR'];//POST数据echo '<hr>[POST]<br><pre>';var_dump($_POST);echo '</pre>'; |
代码如下 | |
function getImagesUrl( $url,$userinfo,$header){$ch = curl_init();$timeout = 1;curl_setopt ($ch, CURLOPT_URL, "$url");curl_setopt ($ch, CURLOPT_HTTPHEADER, $header);curl_setopt ($ch, CURLOPT_REFERER, "http://www.baidu.com/");curl_setopt ($ch, CURLOPT_RETURNTRANSFER, 1);curl_setopt ($ch, CURLOPT_USERAGENT, "$userinfo");curl_setopt ($ch, CURLOPT_CONNECTTIMEOUT, $timeout);$contents = curl_exec($ch);curl_close($ch);//echo $contents;return $contents ;}function saveurl( $handle ,$filename){$fp = fopen($filename,"w");fwrite($fp,$handle);unset($fp);unset($handle);}$binfo =array('Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 5.1; Trident/4.0; .NET CLR 2.0.50727; InfoPath.2; AskTbPTV/5.17.0.25589; Alexa Toolbar)','Mozilla/5.0 (Windows NT 5.1; rv:22.0) Gecko/20100101 Firefox/22.0','Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 5.1; Trident/4.0; .NET4.0C; Alexa Toolbar)','Mozilla/4.0(compatible; MSIE 6.0; Windows NT 5.1; SV1)',$_SERVER['HTTP_USER_AGENT']);//123.125.68.*//125.90.88.*$cip = '123.125.68.'.mt_rand(0,254);$xip = '125.90.88.'.mt_rand(0,254);$header = array('CLIENT-IP:'.$cip,'X-FORWARDED-FOR:'.$xip,);$u = $binfo[mt_rand(0,3)];$get_file = getImagesUrl($value,$u,$header);saveurl($get_file,'a.jpg'); |
相关文章推荐
- 使用manifestPlaceholders
- 剑指offer—编程题23(从上往下打印二叉树)
- html、css和javascript入门
- 从重置input file标签中看jQuery的 .val() 和 .attr(“value”) 区别
- html css相对单位
- Angular----入门
- jQuery基于toggle实现click触发DIV的显示与隐藏问题分析
- javascript jquery对form元素的常见操作详解
- Bootstrap下拉菜单(Dropdowns)和按钮
- JavaScript function函数种类(转)
- 剑指offer—编程题14(调整数组顺序使奇数位于偶数前面)
- CSS3边框
- jquery中如何防止冒泡事件
- CF 363B Fence(和最小的k个数)
- [转][前端优化]使用Combres合并对js、css文件的请求
- 剑指offer——空格替换问题和相关问题
- HTML与CSS的结合方式
- jQuery导出Excel格式
- 编写Javascript插件的要求
- Web前端教程-02.04.HTML5样式、链接和表格