首页 > php代码 > php伪造IP地址与来源程序代码

php伪造IP地址与来源程序代码

在php中要伪造IP和来源是很方便的事情,我们只要不超过10行代码即可实现,下面我来介绍利用php中curl函数来操作。

下面写个构造来路google.com代码

 代码如下 复制代码

$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, http://www.phprm.com/">http://www.phprm.com/);
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.baidu.com/ "); //构造来路
curl_setopt($ch, CURLOPT_HEADER, 1);
$out = curl_exec($ch);
curl_close($ch);


我们常用的获取ip来源的函数

 代码如下 复制代码

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;
     }

得出的结果是我们为造的IP地址来源哦。

echo "<br>IP: " . getClientIp() . "";
echo "<br>referer: " . $_SERVER["HTTP_REFERER"];

得出结果是我们的IP地址:8.8.8.8 来路 baidu.com 成功了吧。



永久地址:http://www.phprm.com/code/45444.html

转载随意~请带上教程地址吧^^

标签:none

发表留言