0
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?

SECCON Beginners 2024 を紹介されたのでやってみた Wooorker

Posted at

これはなに?

会社の方に教えていただいて、面白そうだったのでイベントは終わってますが、挑戦してみようと思います

ローカル環境で実行

コードをDockerで実行します

http://localhost:34466/ にアクセスして以下のような画面が表示されました

cap.png

コードを読んでみる

process.env.FLAGが参照されている箇所は1箇所

const FLAG = process.env.FLAG;

使われているのは app/server.js:39 あたり

app.get('/flag', (req, res) => {
  const token = req.headers.authorization?.split(' ')[1];
  if (!token) {
    return res.status(401).json({ error: 'No token provided' });
  }
  
  try {
    const decoded = jwt.verify(token, jwtSecret);
    if (decoded.isAdmin) {
      const flag = FLAG;
      res.status(200).json({ flag });
    } else {
      res.status(403).json({ error: 'Access denied' });
    }
  } catch (error) {
    res.status(401).json({ error: 'Invalid token' });
  }
});
0
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
0
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?