1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

TsukuCTF 2025 Writeup

Posted at

TsukuCTF 2025

個人で参加してみました。
スクリーンショット 2025-05-08 222251.png

Casca

casca.jpg

Googleの画像検索で検索すると、すぐに熱海だとわかりました。
「ジャカランダ遊歩道 ポルトガル」で調べると以下のサイトが見つかりました(本番は違うサイトを見た気がする)。

記念碑?の写真があり、それに書いてある日付を!
入力するとクリアできました。

curve

curve.jpg

スパイラルエスカレーターです。三菱の技術らしいです。

この記事をみて、地面のタイルが一致していた「横浜ランドマークタワー」であると判断しました。

len_len

const express = require("express");
const bodyParser = require("body-parser");
const process = require("node:process");

const app = express();
const HOST = process.env.HOST ?? "localhost";
const PORT = process.env.PORT ?? "28888";
const FLAG = process.env.FLAG ?? "TsukuCTF25{dummy_flag}";

app.use(bodyParser.urlencoded({ extended: true }));

function chall(str = "[1, 2, 3]") {
  const sanitized = str.replaceAll(" ", "");
  if (sanitized.length < 10) {
    return `error: no flag for you. sanitized string is ${sanitized}, length is ${sanitized.length.toString()}`;
  }
  const array = JSON.parse(sanitized);
  if (array.length < 0) {
    // hmm...??
    return FLAG;
  }
  return `error: no flag for you. array length is too long -> ${array.length}`;
}

app.get("/", (_, res) => {
  res.send(
    `How to use -> curl -X POST -d 'array=[1,2,3,4]' http://${HOST}:${PORT}\n`,
  );
});

app.post("/", (req, res) => {
  const array = req.body.array;
  res.send(chall(array));
});

app.listen(PORT, () => {
  console.log(`Server is running on http://${HOST}:${PORT}`);
});

コードを読むとFLAGが戻り値になっている部分があります。

  if (array.length < 0) {
    // hmm...??
    return FLAG;
  }

const array = JSON.parse(sanitized);が重要で、JSON方式で書かれた配列sanitizedをJavaScript表現に変換しています。

例として以下のコードを示します。

const json = '{"name": "Suzuki", "age": 20}';
const obj = JSON.parse(json);
console.log(obj.name);  // → "Suzuki"
console.log(obj.age);   // → 20

つまり、array.lengthはarray配列の長さを示すのではなく、arrayのlength(項目)の値を示します。
'array={"length":-1}'を引数として渡すとうまくいきました。

感想

実力不足であり、解くために十分な時間をとることができなかったです。精進します。
writeupを書くなら、解き方を明確に示して答えをメモしておくべきでした。

1
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?