Principle Analysis and anatomy of XSS (1)

Source: Internet
Author: User

Principle Analysis and anatomy of XSS (1)

0 × 01 preface:

At the beginning, there was not much information about xss attack techniques on the Internet (they were all ready-made code and did not start from the basics ), it was not until the Thorn's white hat WEB security and cn4rry's XSS cross-site scripting attack analysis and defense began to improve.

Here I will not talk about the history of xss. xss is a popular and less-valued Web attack method. Why is this happening? for the following reasons:

1. time consumption 2. A certain probability of failure 3. No software for automated attacks 4. Basic html and js skills required in the Early Stage, in the future, solid knowledge of html, js, actionscript2/3.0 and other languages is required. 5. It is a passive attack method. 6. There are http-only and crossdomian attacks on websites. xml is useless

However, these vulnerabilities do not affect hackers' preferences on this vulnerability. There are no more reasons, but only one.

Almost every website exists in Xss, and google, baidu, 360, and so on.

0 × 02 principle:

First, we will build a local PHP environment (which can be installed using the phpstudy installation package), and then write the following code in the index. PHP file:

 
 
  1. <Html>
  2. <Head>
  3. <Meta http-equiv = "Content-Type" content = "text/html; charset = UTF-8"/>
  4. <Title> reproduction of XSS principles </title>
  5. </Head>
  6. <Body>
  7. <Form action = "" method = "get">
  8. <Input type = "text" name = "xss_input">
  9. <Input type = "submit">
  10. </Form>
  11. <Hr>
  12. <? Php
  13. $ Xss = $ _ GET ['xss _ input'];
  14. Echo 'the character you entered is <br> '. $ xss;
  15. ?>
  16. </Body>
  17. </Html>
  18.  

Then, you will see such a page on the page

Enter abcd123 and the result is

Let's look at the source code.

The input string is unblocked and output. Here we propose a hypothesis. Suppose we enter the following code in the search box?

 
 
  1. <script>alert('xss')</script> 

In the preceding example, there should be a gap between the [br] and [/boby]> of the 12th rows, Which is changed:

 
 
  1. <br><script>alert('xss')</script></boby> 

Then, a dialog box is displayed.

Since the assumption is proposed, we can't make it true.

We enter

 
 
  1. <script>alert('xss')</script> 

The page is

The window pops up successfully. At this time, you can basically identify the xss vulnerability.

Let's look at the source code.

It seems that our assumption is successful. This section describes the principle of XSS. The following sections describe the construction and utilization of xss.


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.