Example of code for PHPcurl forgery of IP addresses and headers, curlheader_PHP tutorial-php Tutorial

Source: Internet
Author: User
PHPcurl is an example of code for forging IP addresses and header information, curlheader. PHPcurl is a code instance with forged IP addresses and headers. although curlheadercurl is powerful, it can only forge $ _ SERVER [HTTP_X_FORWARDED_FOR]. for most IP address detection programs, PHP curl is used to forge IP addresses and header information code instances, curlheader

Although curl is powerful, it can only forge $ _ SERVER ["HTTP_X_FORWARDED_FOR"]. for most IP address detection programs, it is difficult to forge $ _ SERVER ["REMOTE_ADDR:

First, the client. php code

The code is as follows:
$ Headers ['client-IP'] = '192. 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 an IP address
Curl_setopt ($ ch, CURLOPT_REFERER, "http://www.163.com/"); // Construct a path
Curl_setopt ($ ch, CURLOPT_HEADER, 1 );

Curl_exec ($ ch );
Curl_close ($ ch );
$ Out = ob_get_contents ();
Ob_clean ();

Echo $ out;

Then there is server. php

The code is as follows:
Function 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 "];

Http://www.bkjia.com/PHPjc/990549.htmlwww.bkjia.comtruehttp://www.bkjia.com/PHPjc/990549.htmlTechArticlePHP curl counterfeit IP address and header information code instance, curlheader curl although powerful, but can only forge $ _ SERVER ["HTTP_X_FORWARDED_FOR"], for most IP address detection programs...

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.