无列名注入

写在前边

  又是没有梦想的一天。。。这里介绍一下无列名注入,要求mysql >= 5.7html

  CTF题 https://www.cnblogs.com/Lee-404/p/12830910.htmlmysql

information_schema

  在 mysql => 5 的版本中存在库information_schema,记录着mysql中全部表的结构,一般,在mysql sqli中,咱们会经过此库中的表去获取其余表的结构,即表名,列名等。可是这个库也会常常被WAF过滤。sql

sys

  在mysql5.7增长了sys 系统数据库,经过这个库能够快速的了解系统的元数据信息这个库确实能够方便DBA发现数据库的不少信息,解决性能瓶颈都提供了巨大帮助,简单来讲,当数据库版本是5.7,information_schema库被过滤时,能够利用sys这个库来读取数据

测试

  新建一个库,里边有两张表数据库

 

 

  咱们都知道,通常注入咱们都是在infromation_schema这个库里获取咱们须要的post

    猜数据库   性能

select schema_name from information_schema.schemata

   

   猜某库的数据表测试

select table_name from information_schema.tables where table_schema='数据库名'

  

  猜某表的全部列spa

Select column_name from information_schema.columns where table_name='数据表名'

    

 

   获取某列的内容设计

Select  字段名 from 数据表

   这是咱们通常的注入流程,但当information_schema被过滤,mysql又是5.7时,咱们能够利用sys库来获取信息3d

  

  先了解一下比较重要的视图

sys.schema_auto_increment_columns

  在设计表中,通常会给一些字段添加自增,若是是,那么这个视图下保存的就是那些有自增字段表的数据库的信息

 

  security是sqli-libs的数据库,test库中的test表是我本身建的,其中id字段为自增,能够在不使用information_schema的状况下读取信息

select table_schema from sys.schema_auto_increment_columns;  //查数据库

 select table_name from sys.schema_auto_increment_columns where table_schema = 'test';  //查表

   和infromation_schema同样的效果

schema_table_statistics_with_buffer,x$schema_table_statistics_with_buffer

  当表不存在自增字段时能够利用这两个视图查询,在user表中我没设自增字段

  固然还有其余的视图能够,具体利用方法和上述差很少

绕过information_schema无列名注入

    通过上述的,彷佛只能获得表名,没有完整的字段名,也就是说,咱们没法获取字段值,这时候就能够利用无列名注入,我这里直接本地测试了(环境懒得搭,伪装过滤了)

    1.获取字段数,用order by 或 group by

    2.union联合查询

select * from user where id = -1 union all select 1,2,3,group_concat(table_name)from sys.schema_table_statistics_with_buffer where table_schema=database();

 

     3.利用join获取列名(join在CTF中常常使用的思路)

select * from user where id = -1 union all select * from (select * from user as a join user as b)as c;

    4.获取更多字段名和字段值

 select * from user where id = -1 union all select*from (select * from user as a join user b using(id,username,passwd,phone))c;

 

参考连接

  https://www.anquanke.com/post/id/193512 

若有错误和不足请评论联系指出,谢谢

相关文章
相关标签/搜索