In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-09-23 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/03 Report--
This article introduces to you what php forges referer address methods, the content is very detailed, interested friends can refer to, hope to be helpful to you.
Methods: 1, using "file_get_contents ($url,false,$context)" function; 2, CURL mode, using curl_init (), curl_setopt (), curl_exec () and other functions; 3, using fsockopen () function.
Operating environment of this tutorial: windows7 system, PHP7.1 version, DELL G3 computer
Php gets the URL address of the previous page of the current page, that is, the page from which the current page is linked, you can use $_ SERVER ['HTTP_REFERER']
But $_ SERVER ['HTTP_REFERER'] can also be forged and deceived. There are three ways to forge and deceive $_ SERVER [' HTTP_REFERER']
Note: window platform uses phpstudy integrated environment nginx this method is invalid, apache is normal, other platforms are not tested
The first method: file_get_contents
$url = "http://localhost/test/test.php";$refer="http://www.aa.com";$opt=array('http'=>array('header'=>"Referer: $refer"); $context=stream_context_create ($opt); $file_contents = file_get_contents ($url,false, $context); echo $file_contents
Stream_context_create in file_get_contents forges important parameters of the source.
The second method: CURL
$url = "http://localhost/test/test.php"; / / requested page address $refer=" http://www.aa.com"; / / fake page address $ch = curl_init (); curl_setopt ($ch, CURLOPT_URL,$url); curl_setopt ($ch, CURLOPT_REFERER,$refer); curl_exec ($ch); curl_close ($ch)
The third method: fsockopen
$url= "http://localhost/test/test.php";$target =" http://www.manongjc.com/";/** sockopen forged website source address * @ parem $url page address to be accessed * @ parem $target fake source page * @ parem $port website port default 80 * @ parem page script execution time defaults 30 s * / function referer ($url,$target,$port=80,$t=30) {$info=parse_url ($url) $fp = fsockopen ($info ["host"], $port, $errno, $errstr, $t); if (! $fp) {echo "$errstr ($errno)" .PHP _ EOL;} else {$out = "GET". $info ['path']. " HTTP/1.1 ".PHP _ EOL; $out. =" Host: ". $info [" host "]. PHP_EOL; $out. =" Referer: ". $target.PHP_EOL; $out. =" Connection: Close ".PHP _ EOL; $out. = PHP_EOL; fwrite ($fp, $out); while (! feof ($fp)) {echo fgets ($fp) / / send head request header information} fclose ($fp);}} / / function call referer ($url,$target)
About php forged referer address which method has shared here, hoped that the above content can have the certain help to everybody, can learn more knowledge. If you think the article is good, you can share it for more people to see.
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
The market share of Chrome browser on the desktop has exceeded 70%, and users are complaining about
The world's first 2nm mobile chip: Samsung Exynos 2600 is ready for mass production.According to a r
A US federal judge has ruled that Google can keep its Chrome browser, but it will be prohibited from
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
About us Contact us Product review car news thenatureplanet
More Form oMedia: AutoTimes. Bestcoffee. SL News. Jarebook. Coffee Hunters. Sundaily. Modezone. NNB. Coffee. Game News. FrontStreet. GGAMEN
© 2024 shulou.com SLNews company. All rights reserved.