php用curl伪造ip和来源

1.php 请求 2.php 。
1.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.gosoa.com.cn/ “); //构造来路
curl_setopt($ch, curlopt_header, 1);
$out = curl_exec($ch);
curl_close($ch);
2.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”];

以上就介绍了php用curl伪造ip和来源,包括了方面的内容,希望对php教程有兴趣的朋友有所帮助。

Posted in 未分类