Methods of asp,php and. NET forgery Http-referer method and prevention of forgery referer-related techniques

Source: Internet
Author: User
Tags curl php and
Http-referer This variable has become increasingly unreliable, is completely can be forged out of the Dongdong.
The following is a forgery method:
Asp:
Copy Code code as follows:

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 the curl is installed):
Copy Code code as follows:

$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 (not installed curl with sock)
Copy Code code as follows:

$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\r\n";
Fwrite ($fp, $out);
while (!feof ($FP))
{
Echo fgets ($FP, 128);
}
Fclose ($FP);
}

Vb.net/c#.net
Copy Code code as follows:

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");/??? Oh ~ fake ~
JS does not support ^_^
The principle is that sock constructs HTTP headers to SendData. Other languages, like Perl, you know,
At present, the simpler way to defend against forgery Referer is to use the verification Code (session).
Now there are some commercial companies that can use anti-theft chain software, such as Uudog,linkgate,virtualwall, are the DLLs that are developed to be applied to IIS.
Some use cookies to verify, thread control, some can randomly generate file names and do URL rewrite. Some methods can indeed achieve a good result.
However, while, outsmart, these tricks after all, there is a way to crack.
Related Article

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.