mysql_sql注入_预备知识

admin 2022年5月10日02:48:52评论34 views字数 1190阅读3分58秒阅读模式

*本文来自于暗盾网络安全社区:https://bbs.andunsec.com*


SQL注入的本质和危害不过多阐述了
把用户输入的数据当成了代码去执行,违背数据和代码分离的原则。
mysql 里面有 几个重点的内置库:mysqlsysinformation_schema
其中重点关注information_schema
mysql_sql注入_预备知识


就是下图中的3张表(可以自己打开看看里面的字段)
mysql_sql注入_预备知识


首先看个最简单的 schemata表 进入这个表主要关注schema_name 这个字段
mysql_sql注入_预备知识


所以查询的全部数据库名的语法是

select schema_name from information_schema.schemata;



接着查询某数据库下的全部表
mysql_sql注入_预备知识


table_name表示全部的表名;table_schema表示各个表名对应的数据库。
查询指定库下的表,语法相对复杂一点,要用到where指定数据库:

select table_name from information_schema.tables where table_schema='test';table_schema=‘你希望查询的数据库名’


最后一个是查列名
mysql_sql注入_预备知识


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;


mysql_sql注入_预备知识


可以看见我想查询的库了,接下来我要看这个emp_video库下的全部表

select table_name from information_schema.tables where table_schema='emp_video';


mysql_sql注入_预备知识


可以看见这只有两个表,现在查询bumen(部门)表下有什么列

select column_name from information_schema.columns where table_schema='emp_video'and table_name='bumen';


mysql_sql注入_预备知识


再想看 b_name 的数据就可以直接查询了。

select b_name from emp_video.bumen;


mysql_sql注入_预备知识

乱码的问题可以用 charset gbk; 解决。

mysql_sql注入_预备知识



以上就是information_schema 的基本知识。


原文始发于微信公众号(网安之道):mysql_sql注入_预备知识

  • 左青龙
  • 微信扫一扫
  • weinxin
  • 右白虎
  • 微信扫一扫
  • weinxin
admin
  • 本文由 发表于 2022年5月10日02:48:52
  • 转载请保留本文链接(CN-SEC中文网:感谢原作者辛苦付出):
                   mysql_sql注入_预备知识http://cn-sec.com/archives/993585.html

发表评论

匿名网友 填写信息