您好,登錄后才能下訂單哦!
這篇文章給大家介紹如何在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){ $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:
<?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.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的來源就分享到這里了,希望以上內容可以對大家有一定的幫助,可以學到更多知識。如果覺得文章不錯,可以把它分享出去讓更多的人看到。
免責聲明:本站發布的內容(圖片、視頻和文字)以原創、轉載和分享為主,文章觀點不代表本網站立場,如果涉及侵權請聯系站長郵箱:is@yisu.com進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。