欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页  >  php教程

PHP中伪造HTTP_REFERER代码

程序员文章站 2022-04-26 16:10:49
...
  1. error_reporting( E_ERROR E_WARNING E_PARSE );
  2. set_time_limit(0);
  3. $server = 'www.php100.com'; // IP address
  4. $host = 'www.php100.com'; // Domain name
  5. $target = '/test.php?x=1'; // Specific program
  6. $referer = 'http://www.php100.net/down/redirect.php?x=downurl&id=39&urlid=65'; // Referer
  7. $port = 80;
  8. $re = fsockopen($server, $port, $errno, $errstr, 30);
  9. if (!$re){
  10. echo "h1>无法连接远程服务器h1>h3>$errstr ($errno)h3/>\n";
  11. }
  12. else {
  13. $strhead = "GET $target HTTP/1.1\r\n";
  14. $strhead .= "Host: $host\r\n";
  15. //$strhead .= "Cookie: PHPSESSIONIDSQTBQSDA=DFCAPKLBBFICDAFMHNKIGKEG\r\n";
  16. $strhead .= "Referer: $referer\r\n";
  17. $strhead .= "Connection: Close\r\n\r\n";
  18. fwrite($re, $strhead);
  19. while (!feof($re)){
  20. echo fgets($re, 128);
  21. }
  22. fclose($re);
  23. }