Asp,php with. NET forgery Http-referer methods and methods to prevent forgery of referer _ security-related

Source: Internet
Author: User
Tags curl
Http-referer This variable has become increasingly unreliable, is completely can be forged out of the Dongdong.

The following is a forgery method:

Asp/visual Basic code
Dim http
Set Http=server.createobject ("MSXML2. XMLHTTP ") '//msxml2.serverxmlhttp can also "Get", Url,false
Http.setrequestheader "Referer", ""
Http.send ()

PHP (provided the curl is installed):

PHP code
$ch = Curl_init ();
curl_setopt ($ch, Curlopt_url, "");
curl_setopt ($ch, Curlopt_referer, "");
Curl_exec ($ch);
Curl_close ($ch);

PHP (not installed curl with sock)

PHP code
$server = ' ';
$host = ' ';
$target = '/xxx.asp ';
$referer = ''; Referer
$port = 80;
$fp = Fsockopen ($server, $port, $errno, $errstr, 30);
if (! $fp)
echo "$errstr ($errno) <br/>\n";
$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);

C # code
Dim Oxmlhttp as MSXML2. XMLHTTP30 = New MSXML2. XMLHTTP30 ()
MSXML2. XMLHTTP30 oxmlhttp = new MSXML2. XMLHTTP30 (); (.....)
Oxmlhttp.setrequestheader (.....)
Oxmlhttp.send (..


JavaScript code
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: 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.