Home > php教程 > PHP源码 > PHP伪造HTTP-REFERER来路

PHP伪造HTTP-REFERER来路

PHP中文网
Release: 2016-05-25 17:09:53
Original
1447 people have browsed it

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);
}
Copy after login
Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Recommendations
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template