SQL injection principle--Universal Password injection

Source: Internet
Author: User
Tags logical operators sql injection

The principle of "universal password"
When a user authenticates a user name and password, the Web site needs to query the database. Querying the database is the execution of the SQL statement. For this BBS forum, when the user logs on, the database query operation (SQL statement) executed in the background is "Selectuser id,user type,email from users Where user id= ' username ' and password= ' password '"
Because the site background in the database query does not filter the single quotation marks, when the user name "admin" and the Universal password "2 ' or ' 1", the execution of the SQL statement is "Select User Id,user Type,email from users Whereuser id= ' admin ' and password= ' 2 ' Or1 ". Also, because the logical operators in the SQL statement have precedence, "=" takes precedence over "and", "and" takes precedence over "or" and is applicable for transitivity. Therefore, when this SQL statement is parsed in the background, it is divided into two sentences "Select User Id,user type,emall from users Where user id= ' admin andpassword= ' 2 '" and "' 1 '" two bool values for logical O n operation, Constant is true. The query result of the SQL statement is true, which means that authentication is successful and can be logged into the system.

Www.hanbotec.com

SQL injection principle--Universal Password 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.