首頁  >  文章  >  php教程  >  PHP伪造HTTP-REFERER来路

PHP伪造HTTP-REFERER来路

PHP中文网
PHP中文网原創
2016-05-25 17:09:531440瀏覽

php代码

//PHP(前提是装了curl):
$ch = curl_init();
curl_setopt ($ch, CURLOPT_URL, "http://blog.qita.in/xxx.asp");
curl_setopt ($ch, CURLOPT_REFERER, "http://blog.qita.in/");
curl_exec ($ch);
curl_close ($ch);
 
//PHP(不装curl用sock)
$server = 'blog.qita.in';
$host      = 'blog.qita.in';
$target    = '/xxx.asp';
$referer = 'http://blog.qita.in/';      // Referer
$port      = 80;
$fp = fsockopen($server, $port, $errno, $errstr, 30);
if (!$fp) 
{
     echo "$errstr ($errno)<br />\n";
} 
else
{
          $out = "GET $target HTTP/1.1\r\n";
          $out .= "Host: $host\r\n";
          $out .= "Cookie: ASPSESSIONIDSQTBQSDA=DFCAPKLBBFICDAFMHNKIGKEG\r\n";
          $out .= "Referer: $referer\r\n";
          $out .= "Connection: Close\r\n\r\n";
          fwrite($fp, $out);
          while (!feof($fp)) 
          {
                  echo fgets($fp, 128);
          }
          fclose($fp);
}
陳述:
本文內容由網友自願投稿,版權歸原作者所有。本站不承擔相應的法律責任。如發現涉嫌抄襲或侵權的內容,請聯絡admin@php.cn