# AlpacaHack daily 20260105 - Fushigi Crawler 以下のようにURLを入れるフォームがあり、`Send` ボタンを押すと `/api/crawl-request` に post して返ってきた http ステータスコードを表示するという web アプリが与えられています。  ソースコードは以下のようになっています。 ```javascript! import express from "express"; import rateLimit from "express-rate-limit"; const FLAG = process.env.FLAG ?? console.log("No flag") ?? process.exit(1); const app = express(); app.use(express.json()); app.use(express.static("public")); app.use("/api", rateLimit({ windowMs: 60 * 1000, max: 4, })); app.post("/api/crawl-request", async (req, res) => { const url = req.body?.url; if (typeof url !== "string" || (!url.startsWith("http://") && !url.startsWith("https://"))) return res.status(400).send("Invalid url"); try { const r = await fetch(url, { headers: { FLAG }, signal: AbortSignal.timeout(5000) }); // !! if (!r.ok) return res.status(502).send("Fetch failed"); return res.sendStatus(200); } catch (e) { return res.status(500).send(`Something wrong: ${e.name}`); } }); app.listen(3333); ``` `/api/crawl-request` エンドポイントの実装を見てみます。コメントにヒントがあるとおり、fetch 関数を呼ぶ際にヘッダーにフラグが含まれているので、与えられた web アプリが呼んだ fetch 関数によって送られてきたヘッダーを見ることが出来ればこの問題が解けるということになります。 このような時は https://webhook.site/ というサービスが便利です。webhook.site によって生成した webhook url を今回の問題となっている web アプリに食わせるとリクエストヘッダーを webhook.site から確認出来ます。 実際にやってみると以下のようにリクエストヘッダーに `flag` という項目があり、フラグを得られます。 
×
Sign in
Email
Password
Forgot password
or
By clicking below, you agree to our
terms of service
.
Sign in via Facebook
Sign in via Twitter
Sign in via GitHub
Sign in via Dropbox
Sign in with Wallet
Wallet (
)
Connect another wallet
New to HackMD?
Sign up