*本文来自于暗盾网络安全社区:https://bbs.andunsec.com*
SQL注入的本质和危害不过多阐述了
把用户输入的数据当成了代码去执行,违背数据和代码分离的原则。
mysql 里面有 几个重点的内置库:mysql
、sys
、information_schema
其中重点关注information_schema
就是下图中的3张表(可以自己打开看看里面的字段)
首先看个最简单的 schemata
表 进入这个表主要关注schema_name
这个字段
所以查询的全部数据库名的语法是
select schema_name from information_schema.schemata;
接着查询某数据库下的全部表
table_name表示全部的表名;table_schema表示各个表名对应的数据库。
查询指定库下的表,语法相对复杂一点,要用到where指定数据库:
select table_name from information_schema.tables where table_schema='test';
table_schema=‘你希望查询的数据库名’
最后一个是查列名
column_name放的是全部的列名;table_name 列对应的表名;table_schema 列对应的数据库名
查询指定数据库一张表下的全部列名:select column_name from information_schema.columns where table_schema ='test'
and table_name ='test';
table_schema='想查询列对应的库名';table_name=’想查询列对应的表名‘
——————————————————————————————————————————————
实战:
假如有一张
emp_video
对这个数据库进行查询
select schema_name from information_schema.schemata;
可以看见我想查询的库了,接下来我要看这个emp_video
库下的全部表
select table_name from information_schema.tables where table_schema='emp_video';
可以看见这只有两个表,现在查询bumen(部门)表下有什么列
select column_name from information_schema.columns where table_schema='emp_video'and table_name='bumen';
再想看 b_name 的数据就可以直接查询了。
select b_name from emp_video.bumen;
乱码的问题可以用charset gbk;
解决。
以上就是information_schema
的基本知识。
原文始发于微信公众号(网安之道):mysql_sql注入_预备知识
免责声明:文章中涉及的程序(方法)可能带有攻击性,仅供安全研究与教学之用,读者将其信息做其他用途,由读者承担全部法律及连带责任,本站不承担任何法律及连带责任;如有问题可邮件联系(建议使用企业邮箱或有效邮箱,避免邮件被拦截,联系方式见首页),望知悉。
- 左青龙
- 微信扫一扫
-
- 右白虎
- 微信扫一扫
-
评论