Wide-byte SQL injection

Source: Internet
Author: User
Tags sql injection

The principle of injection production:

The database is set to GBK encoding:

Wide-byte injection stems from the programmer setting the MySQL connection with an error configured as: Set CHARACTER_SET_CLIENT=GBK, which causes an injection vulnerability caused by the encoding conversion.

1, under normal circumstances, when the GPC open or use the Addslashes function will filter the GET or post submitted parameters, the hacker used by the single quotation mark (') will be escaped to: \ ';

2, but if there is wide-byte injection, when we enter%df%27, we first go through the above-mentioned single-quote escape into the%df%5c%27 (%5c is a backslash), and then in the database query

Before the GBK multibyte encoding was used, that is, the two bytes in the Chinese character coding range are encoded into a Chinese character. This creates an injection vulnerability.

The database is set to UTF-8 encoding:

Utf-8 Turn GBK

Here think of the word "Jin", its utf-8 code is E98CA6, its GBK code is%e5%5c, and the above mentioned backslash \ exactly for%5c. So if we set the title

As: ' Kam ', first through the addlashes function or GPC to the single-quote escape to: Kam \ ', and then through the ICONV function will be "Kam" to GBK encoding, and finally%e5%5c%5c%27.

The backslash is escaped (%5c%5c), which causes an injection vulnerability when the single quote escapes.

Wide-byte SQL injection

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.