mysql下的information與concat
use information_schema;
show tables;
可以看到很多表
在注入的時候,有用的表是tables,columns
這兩個表存了整個mysql資料庫中的表的資訊,列的資訊
看一下兩個表中的資訊
TABLES:
在注入過程中只需要關注兩條,table_name 和table_schema,table_name是所有表的表名,table_schema是資料庫的名字,
比如在jsp表下有很多表
查詢tables表中,當table_schema=jsp時的table_name,可以看到和use jsp;show tables;指令執行的結果一致
通俗的說法就是 看看jsp資料庫下面有哪些資料表
或者反過來查, select table_schema from information_schema.tables where table_name="c_programming";
查詢當table_name=“c_programming”時,有哪些資料庫,通俗點說就是,看看哪些資料庫下面有一個叫做“c_programming”的資料表。
COLUMNS:
這個檢視下也有table_schema,table_name,還有一個column_name
可以看一下column_name,舉個例子,看一下jsp表下的c_programming的資訊
列名分別為number,content,a,b…………
執行select column_name from information_schema.columns where table_schema="jsp" and table_name="c_programming";
這個是檢視 jsp庫下c_programming表的欄位資訊,
一致
所以可以直接用information_schema.colums表,重點為其中的table_name,column_name,table_schema幾個欄位,可以很快的得到需要的資訊
之後是concat和group_concat
concat可以把欄位拼接起來,group_concat可以把每一條資料拼接起來(前提是知道欄位名)
首先看一個表:
select concat(username,password) from admin.admin;
或者是加點其他的字元,方便區分 select concat(username," + ",password) from admin.admin;
select group_concat(username," + ",password) from admin.admin;
group_concat也可以加點東西區分,預設是一個",",在group_concat()里加一個separator引數(不要逗號)
舉個栗子:select group_concat(username," + ",password separator ';') from admin.admin;
然後來嘗試用information_schema來獲取admin所有的資訊,
1、
select database();確認資料庫名
select version();確認mysql版本
2、
select distinct table_schema from information_schema.columns;檢視所有的庫名,實戰中估計會要用到group_concat
select group_concat(distinct table_schema) from information_schema.columns;
3、
select group_concat(distinct table_name) from information_schema.columns where table_schema="admin"; 檢視該庫下的表
select group_concat(distinct table_name) from information_schema.columns where table_schema="security";
4、
select group_concat(column_name) from information_schema.columns where table_schema="security" and table_name="users";檢視該表的欄位名
select group_concat(column_name) from information_schema.columns where table_schema="admin" and table_name="admin";
5、
select group_concat(id," = ",username," = ",password separator "\n") from security.users;爆資料
select group_concat(username," = ",password separator "\n") from admin.admin;
c_programming