php伪造referer获取header,请大神指教
$refer=XXXXX$target=XXXXX$host=XXXXX$fp=fsockopen($host,80,$errno,$errstr,30);if(!$fp...
$refer = XXXXX
$target = XXXXX
$host = XXXXX
$fp = fsockopen($host, 80, $errno, $errstr, 30);
if(!$fp){
echo "$errstr($errno)<br />\n";
}else{
$out = "
GET $target HTTP/1.1
Host: $host
Referer: $referer
Connection: Close\r\n\r\n";
fwrite($fp, $out);
while(!feof($fp)){
echo fgets($fp, 1024);
}
fclose($fp);
}
利用以上函数,获得的却是:
302 Found
The requested resource resides temporarily under a different URI.
Powered by Tengine
----------------------------------------
我的目的是伪造referer获得某页面的location信息(因为这个页面有跳转,会检测referer),应该怎么做?(最好不用curl,我的php没安装) 展开
$target = XXXXX
$host = XXXXX
$fp = fsockopen($host, 80, $errno, $errstr, 30);
if(!$fp){
echo "$errstr($errno)<br />\n";
}else{
$out = "
GET $target HTTP/1.1
Host: $host
Referer: $referer
Connection: Close\r\n\r\n";
fwrite($fp, $out);
while(!feof($fp)){
echo fgets($fp, 1024);
}
fclose($fp);
}
利用以上函数,获得的却是:
302 Found
The requested resource resides temporarily under a different URI.
Powered by Tengine
----------------------------------------
我的目的是伪造referer获得某页面的location信息(因为这个页面有跳转,会检测referer),应该怎么做?(最好不用curl,我的php没安装) 展开
1个回答
展开全部
$out那部分不能这么写
$out = "GET $target HTTP/1.1\r\nHost: $host\r\nReferer: $referer\r\nConnection: Close\r\n";
开头不能有空行,且每一行必须有换行符分隔
或者用
$out = "GET $target HTTP/1.1\r\n";
$out .= "Host: $host\r\n";
$out .= "Referer: $referer\r\n";
$out .= "Connection: Close\r\n";
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询