メインコンテンツへスキップ

AlpacaHack Flag for Switch writeup

    flag-for-switch.tar.gzを解凍する。

    tar -xzvf flag-for-switch.tar.gz

    flag-for-switchディレクトリが作成されるので、その中のファイルindex.jsを見てみる。

    const htmlForSwitch = `
    <!DOCTYPE html>
    <html>
      <body>
        <h1>Welcome, Switch user! Here is your flag: ${FLAG}</h1>
      </body>
    </html>
    `;
    
    app.get("/", async (req, res) => {
      const userAgent = req.headers['user-agent'] || '';
      if (userAgent.includes("Switch")) {
        res.send(htmlForSwitch);
      } else {
        res.send(html);
      }
    });
    

    以上の部分に注目してみると、userAgentがSwitchの場合のみflagを表示しているようだ。そのためcurlコマンドでuserAgentを指定して通信をする。

    curl -A "Switch" http://34.170.146.252:51785

    flagが表示された。

    flag = Alpaca{Y0u_can_really_solve_this_cha11enge_with_a_Switch!_Give_it_a_try!}

    あなたへのおすすめ