您的位置:首页 > 数据库

“万能密码”SQL注入基本原理

2014-09-16 10:54 190 查看
SQL语句:

<span style="font-size:14px;">string id = "'haha' + or 1=1 or 1=1",
string password = "'123'"(any password)
string sql = string.format("select * from users where id={0} and password={1}", id, password);
</span>

可以取出一个密码,并通过登录验证。

原理:

and 优先级大于or,

<span style="font-size:14px;">where id='haha' or 1=1 or 1=1 or password='123'
=> where id='haha' or 1=1 or false
=> where true
</span>
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  万能密码 C#