-
- $ch = curl_init();
- $url = "http://localhost/target_ip.php";
- $header = array(
- 'CLIENT-IP:58.68.44.61',
- ' ;
- $page_content = curl_exec($ch);
- curl_close($ch);
- echo $page_content;
- ?>
-
-
- Copy code
-
Requested target file ---target_ip.php:
echo getenv('HTTP_CLIENT_IP'); echo getenv('HTTP_X_FORWARDED_FOR');- echo getenv('REMOTE_ADDR');
- ?>
-
-
- Copy code
-
Goal The IP printing order in the file target_ip is the current IP acquisition order of many open source systems.
Visit fake_ip.php and see the results:
58.68.44.61
58.68.44.61
127.0.0.1
Finally, I’ll provide you with two small examples.
example 1:
$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')); //Construct IP
- curl_setopt($ch, CURLOPT_REFERER, "http://bbs.it-home.org/ ") ; //Construction source
- curl_setopt($ch, CURLOPT_HEADER, 1);
- $out = curl_exec($ch);
- curl_close($ch);
- ?>
-
-
- Copy code
-
Example 2:
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"];
- ?>
-
-
- Copy code
-
|