SQL Injection Method

前端 未结 2 1998
既然无缘
既然无缘 2021-01-27 20:36

The Injection Procedures are :

SELECT UserId, Name, Password FROM Users WHERE UserId = 105 or 1=1;

But, My Question Is how the injection query

2条回答
  •  -上瘾入骨i
    2021-01-27 21:24

    Since the condition 1=1 is always true, adding it at the end of a WHERE statement renders it irrelevant, and always true, as if the WHERE statement does not exist at all. Thus, the query is always executed, regardless of any other conditions added to the WHERE statement.

    In the example you provided, If you allow your users to write down their own userID, they can write 105 or 1=1 in the input fields or in a website's URL address, and since or 1=1 makes UserId=105 useless, and the query will always select the data, hence the SQL injection.

提交回复
热议问题