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.