PHP 伪造HTTP_REFERER的简单示例

前端之家收集整理的这篇文章主要介绍了PHP 伪造HTTP_REFERER的简单示例前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
PHP中伪造HTTP_REFERER代码感兴趣的小伙伴,下面一起跟随编程之家 jb51.cc的小编两巴掌来看看吧!

/**
 * PHP中伪造HTTP_REFERER代码
 *
 * @param 
 * @arrange 512-笔记网: jb51.cc
 **/
//用fsockopen采集时,伪造referer的代码,
error_reporting( E_ERROR | E_WARNING | E_PARSE ); 
set_time_limit(0); 
$server = 'www.PHPerz.com'; // IP address 
$host = 'www.PHPerz.com'; // Domain name 
$target = '/test.PHP?x=1'; // Specific program 
$referer = 'http://www.PHPerz.com; // Referer 
$port = 80; 
$re = fsockopen($server,$port,$errno,$errstr,30); 
if (!$re){ 
echo "<h1>无法连接远程服务器</h1><h3>$errstr ($errno)</h3/>\n"; 
} 
else { 
$strhead = "GET $target HTTP/1.1\r\n"; 
$strhead .= "Host: $host\r\n"; 
//$strhead .= "Cookie: PHPSESSIONIDSQTBQSDA=DFCAPKLBBFICDAFMHNKIGKEG\r\n"; 
$strhead .= "Referer: $referer\r\n"; 
$strhead .= "Connection: Close\r\n\r\n";
fwrite($re,$strhead); 
while (!feof($re)){ 
echo fgets($re,128); 
} 
fclose($re); 
}
/***   来自编程之家 jb51.cc(jb51.cc)   ***/
原文链接:https://www.f2er.com/php/528121.html

猜你在找的PHP相关文章