Php counterfeit IP address and source code-PHP source code

Source: Internet
Author: User
It is very convenient to forge IP addresses and sources in php. We only need 10 lines of code to implement it. Next I will introduce how to use the curl function in php. It is very convenient to forge IP addresses and sources in php. We only need 10 lines of code to implement it. Next I will introduce how to use the curl function in php.

Script ec (2); script

The following code constructs .com.

The Code is as follows:

$ Ch = curl_init ();
Curl_setopt ($ ch, CURLOPT_URL, http://www.111cn.net /);
Curl_setopt ($ ch, CURLOPT_HTTPHEADER, array ('x-FORWARDED-FOR: 8.8.8.8 ', 'client-IP: 8.8.8.8'); // construct an IP address
Curl_setopt ($ ch, CURLOPT_REFERER, "http://www.baidu.com/"); // construct a path
Curl_setopt ($ ch, CURLOPT_HEADER, 1 );
$ Out = curl_exec ($ ch );
Curl_close ($ ch );


Our common functions for getting ip sources

The Code is as follows:

Function getClientIp (){
If (! Emptyempty ($ _ SERVER ["HTTP_CLIENT_IP"])
$ Ip = $ _ SERVER ["HTTP_CLIENT_IP"];
Else if (! Emptyempty ($ _ SERVER ["HTTP_X_FORWARDED_FOR"])
$ Ip = $ _ SERVER ["HTTP_X_FORWARDED_FOR"];
Else if (! Emptyempty ($ _ SERVER ["REMOTE_ADDR"])
$ Ip = $ _ SERVER ["REMOTE_ADDR"];
Else
$ Ip = "err ";
Return $ ip;
}

The result is the source of the IP address.

Echo"
IP: ". getClientIp ()."";
Echo"
Referer: ". $ _ SERVER [" HTTP_REFERER "];

The result is that our IP address 8.8.8.8 is successfully connected to baidu.com.

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.