Methods of ASP, PHP and. Net forged HTTP-REFERER and methods of preventing forged Referer
HTTP-REFERER this variable has become increasingly unreliable, completely can be forged out of the east.
Here are the forgery methods:
ASP:
Dim HTTP
Set HTTP = server. Createobject ("msxml2.xmlhttp") '// msxml2.serverxmlhttp can also
HTTP. Open "get", URL, false
HTTP. setRequestHeader "Referer", "http://www.dc9.cn /"
HTTP. Send ()
PHP (provided that curl is installed ):
$ CH = curl_init ();
Curl_setopt ($ ch, curlopt_url, "http://www.dc9.cn/xxx.asp ");
Curl_setopt ($ ch, curlopt_referer, "http://www.dc9.cn /");
Curl_exec ($ ch );
Curl_close ($ ch );
PHP (use sock instead of curl)
$ Server = 'www .dc9.cn ';
$ Host = 'www .dc9.cn ';
$ Target = '/xxx. asp ';
$ Referer = 'HTTP: // www.dc9.cn/'; // Referer
$ Port = 80;
$ Fp = fsockopen ($ server, $ port, $ errno, $ errstr, 30 );
If (! $ FP)
{
Echo "$ errstr ($ errno) <br/> \ n ";
}
Else
{
$ Out = "get $ target HTTP/1.1 \ r \ n ";
$ Out. = "Host: $ host \ r \ n ";
$ Out. = "Cookie: aspsessionidsqtbqsda = dfcapklbbficdafmhnkigkeg \ r \ n ";
$ Out. = "Referer: $ Referer \ r \ n ";
$ Out. = "connection: Close \ r \ n ";
Fwrite ($ FP, $ out );
While (! Feof ($ FP ))
{
Echo fgets ($ FP, 128 );
}
Fclose ($ FP );
}
VB. NET/C #. net
Dim oxmlhttp as msxml2.xmlhttp30 = new msxml2.xmlhttp30 ()
Or
Msxml2.xmlhttp30 oxmlhttp = new msxml2.xmlhttp30 ();
Oxmlhttp. Open (....
Oxmlhttp. setRequestHeader (...
Oxmlhttp. Send (..
Javascript
XMLHTTP. setRequestHeader ("Referer", "http: // URL ");//??? Haha ~ Fake ~
JS does not support ipv_^
The principle is that sock constructs an HTTP header to senddata. Other languages, such as Perl, can also be used,
Currently, the simple method to defend against Referer forgery is to use a verification code (session ).
Some commercial companies that can use anti-leech software, such as uudog, linkgate, and virtualwall, are all developed to apply the DLL on IIS.
Some use cookies for verification and thread control, and some can randomly generate file names and then rewrite URLs. Some methods can indeed achieve good results.
However, the magic of these skills will eventually be cracked.