HTTP POSTに関する問題を5つ用意しました。すべて解いてFLAGを入手してください!
https://post.web.wanictf.org/
web-http-post.zip
POSTを複数回行って各チャレンジをクリアしていくサイトのようだ。
POST Challenge
site.png
配布されたソースを見る。
chal1は以下のようであった。
app.post("/chal/1", function (req, res) {
let FLAG = null;
if (req.body.data === "hoge") {
FLAG = process.env.FLAG_PART1;
}
res.render("chal", { FLAG, chal: 1 });
});
req.body.data === "hoge"
なのでdataにhoge
を入れればよい。
$ curl -X POST https://post.web.wanictf.org/chal/1 --data "data=hoge"
~~~
Congratulations! Challenge 1 FLAG: y0u
~~~
chal2は以下のようであった。
app.post("/chal/2", function (req, res) {
// リクエストヘッダのUser-AgentにどのブラウザでもついているMozilla/5.0がある場合のみFLAGを送信
let FLAG = null;
if (
req.headers["user-agent"].includes("Mozilla/5.0") &&
req.body.data === "hoge"
) {
FLAG = process.env.FLAG_PART2;
}
res.render("chal", { FLAG, chal: 2 });
});
UAをMozilla/5.0
にすればよい。
$ curl -X POST https://post.web.wanictf.org/chal/2 --data "data=hoge" -H "User-Agent: Mozilla/5.0"
~~~
Congratulations! Challenge 2 FLAG: ar3
~~~
chal3は以下のようであった。
app.post("/chal/3", function (req, res) {
let FLAG = null;
if (req.body.data?.hoge === "fuga") {
FLAG = process.env.FLAG_PART3;
}
res.render("chal", { FLAG, chal: 3 });
});
data[hoge]にfuga
を入れればよい。
$ curl -X POST https://post.web.wanictf.org/chal/3 --data "data[hoge]=fuga"
~~~
Congratulations! Challenge 3 FLAG: http
~~~
chal4は以下のようであった。
app.post("/chal/4", function (req, res) {
let FLAG = null;
if (req.body.hoge === 1 && req.body.fuga === null) {
FLAG = process.env.FLAG_PART4;
}
res.render("chal", { FLAG, chal: 4 });
});
hogeが1
でfugaがnull
である必要がある。
Content-Type: application/json
でPOSTしてやる。
$ curl -X POST https://post.web.wanictf.org/chal/4 --data '{"hoge":1,"fuga":null}' -H "Content-Type: application/json"
~~~
Congratulations! Challenge 4 FLAG: p0st
~~~
chal5は以下のようであった。
function md5file(filePath) {
const target = fs.readFileSync(filePath);
const md5hash = crypto.createHash("md5");
md5hash.update(target);
return md5hash.digest("hex");
}
app.post("/chal/5", function (req, res) {
let FLAG = null;
if (req.files?.data?.md5 === md5file("public/images/wani.png")) {
FLAG = process.env.FLAG_PART5;
}
res.render("chal", { FLAG, chal: 5 });
});
md5が一致するもの、つまりwani.pngを送れと言っている。
トップページのワニをPOSTすればよい。
$ wget https://post.web.wanictf.org/images/wani.png
~~~
$ curl -X POST https://post.web.wanictf.org/chal/5 -F data=@wani.png -H "Content-Type: multipart/form-data"
~~~
Congratulations! Challenge 5 FLAG: m@ster!
~~~
これらchal1~5を指定されたとおりに整形するとflagとなった。