- 相關推薦
PHP中用CURL偽造IP來源的方法
1.文件 1.php
復制代碼 代碼如下:
<?php
$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.jquerycn.cn/ "); //來路
curl_setopt($ch, CURLOPT_HEADER, 1);
$out = curl_exec($ch);
curl_close($ch);
2.文件 2.php
復制代碼 代碼如下:
<?php
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"];
用1.php 請求 2.php,輸出結果:
IP:8.8.8.8 referer:http://www.jquerycn.cn
【PHP中用CURL偽造IP來源的方法】相關文章:
使用php偽造referer的方法04-03
PHP獲取真實的客戶IP的方法01-27
php的curl學習總結07-08
php獲取IP物理地址的方法05-15
PHP curl之操作實例01-14
PHP中CURL的幾個經典應用08-12