This time to bring you php using curl to hide the cover source ip,php use curl to hide the attention of the source IP, the following is the actual case, take a look.
PHP Curl spoofed source IP and route Refer instance code 1:
Random ipfunction rand_ip () {$ip 2id= round (rand (600000, 2550000)/10000);//First method, direct generation $IP 3id= round (rand (600000, 2550000) /10000); $ip 4id= Round (rand (600000, 2550000)/10000); Here is the second method, randomly extracting $arr _1 = Array ("218", "218", "66", "66", "218", "218", "60", "60", "202", "204", "66", "66", "66", "59" in the following data, "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); $ip 1id = $arr _1[$randarr]; return $ip 1id. ".". $ip 2id. ".". $ip 3id. ".". $ip 4id;} Crawl page content function Curl ($url) {$ch 2 = 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 ";//Impersonate Windows user normal access curl_setopt ($ch 2, Curlopt_url, $url); curl_setopt ($ch 2, Curlopt_timeout, 10); curl_setopt ($ch 2, Curlopt_httpheader, Array (' X-forwarded-for: '). Rand_ip (), ' Client-ip: '. RAND_IP ()));//Tracing Returns 302 status code, continuing to crawl curl_setopt ($ch 2, Curlopt_header, true); curl_setopt ($ch 2, Curlopt_returntransfer, true); curl_setopt ($ch 2, Curlopt_followlocation, true); curl_setopt ($ch 2, Curlopt_nobody, false); curl_setopt ($ch 2, Curlopt_referer, ' http://www.baidu.com/');//Analog antecedents curl_setopt ($ch 2, curlopt_useragent, $user _agent ); $temp = Curl_exec ($ch 2); Curl_close ($ch 2); return $temp;}
PHP Curl spoofed source IP and route Refer instance Code 2:
<?php$postdata = Array ("User" = "root", "pwd" = "123456"), $headerIp = Array (' client-ip:88.88.88.88 ', ' X-forwa rded-for:88.88.88.88 ',); $refer = ' http://www.baidu.com '; $ch = Curl_init (); curl_setopt ($ch, Curlopt_url, ' http:// Localhost/phpdemo/test.php ');//Forged Source refercurl_setopt ($ch, Curlopt_referer, $refer);//Forged Source ipcurl_setopt ($ch, Curlopt_httpheader, $headerIp);//Submit post curl_setopt ($ch, Curlopt_postfields, $postData);//... Various curl attribute parameter settings $out_put = curl_exec ($ch); Curl_close ($ch); Var_dump ($out _put);
Believe that you have read the case of this article you have mastered the method, more exciting please pay attention to the PHP Chinese network other related articles!
Recommended reading:
JS validation input retains specified decimals
Implementation code for puppeteer simulation login Crawl page