首頁  >  文章  >  php教程  >  PHP中伪造HTTP_REFERER代码

PHP中伪造HTTP_REFERER代码

WBOY
WBOY原創
2016-06-21 08:55:501191瀏覽
<ol class="dp-xml">
<li class="alt"><span><span>error_reporting( E_ERROR  E_WARNING  E_PARSE );  </span></span></li>
<li><span>set_time_limit(0); </span></li>
<li class="alt"><span> </span></li>
<li>
<span>$</span><span class="attribute">server</span><span>  = </span><span class="attribute-value">'www.php100.com'</span><span>;   // IP address  </span>
</li>
<li class="alt">
<span>$</span><span class="attribute">host</span><span>    = </span><span class="attribute-value">'www.php100.com'</span><span>;   // Domain name  </span>
</li>
<li>
<span>$</span><span class="attribute">target</span><span>  = </span><span class="attribute-value">'/test.php?x=1'</span><span>;    // Specific program  </span>
</li>
<li class="alt">
<span>$</span><span class="attribute">referer</span><span> = </span><span class="attribute-value">'http://www.php100.net/down/redirect.php?x=downurl&id=39&urlid=65'</span><span>;    // Referer  </span>
</li>
<li>
<span>$</span><span class="attribute">port</span><span>    = </span><span class="attribute-value">80</span><span>; </span>
</li>
<li class="alt"><span> </span></li>
<li>
<span>$</span><span class="attribute">re</span><span> = </span><span class="attribute-value">fsockopen</span><span>($server, $port, $errno, $errstr, 30);  </span>
</li>
<li class="alt"><span>if (!$re){  </span></li>
<li>
<span>   echo "</span><span class="tag"><span class="tag-name">h1</span><span class="tag">></span><span>无法连接远程服务器</span><span class="tag"></span><span class="tag-name">h1</span><span class="tag">></span><span class="tag"><span class="tag-name">h3</span><span class="tag">></span><span>$errstr ($errno)</span><span class="tag"></span><span class="tag-name">h3</span><span class="tag">/></span><span>\n";  </span></span></span>
</li>
<li class="alt"><span>}   </span></li>
<li><span>else {  </span></li>
<li class="alt">
<span> $</span><span class="attribute">strhead</span><span> = </span><span class="attribute-value">"GET $target HTTP/1.1\r\n"</span><span>;  </span>
</li>
<li>
<span> $strhead </span><span class="attribute">.</span><span>= </span><span class="attribute-value">"Host: $host\r\n"</span><span>;  </span>
</li>
<li class="alt">
<span> //$strhead </span><span class="attribute">.</span><span>= </span><span class="attribute-value">"Cookie: PHPSESSIONIDSQTBQSDA=DFCAPKLBBFICDAFMHNKIGKEG\r\n"</span><span>;  </span>
</li>
<li>
<span> $strhead </span><span class="attribute">.</span><span>= </span><span class="attribute-value">"Referer: $referer\r\n"</span><span>;  </span>
</li>
<li class="alt">
<span> $strhead </span><span class="attribute">.</span><span>= </span><span class="attribute-value">"Connection: Close\r\n\r\n"</span><span>;</span>
</li>
<li><span> </span></li>
<li class="alt"><span> fwrite($re, $strhead);  </span></li>
<li><span> while (!feof($re)){  </span></li>
<li class="alt"><span>  echo fgets($re, 128);  </span></li>
<li><span> }  </span></li>
<li class="alt"><span> fclose($re);  </span></li>
<li><span>}  </span></li>
<li class="alt"><span> </span></li>
</ol>




陳述:
本文內容由網友自願投稿,版權歸原作者所有。本站不承擔相應的法律責任。如發現涉嫌抄襲或侵權的內容,請聯絡admin@php.cn