Try   HackMD

[CH] Useful Tools

tags: Writeup Web Chinese

curious

思路和解法

Challenge 1

如果使用 burpsuite 攔截從瀏覽器送出的 HTTP 請求的話,除了會收到正常的請求外,還會收到一個向 /burp5u17e_ch4ll3nge 的請求

Image Not Showing Possible Reasons
  • The image file may be corrupted
  • The server hosting the image is unavailable
  • The image path is incorrect
  • The image format is not supported
Learn More →

我們可以把這個請求放到 Repeater 請求看看

Image Not Showing Possible Reasons
  • The image file may be corrupted
  • The server hosting the image is unavailable
  • The image path is incorrect
  • The image format is not supported
Learn More →

可以看到 Response 回應了 Let's start the challenge!,而且可以注意到 Requests 中有一個 Challenge header 看起來就不是一般 HTTP 請求會有的 header。嘗試把 Challenge 的值改成 1 試試看

Image Not Showing Possible Reasons
  • The image file may be corrupted
  • The server hosting the image is unavailable
  • The image path is incorrect
  • The image format is not supported
Learn More →

這樣就得到第一段 flag 和下一個 challenge 的網址了

這題也可以從提示獲得一點想法

fetch("/???", {
  headers: {???: "???"}
});
document.querySelector("body").innerHTML = "...";

fetch 提示了這一段 JavaScript 會向伺服器額外送出一個帶有自訂 header 的請求,所以可以用 burpsuite 去攔截請求。
這題其實是不希望你去看 JavaScript 的,所以題目的 JavaScript 是有被混淆過的。

Challenge 2

如果直接用瀏覽器存取 /cur1_ch4ll3nge 的話會看到 "Do you know how to use curl?",所以用 curl http://lotuxctf.com:20001/cur1_ch4ll3nge 去存取這個網頁試試看

Image Not Showing Possible Reasons
  • The image file may be corrupted
  • The server hosting the image is unavailable
  • The image path is incorrect
  • The image format is not supported
Learn More →

題目問說要怎麼用 curl 看 headers,所以加上 -i 看看會怎麼樣

Image Not Showing Possible Reasons
  • The image file may be corrupted
  • The server hosting the image is unavailable
  • The image path is incorrect
  • The image format is not supported
Learn More →

看完題目給的 hint 後可以知道我們需要知道 server 提供什麼 request methods,剛好有一個 request method 叫做 OPTIONS 可以用來向伺服器詢問提供了什麼 methods,所以

Image Not Showing Possible Reasons
  • The image file may be corrupted
  • The server hosting the image is unavailable
  • The image path is incorrect
  • The image format is not supported
Learn More →

可以看到有一個非常奇怪的 method,試著用這個 method 請求看看

Image Not Showing Possible Reasons
  • The image file may be corrupted
  • The server hosting the image is unavailable
  • The image path is incorrect
  • The image format is not supported
Learn More →

這樣就可以成功進入下一個 challenge 了

Challenge 3

如果直接用瀏覽器存取 /r3que57s_ch4ll3nge 的話會看到 "How to browse websites with python?",所以使用 Python requests 來存取網頁

import requests as req r = req.get('http://lotuxctf.com:20001/r3que57s_ch4ll3nge') print(r.headers) print(r.text)

可以看到伺服器說已經驗證了身份,所以說應該會有一個 Set-Cookie 的 header 要設定我們的 cookie 來表示我們登入的身份。然後伺服器說我們要用 POST 這個 method 來取得敏感資料,為了要保持登入的身份,我們可以在 POST 的時候攜帶 Set-Cookie 要設定表示身份的 cookie,或是直接用 requests.Session 這個物件來自動完成這件事

import requests as req s = req.Session() s.get('http://lotuxctf.com:20001/r3que57s_ch4ll3nge') print(s.post('http://lotuxctf.com:20001/r3que57s_ch4ll3nge').text)

把三段 flag 組合在一起就是完整的 flag 囉!

比對一下 burpsuite,_curl,_requests 拿去做 sha256 的結果和 flag 吧