How to bypass space filtering by mysql Injection

Source: Internet
Author: User
Tags mysql injection

How to bypass space filtering by mysql Injection

During SQL injection, spaces are widely used. For example, we use union to obtain the target data:
Http://www.xxx.com/index.php? Id = 1 and 0 union select null, null, null

The preceding statement requires spaces on both sides of and, union, and select.

1. Comment bypass Spaces

This is the most basic method and is widely used in some automated SQL Injection tools. In MySQL, use
/* Comment */

To mark the content of the comment. For example, SQL query:
Select user () from dual

We can replace spaces with comments to convert them:
Select/**/user ()/**/from/**/dual

For example, the SQL command can be correctly executed:


2. Parentheses bypass Spaces

Spaces are filtered, but parentheses are not filtered. You can bypass the parentheses.

In my experience, in MySQL, parentheses are used to enclose subqueries. Therefore, any statement that can calculate the result can be enclosed in parentheses. The two ends of the brackets can have no extra spaces.

The method of bypassing spaces in parentheses is time-based blind injection.

For example, we have such an SQL query:
Select user () from dual where 1 = 1 and 2 = 2

How to minimize spaces?

It is observed that user () can calculate the value, so the user () must be enclosed in parentheses and changed:
Select (user () from dual where 1 = 1 and 2 = 2;

Continue. values 1 = 1 and 2 = 2 can be calculated, and parentheses are added to remove spaces and change:
Select (user () from dual where (1 = 1) and (2 = 2)

Spaces on both sides of dual are usually added by the programmer, which we generally cannot control. Therefore, the result is the result with the least space.


This is also a very practical technique.

Make a summary using a commonly used time-based blind injection statement:
Http://www.xxx.com/index.php? Id = (sleep (ascii (mid (user () from (2) for (1) = 109 ))

This statement is used to guess whether the second ascii code of user () is 109. If it is 109, page loading will be delayed. It:

1) No comma or symbol is used.

2) No space is used.

But it can complete data guesses!

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.