A comprehensive, real-time Capture The Flag (CTF) platform designed for Attack-Defense style competitions with advanced scoring, team management, and administrative features.
The Attack and Defense CTF Platform is a modern, full-stack web application built for hosting competitive cybersecurity events. It provides a complete ecosystem for running Attack-Defense style CTF competitions with real-time scoring, team management, and comprehensive administrative controls.
- 🏆 Real-time Scoring System – Dynamic point calculation with multiple scoring mechanisms
- 👥 Team Management – Complete team registration, authentication, and monitoring
- 🚩 Flag Management – Comprehensive flag creation, assignment, and tracking
- ⚡ Passive Points System – Automated scoring based on flag ownership
- 📊 Live Scoreboard – Real-time competition standings and statistics
- 💬 Team Communication – Built-in chat system with moderation tools
- 🔧 Admin Dashboard – Powerful administrative interface with full control
- 📱 Responsive Design – Works seamlessly on desktop and mobile devices
- Attack-Defense Format – Teams attack others while defending their own flags
- Real-time Updates – Live scoreboard and instant score updates
- Multiple Scoring Types – Self-flag penalties, attack rewards, defense bonuses
- Configurable Timing – Customizable competition duration and intervals
- Automated Scoring – Passive points system for continuous engagement
- 🔐 Secure Admin Panel – JWT-based authentication with role management
- 📈 Real-time Analytics – Comprehensive competition statistics and insights
- ⚙️ Dynamic Configuration – Live system configuration without restarts
- 👥 Team Management – Bulk operations, score adjustments, and monitoring
- 🚩 Flag Operations – Mass flag creation, assignment, and tracking
- 💬 Chat Moderation – Message monitoring and content management
- 🔄 Competition Control – Start, stop, and manage competition phases
- 🔒 Secure Authentication – bcrypt password hashing and JWT tokens
- 🚫 Rate Limiting – API abuse prevention and submission throttling
- 🛡️ Input Validation – Comprehensive data sanitization and validation
- 📝 Audit Logging – Complete activity tracking and monitoring
- 🔐 Session Management – Secure session handling and timeout controls
- 📱 Responsive Design – Mobile-first, works on all devices
- 🌙 Modern UI – Clean, intuitive interface with Tailwind CSS
- ⚡ Real-time Updates – Live data without page refreshes
- 🔔 Notifications – In-app notifications for important events
- 📊 Visual Analytics – Charts and graphs for performance tracking
- Frontend: Next.js 15, React 18, TypeScript, Tailwind CSS
- Backend: Next.js API Routes, Node.js
- Database: MongoDB with Mongoose ODM
- Authentication: JWT tokens with secure cookies
- Deployment: Docker containerization
- UI Components: shadcn/ui component library
- Icons: Lucide React icons
Before running the application, ensure you have:
- Node.js (v18 or higher) 📦
- MongoDB (v5 or higher) 🍃
- npm or yarn package manager 📥
- Docker (optional, for containerized deployment) 🐳
start by changing the default admin user name and password in setup-database.js file:
// Create default admin account with plaintext password
// We'll handle password hashing in the application
db.admins.insertOne({
username: "admin",
password: "admin", // Plaintext password for initial login
createdAt: new Date(),
updatedAt: new Date(),
})after that run the following commands:
# Build and start all services
docker-compose up -d
# View logs
docker-compose logs -f
# Stop services
docker-compose down# Build the image
docker build -t ctf-platform .
# Run the container
docker run -p 3000:3000 --env-file .env.local ctf-platformgit clone https://github.com/Alter-N0X/ctf-attack-defense-platform.git
cd ctf-attack-defense-platformnpm install
# or
yarn installCreate a .env.local file in the root directory:
cp .env.example .env.localConfigure the following environment variables:
# Database Configuration
MONGODB_URI=mongodb://localhost:27017/ctf-platform
# JWT Secret (generate a secure random string)
JWT_SECRET=your-super-secure-jwt-secret-key
# Scoring Configuration
SELF_FLAG_POINTS=10
ATTACK_POINTS=200
DEFENSE_PENALTY=50
PASSIVE_POINTS_VALUE=1
PASSIVE_POINTS_INTERVAL=1200000
# Rate Limiting
MAX_SUBMISSIONS_PER_MINUTE=10
RATE_LIMIT_WINDOW=60000
# Competition Settings
NEXT_PUBLIC_COMPETITION_NAME="CTF Competition 2024"
NEXT_PUBLIC_COMPETITION_START="2024-01-01T00:00:00Z"
NEXT_PUBLIC_COMPETITION_END="2024-01-01T23:59:59Z"Initialize the database with the setup script:
npm run setup-dbThis creates the initial admin account:
- Username:
admin - Password:
admin
npm run devThe application will be available at http://localhost:3000
Navigate to http://localhost:3000/admin/login and use the default credentials to access the admin panel.
- 🔐 Admin Login: Access the admin panel at
/admin/login - ⚙️ Configure Settings: Set scoring rules and timing in the Configuration section
- 👥 Create Teams: Add teams manually or import via CSV
- 🚩 Add Flags: Create flags and assign them to teams
- 🎮 Initialize Competition: Use the initialization wizard for quick setup
▶️ Start Competition: Enable passive points and monitor progress
- 📝 Team Registration: Teams register with unique names and passwords
- 🔐 Login: Access team dashboard at
/login - 🚩 Submit Flags: Submit captured flags for points
- 📊 Monitor Progress: View real-time scoreboard and statistics
- 💬 Team Chat: Communicate with team members
- 📈 Track Performance: Monitor submission history and statistics
- 🎯 Attack Points: Earn points by capturing other teams' flags
- 🛡️ Defense Penalty: Lose points when your flags are captured
⚠️ Self-Flag Penalty: Penalty for submitting your own flags- ⏰ Passive Points: Automatic points based on flag ownership
- 📊 Real-time Updates: Scores update instantly across the platform
All scoring parameters are configurable through the admin panel:
| Setting | Description | Default |
|---|---|---|
| Attack Points | Points for capturing enemy flags | 200 |
| Defense Penalty | Points lost when flag is captured | 50 |
| Self Flag Points | Penalty for own flag submission | 10 |
| Passive Points Value | Points per flag per interval | 1 |
| Passive Points Interval | Time between passive awards | 20 minutes |
- Competition Duration: Set start and end times
- Passive Points Interval: Frequency of passive points awarding
- Rate Limits: Max submissions per minute to prevent abuse
Contributions are welcome! Please follow these guidelines:
- Fork the repository and create your feature branch
- Write clear, concise commit messages
- Ensure code passes linting and tests
- Submit a pull request for review





