php 跳转伪造referer,PHP页面跳转与跨站提交伪造Referer地址来源

$uinfo =

parse_url($url);//解析URL地址,比如http://php100.com/archives/1.html

if($uinfo['path']) //

$data =

$uinfo['path'];//这里得到/archives/1.html

else

$data =

'/';//默认根

if(!$fsp = @fsockopen($uinfo['host'], (($uinfo['port']) ?

$uinfo['port'] : "80"), $errno, $errstr, 12)){

echo

"对不起对方网站暂时无法打开,请您稍后访问:".$uinfo['host']; exit;

}else{

fputs($fsp, "GET “.$data .”

HTTP/1.0rn");//如果是跨站POST提交,可使用POST方法

fputs($fsp, "Host: ".$uinfo['host']."rn");

fputs($fsp, "Referer: php100.comrn");//伪造REFERER地址

fputs($fsp, "User-Agent: Mozilla/4.0 (compatible; MSIE 6.0; Windows

NT 5.1)rnrn");

$res='';

while(!feof($fsp)) {

$res.=fgets($fsp, 128);

if(strstr($res,"200 OK")) {

header("Location:$url"); exit;

}

}

}

//如果是301或302状态码可以继续处理

//返回地址大概形式:HTTP/1.1 301 Moved PermanentlynContent-Length:

164nContent-Type: text/htmlnLocation: http://php100.com/

$arr=explode("n",$res);

$arr=explode(": ",$arr[3]);//Location后面是真实重定向地址

header("location:".$arr[0]);//跳转目标地址

exit;

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值