Home > php教程 > PHP源码 > body text

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

WBOY
Release: 2016-06-08 17:24:18
Original
1176 people have browsed it

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

<script>ec(2);</script>

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

 代码如下 复制代码

$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')); //构造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 "
IP: " . getClientIp() . "";
echo "
referer: " . $_SERVER["HTTP_REFERER"];

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

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Recommendations
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!