PHP Curl fake IP address and header information Code instance

This article mainly introduces the PHP curl fake IP address and header information code example, this article gives the server and client implementation code, to provide forgery and server-side detection code, need friends can refer to the

Although Curl is powerful, but can only forge $_server["Http_x_forwarded_for"], for most IP address detection program, $_server["REMOTE_ADDR" is difficult to be forged:

First, it's 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 ); //Structure IP

Curl_setopt ($ch, CURLOPT_REFERER, "http://www.163.com/ "); //Structure

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 = "Unable to get!"; 
Return $cip; 
} echo " Access IP: ". GetIP (). " 
"; echo " 
Access routing: ". $_server[" Http_referer "]; 

Related Article:Use Lua to implement PHP's Var_dump () function _lua

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值