Mysticbinary

MySQL注入与informantion_schema库


MySQL V5.0安装完成会默认会生成一个库(informantion_schema),里面有几十个表,保存着关于当前数据库系统所维护的其他数据库的信息,如数据库名、表、列、数据类型与访问权限等。

只可读

informantion_schema库包含多个只读表。它们实际上是视图,而不是基表,因此没有与它们关联的文件,并且您无法在它们上设置触发器。此外,没有该名称的数据库目录。

只可读意味着,可以对里面的表执行use、select读取表的内容,但不能执行insert、update、delete操作。

自动开启

V5.6之前需要手动开启,从V5.6后默认开启;

和MySQL注入有关的3个表

以下基于MySQL 5.7.26版本进行研究;

里面虽然有很多表,但是作MySQL注入的话,先了解这3个表:

  • schemate
  • tables
  • columns

手动注入的使用案例

表介绍

表名:SCHEMATA

  • 作用:存储数据库名
  • 列名
    • SCHEMA_NAME
  • 查全部库名DEMO : select schema_name from information_schema.schemata;

表名:TABLES

  • 作用:存储表名
  • 列名:
    • TABLE_SCHEMA :表所属的数据库名称
    • TABLE_NAME: 表的名称
  • 查全部表名DEMO : select distinct table_name from information_schema.tables;

表名:COLUMNS

  • 作用:存储所有字段
  • 列名
    • TABLE_SCHEMA : 表所属的数据库名称
    • TABLE_NAME :所属表的名字
    • COLUMN_NAME : 字段名称
  • 查全部字段名DEMO : select distinct column_name from information_schema.columns;

查询一个表中全部字段的过程

模拟注入的流程

# 获取当前在使用的库名
select database(); 

# 获取当前在使用的表名
select table_name from information_schema.tables where table_schema=(
    select database()
); 

# 获取当前使用表的全部字段名
select column_name from information_schema.columns where table_name=(
    select table_name from information_schema.tables where table_schema=(select database())
); 

posted on 2021-02-14 18:15  Mysticbinary  阅读(244)  评论(0编辑  收藏  举报

导航