Example of code for PHPcurl forgery of IP addresses and headers-PHP source code

Source: Internet
Author: User
PHPcurl: Counterfeit IP address and header information code instance PHP curl: Counterfeit IP address and header information code instance

// Author http://www.lai18.com $ headers ['client-IP'] = '2017. 103.229.40 '; $ headers ['X-FORWARDED-FOR'] = '2017. 103.229.40 '; $ headerArr = array (); foreach ($ headers as $ n => $ v) {$ headerArr [] = $ n. ':'. $ v;} ob_start (); $ ch = curl_init (); curl_setopt ($ ch, CURLOPT_URL, "http: // localhost/curl/server. php "); curl_setopt ($ ch, CURLOPT_HTTPHEADER, $ headerArr); // Construct IPcurl_setopt ($ ch, CURLOPT_REFERER," http://www.163.com/"); // Construct the Origin curl_setopt ($ ch, CURLOPT_HEADER, 1); curl_exec ($ ch); curl_close ($ ch); $ out = ob_get_contents (); ob_clean (); echo $ out;
2.Then there is server. php
// Author http://www.lai18.comfunction GetIP () {if (! Emptyempty ($ _ SERVER ["HTTP_CLIENT_IP"]) $ cip = $ _ SERVER ["HTTP_CLIENT_IP"]; else if (! Emptyempty ($ _ SERVER ["HTTP_X_FORWARDED_FOR"]) $ cip = $ _ SERVER ["HTTP_X_FORWARDED_FOR"]; else if (! Emptyempty ($ _ SERVER ["REMOTE_ADDR"]) $ cip = $ _ SERVER ["REMOTE_ADDR"]; else $ cip = "cannot be obtained! "; Return $ cip;} echo" access IP: ". GetIP ()." "; echo" access path: ". $ _ SERVER [" HTTP_REFERER "];

The above is the content of the PHP curl counterfeit IP address and header information code instance. For more information, see PHP Chinese network (www.php1.cn )!

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: info-contact@alibabacloud.com 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.