PHP uses curl to forge IP address and header information
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
| 01 |
$ Headers ['client-IP'] = '192. 103.229.40 '; |
| 02 |
$ Headers ['X-FORWARDED-FOR '] = '2017. 103.229.40 '; |
| 04 |
$ HeaderArr = array (); |
| 05 |
Foreach ($ headers as $ n => $ v ){ |
| 06 |
$ HeaderArr [] = $ n. ':'. $ v; |
| 11 |
Curl_setopt ($ ch, CURLOPT_URL, "http: // localhost/curl/server. php "); |
| 12 |
Curl_setopt ($ ch, CURLOPT_HTTPHEADER, $ headerArr); // Construct an IP address |
| 13 |
Curl_setopt ($ ch, CURLOPT_REFERER, "http://www.163.com/"); // Construct a path |
| 14 |
Curl_setopt ($ ch, CURLOPT_HEADER, 1 ); |
| 18 |
$ Out = ob_get_contents (); |
Then there is server. php
| 02 |
If (! Emptyempty ($ _ SERVER ["HTTP_CLIENT_IP"]) |
| 03 |
$ Cip = $ _ SERVER ["HTTP_CLIENT_IP"]; |
| 04 |
Else if (! Emptyempty ($ _ SERVER ["HTTP_X_FORWARDED_FOR"]) |
| 05 |
$ Cip = $ _ SERVER ["HTTP_X_FORWARDED_FOR"]; |
| 06 |
Else if (! Emptyempty ($ _ SERVER ["REMOTE_ADDR"]) |
| 07 |
$ Cip = $ _ SERVER ["REMOTE_ADDR"]; |
| 09 |
$ Cip = "cannot be obtained! "; |
| 12 |
Echo" Access IP: ". GetIP ()." "; |
| 13 |
Echo" Access path: ". $ _ SERVER [" HTTP_REFERER "]; |
|
Curl, PHP, header