PHP Forged HTTP header hack anti-theft chain _php Tutorial

Source: Internet
Author: User

< span="">Anti-theft chain< span="">

Forged Referer instance code, mainly used for some breakthrough anti-theft chain, than tablets, software and so on.

Here directly to the complete program, the specific application can be modified by themselves.
The example I gave here is very simple, and in fact, there are many applications that can be developed from this example. such as hiding the real URL address ... Hey, I'm going to do the exact analysis.
Create a new file file.php here. The next parameter is the target address of the referfer that needs to be forged. such as: File.php/http://www.xxx.xxx/xxx.mp3

Code:
  1. $url = Str_replace ('/file.php/',',$_server[" Request_uri "]); //Get the URL that needs to be converted. Here I am lazy, do not do safety testing, need to add their own to
  2. $downfile = Str_replace ("","%20",$url); //Replace spaces, etc., can be replaced according to the actual situation
  3. $downfile = Str_replace ("http://","",$downfile);//Remove HTTP///
  4. $urlarr = Explode ("/",$downfile); //Break out Domain name with "/"
  5. $domain = $urlarr [0]; //Domain name
  6. $getfile = Str_replace ($urlarr[0],",$downfile); //Get part of the header
  7. $content = @ Fsockopen ("$domain", $errno , $errstr,); //Connect to target host
  8. if (! $content ) {//Link not on prompt error
  9. die ("Sorry, unable to connect on $domain. ");
  10. }
  11. fputs ($content, "GET $getfile http/1.0rn");
  12. fputs ($content, "Host: $domainrn");
  13. fputs ($content, "Referer: $domainrn"); //Forged parts
  14. fputs ($content, "user-agent:mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1) rnrn ");
  15. while (! feof ($content)) {
  16. $TP .= fgets ($content, +);
  17. if (strstr($tp,"OK"){ //here to illustrate. The first line of the header is typically the state of the requested file. Please refer to the HTTP 1.1 status code and its meaning hi.baidu.com/110911/blog/item/21f20d2475af812ed50742c5.html here is the normal file request status, just a direct turn on it. Continuation program for other states
  18. Header ("Location: $url");
  19. die ();
  20. }
  21. }
  22. //302 steering, most of the anti-theft chain system is the first to judge the Referfer, the words then turn to the real address. Here's how to get the real address.
  23. $arr = Explode ("n",$tp);
  24. $arr 1 = Explode ("Location:",$tp); //Break out the real-time address behind the location
  25. $arr 2 = Explode ("n",$arr 1[1]);
  26. Header (' content-type:application/force-download '); //Mandatory Download
  27. Header ("Location:". ) $arr 2 [0]); //Turn to Destination address
  28. die ();
  29. ?>

The above code only for the use of Referer to determine whether hotlinking anti-theft chain system, the use of other special methods of anti-theft chain, it does not apply.

< span="">< span="">

  1. $txt = $_get [' url '];
  2. Echo referfile ($txt,' http://www.jbxue.com/');
  3. function referfile ($url,$refer=") {
  4. $opt = Array ('http '= =array(' header '= "Referer: $refer" ));
  5. $context =stream_context_create ($opt);
  6. Header ("Location:". ) $url );
  7. return file_get_contents($url, False,$context);
  8. }
  9. $host = "Pakey.net" ; //The domain you want to visit
  10. $target = "/test.asp" ; //The page address you want to visit
  11. $referer = "http//uuwar.com/" ;//Forge the antecedents page
  12. $fp = Fsockopen ($host, $errno , $errstr,);
  13. if (! $fp ){
  14. Echo "$errstr ($errno)
    \ n ";
  15. }Else{
  16. $out = "
  17. GET $target http/1.1
  18. Host: $host
  19. Referer: $referer
  20. Connection:close\r\n\r\n ";
  21. Fwrite ($fp, $out);
  22. while (! feof ($fp)) {
  23. Echo fgets($fp, 1024x768);
  24. }
  25. Fclose ($fp);
  26. }
  27. ?>

http://www.bkjia.com/PHPjc/743818.html www.bkjia.com true http://www.bkjia.com/PHPjc/743818.html techarticle anti-theft chain forged Referer instance code, mainly used for some breakthrough anti-theft chain, than tablets, software and so on. Here directly to the complete program, the specific application can be modified by themselves. ...

  • Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.