PHP Curl Forged IP Address and header information code example, Curlheader
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.
Copy the Code code 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.
Copy the Code code 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/990549.html www.bkjia.com true http://www.bkjia.com/PHPjc/990549.html techarticle PHP Curl Forged IP Address and header information code instance, Curlheader curl although powerful, but can only forge $_server["Http_x_forwarded_for", for most IP address detection program ...