日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程语言 > php >内容正文

php

php curl伪造referer与来源IP实例

發布時間:2024/9/20 php 33 豆豆
生活随笔 收集整理的這篇文章主要介紹了 php curl伪造referer与来源IP实例 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

轉自:http://www.111cn.net/phper/php/69500.htm

php curl偽造referer與來源IP非常的簡單,今天做一個圖片采集的也有做過,下面我把兩個例子都整理一下,供大家參考。

例子1 [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');//偽造來源referer curl_setopt ($ch,CURLOPT_REFERER,$referer);//偽造來源ip curl_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>';

?

?

例子2

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');

來源:https://www.cnblogs.com/Killertu/p/5332178.html

總結

以上是生活随笔為你收集整理的php curl伪造referer与来源IP实例的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。