作者:佚名 时间:2023-11-27 09:23:31 阅读:(8)
我们在开发项目的时候经常会用到referer这个信息,虽然现在referer已经变得没有那么安全了我们还是可以用来使用的,接下来云梦编程就为大家介绍了PHP伪造来源HTTP_REFERER的方法:
$ch = curl_init(); curl_setopt ($ch, CURLOPT_URL, "https://www.yundreams.com"); curl_setopt ($ch, CURLOPT_REFERER, "http://www.yundreams.com/"); curl_exec ($ch); curl_close ($ch);
$server = 'www.yundreams.com'; $host = 'www.yundreams.com'; $target = 'index.php'; $referer = 'https://www.yundreams.com/'; // Referer $port = 80; $fp = fsockopen($server, $port, $errno, $errstr, 30); if (!$fp){ echo "$errstr ($errno)\n"; }else{ $out = "GET $target HTTP/1.1\r\n"; $out .= "Host: $host\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); }
$referer = 'https://www.yundreams.com/'; // Referer $opt=array('http'=>array('header'=>"Referer: $refer")); $context=stream_context_create($opt); $file_contents = file_get_contents($url,false, $context);
以上就是云梦编程为大家介绍的三种关于PHP伪造来源HTTP_REFERER的方法,了解更多相关文章请关注云梦编程网!