php使用curl偽造來源ip和refer的方法

來源:互聯網
上載者:User
這篇文章主要介紹了關於php使用curl偽造來源ip和refer的方法,有著一定的參考價值,現在分享給大家,有需要的朋友可以參考一下

本文執行個體講述了php使用curl偽造來源ip和refer的方法。分享給大家供大家參考,具體如下:

php curl偽造來源ip和來路refer執行個體代碼1:

//隨機IPfunction 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.baidu.com';$ch = curl_init();curl_setopt($ch, CURLOPT_URL, 'http://localhost/phpdemo/test.php');//偽造來源refercurl_setopt($ch, CURLOPT_REFERER, $refer);//偽造來源ipcurl_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);

以上就是本篇文章的全部內容了,更多相關內容請關注topic.alibabacloud.com。

相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.