Bypass XSS filter rules: advanced Web penetration testing XSS tutorial

Source: Internet
Author: User

I believe everyone has had this experience when conducting penetration tests. It is clear that there is an XSS vulnerability, but there are XSS filtering rules or WAF protection, which makes us unable to use it successfully, for example, if we enter <scirpt> alert ("hi") </script>, it is converted to <script> alert (> xss detected <) </script>, in this case, our XSS will not take effect. Here are some simple methods to bypass XSS:

1. Bypass magic_quotes_gpc

Magic_quotes_gpc = ON is the security setting in php. After it is enabled, some special characters will be rotated, for example, '(single quotation marks) is converted to \', "(double quotation marks) is converted \", \ \\

For example, <script> alert ("xss"); </script> is converted to <script> alert (\ "xss \"); </script>, in this way, our xss will not take effect.

For websites with magic_quotes_gpc enabled, we can bypass the String. fromCharCode method in javascript. We can convert alert ("XSS")

String. fromCharCode (97,108,101,114,116, 40, 34, 88, 83, 83, 34, 41) then our XSS statement becomes

<Script> String. fromCharCode (97,108,101,114,116, 40, 34, 88, 83, 83, 34, 41, 59) </script>

String. fromCharCode () is a String method in javascript to convert ASCII to a String.

How do I convert ASCII codes?

We can do it with hackbar, Firefox's extended tool https://addons.mozilla.org/en-US/firefox/addon/hackbar/.

Finally, use the <script> converted file here </script> to include it. 2. HEX Encoding we can perform hex Encoding on our statements to bypass XSS rules. For example, <script> alert ("xss"); </script> can be converted: % 3c % 73% 63% 72% 69% 70% 3e % 74% 6c % 61% 65% 72% 74% 28% 22% 78% 73% 73% 3b % 3c % 2f % 22% 29% 73% 63% 72% 3e online tools: during the testing process, we can change the case sensitivity of the test statement to bypass XSS rules such as: <script> alert ("xss"); </script> can be converted: <ScRipt> ALeRt ("XSS"); </sCRipT> 4. Disable tags. Sometimes we need to disable tags to make our XSS take effect, for example: "> <script> alert (" Hi "); </script> reference: http://www.breakthesecurity.com/2011/12/bypassing-xss-filters-advanced-xss.htmlhttp://www.exploit-db.com/papers/15446/

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.