Php CURL counterfeit IP address and source implementation program

Source: Internet
Author: User

It is very easy for php to forge IP sources. We only need to use php curl to forge IP sources. You can write IP addresses at will.

Instance

The Code is as follows: Copy code

$ Ch = curl_init ();
Curl_setopt ($ ch, CURLOPT_URL, "http: // localhost/2.php ");
Curl_setopt ($ ch, CURLOPT_HTTPHEADER, array ('x-FORWARDED-FOR: 8.8.8.8 ', 'client-IP: 8.8.8.8'); // IP
Curl_setopt ($ ch, CURLOPT_REFERER, "http://www.hzhuti.com /"); //
Curl_setopt ($ ch, CURLOPT_HEADER, 1 );
$ Out = curl_exec ($ ch );
Curl_close ($ ch );

2. php code:

The Code is as follows: Copy code

Function getClientIp (){
If (! Empty ($ _ SERVER ["HTTP_CLIENT_IP"])
$ Ip = $ _ SERVER ["HTTP_CLIENT_IP"];
Else if (! Empty ($ _ SERVER ["HTTP_X_FORWARDED_FOR"])
$ Ip = $ _ SERVER ["HTTP_X_FORWARDED_FOR"];
Else if (! Empty ($ _ SERVER ["REMOTE_ADDR"])
$ Ip = $ _ SERVER ["REMOTE_ADDR"];
Else
$ Ip = "err ";
Return $ ip;
}
Echo "IP:". getClientIp ()."";
Echo "referer:". $ _ SERVER ["HTTP_REFERER"];

Request 2.php with 1.php and output the result:

IP: 8.8.8.8 referer: http://www.hzhuti.com

Forged successfully. Does this provide a good IP address change solution for the collected friends !! Of course, you should pay attention to the anti-fake items.

CURL Library Function in PHP)

Curl_close-close a curl session
Curl_copy_handle-copy all content and parameters of a curl connection Resource
Curl_errno-A number containing the current session error message is returned.
Curl_error-returns a string containing the current session error message.
Curl_exec-execute a curl session
Curl_getinfo-obtains the information of a curl connection resource handle.
Curl_init-initialize a curl session
Curl_multi_add_handle-Add a separate curl handle resource to the curl batch processing session
Curl_multi_close-close a batch processing handle Resource
Curl_multi_exec-parse a curl batch handle
Curl_multi_getcontent-return the obtained output text stream
Curl_multi_info_read-obtains the transmission information of the currently resolved curl.
Curl_multi_init-initialize a curl batch processing handle Resource
Curl_multi_remove_handle-remove a handle resource from the curl batch processing handle.
Curl_multi_select-Get all the sockets associated with the cURL extension, which can then be "selected"
Curl_setopt_array-set session parameters for a curl in the form of an array
Curl_setopt-set session parameters for a curl
Curl_version-obtain curl-related version information

The function curl_init () initializes a curl session. The unique parameter of the curl_init () function is optional, indicating a url address.
The role of the curl_exec () function is to execute a curl session. The unique parameter is the handle returned by the curl_init () function.
The function curl_close () is used to close a curl session. The only parameter is the handle returned by the curl_init () function.


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.