CTF Challenge - Mongoose RCE (CVE-2024-53900)
Challenge Overview
这个 Capture The Flag (CTF) 挑战基于 CVE-2024-53900,该漏洞存在于 Mongoose 中,由于在 MongoDB 查询中不当使用 $where 运算符,导致远程代码执行(RCE)。
你的目标是利用该漏洞,并获取隐藏在应用程序中的 flag!
Setup Instructions
1 安装依赖 确保已安装 Node.js,然后运行:
npm install
2 配置 MongoDB
安装 MongoDB 并确保其正在运行。
在根目录创建一个 .env 文件,内容如下:
MONGO_URI=mongodb://localhost:27017/ctf_db
3 启动服务器 运行存在漏洞的 Express 服务器:
node server.js
服务器将在 http://localhost:3000 启动。
Challenge Objective
你的目标是绕过身份验证,并从存在漏洞的端点中提取 flag。
Vulnerable Endpoint:
POST /login
该应用程序使用了不安全的 MongoDB $where 查询,这使得它对 NoSQL 注入和 RCE 漏洞开放。
Exploitation Hint:
尝试使用 NoSQL 注入载荷来操纵查询。
将 JavaScript 代码注入到 $where 条件中。
获取隐藏在响应中的 flag。
Directory Structure
│── public/ Frontend assets
│ ├── index.html CTF challenge UI
│ ├── style.css Styling for the challenge
│ └── script.js JavaScript for login request
│── .env Environment variables (MongoDB URI)
│── server.js Vulnerable Express.js server
│── package.json Dependencies & scripts
│── package-lock.json Lock file for dependencies
└── README.md Challenge guide (this file)
Winning Condition
如果你成功利用该漏洞,将会获得如下响应:
Login Successful! Here is your flag: FLAG{**__****}