关于HTTP_CLIENT_IP,HTTP_X_FORWAR
HTTP_CLIENT_IP:可通过http头伪造
HTTP_X_FORWARDED_FOR:可通过http头伪造
REMOTE_ADDR:可能是用户真实IP也可能是代理IP
服务端获取IP地址 http://www.taoyiz.com/util/ip 其代码如下:
$s_onlineip = getenv(‘HTTP_CLIENT_IP’);
echo “HTTP_CLIENT_IP:”.$s_onlineip.”
n”;
$s_onlineip = getenv(‘HTTP_X_FORWARDED_FOR’);
echo “HTTP_X_FORWARDED_FOR:”.$s_onlineip.”
n”;
$s_onlineip = getenv(‘REMOTE_ADDR’);
echo “REMOTE_ADDR:”.$s_onlineip.”
n”;
$s_onlineip = $_SERVER['REMOTE_ADDR'];
echo “$_SERVER['REMOTE_ADDR']:”.$s_onlineip.”
n”;
客户端代码:
伪造IP测试:
$url = ‘http://www.taoyiz.com/util/ip’;
$data_string = ‘test=test’;
$URL_Info = parse_url($url);
$request = ”;
if (!isset($URL_Info["port"]))
$URL_Info["port"]=80;
$request.=”POST “.$URL_Info["path"].” HTTP/1.1n”;
$request.=”Host: “.$URL_Info["host"].”n”;
$request.=”Referer: “.$URL_Info["host"].”n”;
$request.=”Content-type: application/x-www-form-urlencodedn”;
$request.=”X-Forwarded-For:192.168.1.4n”;//HTTP_X_FORWARDED_FOR的值
$request.=”client_ip:192.168.1.5n”;//HTTP_CLIENT_IP的值
$request.=”Content-length: “.strlen($data_string).”n”;
$request.=”Connection: closen”;
$request.=”n”;
$request.=$data_string.”n”;
$fp = fsockopen($URL_Info["host"] $URL_Info["port"]);
fputs($fp $request);
$result = ”;
while(!feof($fp)) {
$result .= fgets($fp 1024);
}
fclose($fp);
echo $result;
输出:
HTTP_CLIENT_IP:192.168.1.5
HTTP_X_FORWARDED_FOR:192.168.1.4
REMOTE_ADDR:127.0.0.1
$_SERVER['REMOTE_ADDR']:127.0.0.1
代理IP测试:
$cUrl = curl_init();
curl_setopt($cUrl CURLOPT_URL $url);
curl_setopt($cUrl CURLOPT_RETURNTRANSFER 1);
curl_setopt($cUrl CURLOPT_HEADER 1);
curl_setopt($cUrl CURLOPT_USERAGENT “Mozilla/99.99″);
//curl_setopt($cUrl CURLOPT_TIMEOUT 10);
curl_setopt($cUrl CURLOPT_PROXY ’125.77.194.103:80′);
$c = curl_exec($cUrl);
curl_close($cUrl);
echo $c;
输出:
HTTP_CLIENT_IP:
HTTP_X_FORWARDED_FOR:
REMOTE_ADDR:125.77.194.103
$_SERVER['REMOTE_ADDR']:125.77.194.103
关于HTTP_CLIENT_IP,HTTP_X_FORWAR的更多相关文章
- REMOTE_ADDR,HTTP_CLIENT_IP,HTTP_X_FORWARDED_FOR获取客户端IP
话不多说,先上代码: /** * 获得用户的真实IP地址 * * @access public * @return string */ function real_ip() { ...
- [转]REMOTE_ADDR,HTTP_CLIENT_IP,HTTP_X_FORWARDED_FOR
午睡一觉醒来,突然想伪造IP地址.搜了一下,Mark. 源地址:http://www.cnblogs.com/lmule/archive/2010/10/15/1852020.html ------- ...
- PHP获得真实客户端的真实IP REMOTE_ADDR,HTTP_CLIENT_IP,HTTP_X_FORWARDED_FOR
REMOTE_ADDR 是你的客户端跟你的服务器“握手”时候的IP.如果使用了“匿名代理”,REMOTE_ADDR将显示代理服务器的IP. HTTP_CLIENT_IP 是代理服务器发送的HTTP头. ...
- PHP获得真实客户端的真实时用到的IP REMOTE_ADDR,HTTP_CLIENT_IP,HTTP_X_FORWARDED_FOR
REMOTE_ADDR 是你的客户端跟你的服务器“握手”时候的IP.如果使用了“匿名代理”,REMOTE_ADDR将显示代理服务器的IP. HTTP_CLIENT_IP 是代理服务器发送的HTTP头. ...
- 详解REMOTE_ADDR,HTTP_CLIENT_IP,HTTP_X_FORWARDED_FOR
转载自:http://www.cnblogs.com/lmule/archive/2010/10/15/1852020.html 看ecshop的lib_base.php的时候里面获取客户端真实ip的 ...
- PHP中HTTP_X_FORWARDED_FOR、REMOTE_ADDR和HTTP_CLIENT_IP
1.REMOTE_ADDR:浏览当前页面的用户计算机的ip地址 2.HTTP_X_FORWARDED_FOR: 浏览当前页面的用户计算机的网关 3.HTTP_CLIENT_IP:客户端的ip 在PHP ...
- PHP获得真实客户端的真实IP REMOTE_ADDR,HTTP_CLIENT_IP,HTTP_X_FORWARDED_FOR[]转载
REMOTE_ADDR 是你的客户端跟你的服务器“握手”时候的IP.如果使用了“匿名代理”,REMOTE_ADDR将显示代理服务器的IP. HTTP_CLIENT_IP 是代理服务器发送的HTTP头. ...
- What is the difference between HTTP_CLIENT_IP and HTTP_X_FORWARDED_FOR
What is the difference between HTTP_CLIENT_IP and HTTP_X_FORWARDED_FOR? it is impossible to say. Dif ...
- HTTP_CLIENT_IP、HTTP_X_FORWARDED_FOR、REMOTE_ADDR
REMOTE_ADDR 是你的客户端跟你的服务器"握手"时候的IP.如果使用了"匿名代理",REMOTE_ADDR将显示代理服务器的IP. HTTP_CLIEN ...
随机推荐
- 设置ulabel的行间距
NSString *text = @"我是一个好人,12份绿色购物个 i 认为个人我国 i 加热哦围观 i我国3噢奇怪级我过街天桥哦推荐我她否认"; NSMutableParagr ...
- CentOS7 PostgreSQL 主从配置( 一)
主库配置 pg_hba.conf host replication all 10.2.0.0/0 trust postgresql.conf listen_addresses = '*' max_wa ...
- table导出到excel的两种方法
1. 用table2excel 的js文件,这种方法没有IE兼容性 需要在文件中导入 <script type="text/javascript" src="< ...
- Asp:Cookies应用指南
实际上,在web开发中,cookie仅仅是一个文本文件,当用户访问站点时,它就被存储在用户使用的计算机上,其中,保存了 一些信息,当用户日后再次访问这个站点时,web可以将这些信息提取出来. 尽 ...
- slf4j(simple logging facade for java)
http://www.tuicool.com/articles/IfeUfq slf4j(simple logging facade for java)是Java的简单的日志门面,它 不是具体的日 ...
- php非阻塞
PHP非阻塞模式 让PHP不再阻塞当PHP作为后端处理需要完成一些长时间处理,为了快速响应页面请求,不作结果返回判断的情况下,可以有如下措施: 一.若你使用的是FastCGI模式,使用fastcgi_ ...
- linux视频学习3(linux安装,shell,tcp/ip协议,网络配置)
linux系统的安装: 1.linux系统的安装方式三种: 1.独立安装linux系统. 2.虚拟机安装linux系统. a.安装虚拟机,基本是一路点下去. b.安装linux. c.linux 安装 ...
- oracle中的exists 和in
有两个简单例子,以说明 “exists”和“in”的效率问题 1) select * from T1 where exists(select 1 from T2 where T1.a=T2.a) ; ...
- Java Networking Related (Java Examples in a Nutshell 3rd Edition)
Examples to: Use URL class to parse URLs and download the network resources specified by a URL Use U ...
- 字段为空sql语句,设置当前模式
delete from t_corpinfo where CORPID='' and CORPNAME='' 该命令是删除字段为空的记录 SET CURRENT SCHEMA DB2INST1;