PHP hides overwrite source IP with Curl

Source: Internet
Author: User
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, '');//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: ', ' X-forwa rded-for: ',); $refer = ' '; $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

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: and provide relevant evidence. A staff member will contact you within 5 working days.

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.