PHP spoofs the referer instance code, reads the PHP spoofed referer instance code, and forged the referer instance code. it is mainly used to break through anti-Leech protection. here we will provide a complete program. you can modify the specific application. The example I provided here is very simple. In fact, many applications can be shown in this example. For example, hiding a real URL ...... "> <LINKhref =" http: // ww
Counterfeit referer instance code, mainly used to break through anti-Leech protection
The complete program is provided here. you can modify the specific application on your own.
The example I provided here is very simple. In fact, many applications can be shown in this example. For example, hiding a real URL ...... Hey, let's analyze it by yourself.
Create a file. php. The following parameter is the target address of the referer to be forged. Such as: file. php/http://www.xxx.xxx/xxx.mp3
$ Url = str_replace ('/file. php/', '', $ _ SERVER [" REQUEST_URI "]); // Obtain the url to be converted. I am so lazy here that I don't need to perform security detection. I need to add it myself.
$ Downfile = str_replace ("", "% 20", $ url); // replace spaces and so on, which can be replaced according to the actual situation
$ Downfile = str_replace ("http: //", "", $ downfile); // remove http ://
$ Urlarr = explode ("/", $ downfile); // break down the domain name "/"
$ Domain = $ urlarr [0]; // domain name
$ Getfile = str_replace ($ urlarr [0], '', $ downfile); // GET The GET part in the header.
$ Content = @ fsockopen ("$ domain", 80, $ errno, $ errstr, 12); // connect to the target host
If (! $ Content) {// An error is prompted if the link is not connected.
Die ("Sorry, unable to connect to $ domain. ");
}
Fputs ($ content, "GET $ getfile HTTP/1.0 \ r \ n ");
Fputs ($ content, "Host: $ domain \ r \ n ");
Fputs ($ content, "Referer: $ domain \ r \ n"); // counterfeit part
Fputs ($ content, "User-Agent: Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1) \ r \ n ");
While (! Feof ($ content )){
$ Tp. = fgets ($ content, 128 );
If (strstr ($ tp, "200 OK") {// Here we will describe it. The first line of the header is generally the status of the request file. For details, refer to the HTTP 1.1 Status Code and its meaning. Programs in other states
Header ("Location: $ url ");
Die ();
}
}
// 302 redirection. most anti-Leech systems first judge the referer. If yes, they will then turn to the real address. The following describes how to obtain the real address.
$ Arr = explode ("\ n", $ tp );
$ Arr1 = explode ("Location:", $ tp); // returns the actual address after the Location
$ Arr2 = explode ("\ n", $ arr1 [1]);
Header ('content-Type: application/force-download'); // force download
Header ("location:". $ arr2 [0]); // redirects to the target address
Die ();
?>
This program can only use referer to determine whether the leeching anti-Leech system is used. Other special anti-Leech methods are used. This estimation is not applicable.