PHP Curl Forged IP Address and header information code example
This article mainly introduces the PHP curl forged IP Address and header information code example, this article gives the server-side and client implementation code, provide the forgery function and server-side detection code, the need for friends can refer to the following
Although Curl is powerful, but can only forge $_server["Http_x_forwarded_for", for most IP address detection procedures, $_server["REMOTE_ADDR"] is difficult to forge:
The first is the client.php code.
The code is as follows:
$headers [' client-ip '] = ' 202.103.229.40 ';
$headers [' x-forwarded-for '] = ' 202.103.229.40 ';
$HEADERARR = Array ();
foreach ($headers as $n = = $v) {
$HEADERARR [] = $n. ': '. $v;
}
Ob_start ();
$ch = Curl_init ();
curl_setopt ($ch, Curlopt_url, "http://localhost/curl/server.php");
curl_setopt ($ch, Curlopt_httpheader, $HEADERARR); Constructing IP
curl_setopt ($ch, Curlopt_referer, "http://www.163.com/"); Construction route
curl_setopt ($ch, Curlopt_header, 1);
Curl_exec ($ch);
Curl_close ($ch);
$out = Ob_get_contents ();
Ob_clean ();
Echo $out;
And then the server.php.
The code is as follows:
function GetIP () {
if (!emptyempty ($_server["Http_client_ip"))
$cip = $_server["Http_client_ip"];
else if (!emptyempty ($_server["http_x_forwarded_for"]))
$cip = $_server["Http_x_forwarded_for"];
else if (!emptyempty ($_server["REMOTE_ADDR"]))
$cip = $_server["REMOTE_ADDR"];
Else
$CIP = "Cannot get!";
return $CIP;
}
echo "
Access IP: ". GetIP (). "
";
echo "
Access route: ". $_server[" Http_referer "];
http://www.bkjia.com/PHPjc/990994.html www.bkjia.com true http://www.bkjia.com/PHPjc/990994.html techarticle PHP Curl Forged IP Address and header information code example this article mainly introduces the PHP curl forged IP Address and header information code example, this article gives the server-side and the client implementation code, provide ...