下面是使用fsockopen伪造ip。
$out = "POST $path HTTP/1.1\r\n";
$out .= "Accept: */*\r\n";
$out .= "Content-Type: application/x-www-form-urlencoded\r\n";
$out .= "User-Agent: $_SERVER[HTTP_USER_AGENT]\r\n";
$out.="X-Forwarded-For: ".$ip."\r\n"; //主要是这里来构造IP
$out .= "Host: ".$domain_ip."\r\n";
$out .= "Content-Length: ".$content_length."\r\n";
$out .= "Connection: close\r\n\r\n";
$out .= $content."\r\n\r\n"; //提交的内容这个是获得客户端ip。本地可以获得伪造的ip,服务器上获得却是两个ip。比如变成这样116.7.54.78, 27.151.95.121。求帮忙 if (getenv("HTTP_X_FORWARDED_FOR"))
{
$ip = getenv("HTTP_X_FORWARDED_FOR");
}
elseif (getenv("HTTP_CLIENT_IP"))
{
$ip = getenv("HTTP_CLIENT_IP");
}
elseif (getenv("REMOTE_ADDR"))
{
$ip = getenv("REMOTE_ADDR");
}
else
{
$ip = "";
}
$out = "POST $path HTTP/1.1\r\n";
$out .= "Accept: */*\r\n";
$out .= "Content-Type: application/x-www-form-urlencoded\r\n";
$out .= "User-Agent: $_SERVER[HTTP_USER_AGENT]\r\n";
$out.="X-Forwarded-For: ".$ip."\r\n"; //主要是这里来构造IP
$out .= "Host: ".$domain_ip."\r\n";
$out .= "Content-Length: ".$content_length."\r\n";
$out .= "Connection: close\r\n\r\n";
$out .= $content."\r\n\r\n"; //提交的内容这个是获得客户端ip。本地可以获得伪造的ip,服务器上获得却是两个ip。比如变成这样116.7.54.78, 27.151.95.121。求帮忙 if (getenv("HTTP_X_FORWARDED_FOR"))
{
$ip = getenv("HTTP_X_FORWARDED_FOR");
}
elseif (getenv("HTTP_CLIENT_IP"))
{
$ip = getenv("HTTP_CLIENT_IP");
}
elseif (getenv("REMOTE_ADDR"))
{
$ip = getenv("REMOTE_ADDR");
}
else
{
$ip = "";
}
解决方案 »
- onclick事件
- php 里面赋值?
- pdflib 的问题100分散了
- 求助:PHP多重继承的问题,方法名怎么不同相同
- 请教windows下mysqlimport的--fields-terminated-by=空格如何表示
- 模糊搜索的时候,除了LIKE之外,还有么有更好的搜索方式了。mysql数据库,
- 请教,我在WINDOWS下使用备份数据库总出错误!!
- 如何取得当月的第一天和最后一天!
- 谁有网上调查系统代码,发一个给我,谢谢!!
- 哪里弄错了?Fatal error: Call to undefined function: mssql_connect() ;
- 关于intval的一个问题
- PHP如何在linux下开通ftp用户
应该是你给错了代码
http协议这么规定的,
http://zh.wikipedia.org/zh-cn/X-Forwarded-For
http协议这么规定的,
http://zh.wikipedia.org/zh-cn/X-Forwarded-For
谢谢,看到了。