_javascript tips on how Cookie injection is produced

Source: Internet
Author: User
Let's look at what happens when cookies are injected! If you've ever studied ASP, you should know that.
Copy Code code as follows:

Request.QueryString (GET)

Or
Copy Code code as follows:

Request.Form (POST)

Oh, yes, that's what we use to read the value in the specified key that the user sends to the Web server! We sometimes write in order to simplify the code
Copy Code code as follows:

Id=request ("ID")

This is a simple way of writing, but the problem comes ~ ~ ~ We first look at how the Web services read data, he is to take the data in the get, no more data in the post, but also to fetch the data in the cookies (Halo, the book did not say so, this is and small high communication just know ~ ~ seems to say the book is not full ~ ~)

Let's take a look at the anti-injection system, he will detect the data in get and post, if there are special characters (of course, the character is injected)! To prohibit the submission of data! But he's not testing cookies! The question comes ~ ~ ~ So how do we test whether there is a cookie injection problem ~ Please look at the connection below (for example, so the connection is not true)
Http://www.xxx.com/1.asp?id=123

If we only lose http://www.xxx.com/1.asp, we can not see the normal data, because there are no parameters! We would like to know if there is a problem with cookies (i.e. there is no request ("XXX") format problem), first use IE input http:// Www.xxx.com/1.asp

Load Web page, show abnormal (no reason for the loss of parameters) and then enter in IE input box
Javascript:alert (document.cookie= "id=" +escape ("123"));
Press Enter and you will see a pop-up dialog box content is: After id=123, you refresh a page, if the normal display, the expression is used
Request ("ID")
This format collects data ~ ~ ~, this format can be tested cookies injected into the input box
Javascript:alert (document.cookie= "id=" +escape ("123 and 3=3"));
Refresh the page, if the display is normal, you can try the next step (if not normal, it may also have filtered)
Javascript:alert (document.cookie= "id=" +escape ("123 and 3=4"));
Refresh the page, if not normal display, this means that there is injected ~ ~ ~ If the programmer is using
Request.QueryString
Or
Request.Form
Collecting data, there is no cookie injection problem, because the service program is straightforward from Get or post to read data, cookies have data, the Web server is ignored, so can not use cookies injected! ~

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.