Skip to content

A comprehensive, real-time Capture The Flag (CTF) platform designed for Attack-Defense style competitions with advanced scoring, team management, and administrative features.

Notifications You must be signed in to change notification settings

Engineers-Spark/Attack-and-Defense-CTF-Platform

Folders and files

NameName
Last commit message
Last commit date

Latest commit

ย 

History

4 Commits
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

๐Ÿšฉ Attack and Defense CTF Platform

A comprehensive, real-time Capture The Flag (CTF) platform designed for Attack-Defense style competitions with advanced scoring, team management, and administrative features.

Next.js TypeScript MongoDB Docker License: MIT

๐ŸŽฏ Overview

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.

img6 img3 img4 img1 img2 img5

๐ŸŒŸ Core Functionalities

  • ๐Ÿ† 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

๐Ÿš€ Features

๐ŸŽฎ Competition Features

  • 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

๐Ÿ‘จโ€๐Ÿ’ผ Administrative Features

  • ๐Ÿ” 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

๐Ÿ›ก๏ธ Security Features

  • ๐Ÿ”’ 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

๐ŸŽจ User Experience

  • ๐Ÿ“ฑ 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

๐Ÿ› ๏ธ Technology Stack

  • 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

๐Ÿ“‹ Prerequisites

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) ๐Ÿณ

๐Ÿณ Docker Deployment

Using Docker Compose (Recommended)

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

Manual Docker Build

# Build the image
docker build -t ctf-platform .

# Run the container
docker run -p 3000:3000 --env-file .env.local ctf-platform

โšก Quick Start

1. ๐Ÿ“ฅ Clone the Repository

git clone https://github.com/Alter-N0X/ctf-attack-defense-platform.git
cd ctf-attack-defense-platform

2. ๐Ÿ“ฆ Install Dependencies

npm install
# or
yarn install

3. ๐Ÿ”ง Environment Configuration

Create a .env.local file in the root directory:

cp .env.example .env.local

Configure 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"

4. ๐Ÿ—„๏ธ Database Setup

Initialize the database with the setup script:

npm run setup-db

This creates the initial admin account:

  • Username: admin
  • Password: admin

โš ๏ธ Important: Change these credentials immediately after first login!

5. ๐Ÿš€ Start the Application

npm run dev

The application will be available at http://localhost:3000

6. ๐Ÿ” Admin Access

Navigate to http://localhost:3000/admin/login and use the default credentials to access the admin panel.

๐Ÿ“– Usage Guide

๐Ÿ Setting Up a Competition

  1. ๐Ÿ” Admin Login: Access the admin panel at /admin/login
  2. โš™๏ธ Configure Settings: Set scoring rules and timing in the Configuration section
  3. ๐Ÿ‘ฅ Create Teams: Add teams manually or import via CSV
  4. ๐Ÿšฉ Add Flags: Create flags and assign them to teams
  5. ๐ŸŽฎ Initialize Competition: Use the initialization wizard for quick setup
  6. โ–ถ๏ธ Start Competition: Enable passive points and monitor progress

๐Ÿ‘ฅ Team Participation

  1. ๐Ÿ“ Team Registration: Teams register with unique names and passwords
  2. ๐Ÿ” Login: Access team dashboard at /login
  3. ๐Ÿšฉ Submit Flags: Submit captured flags for points
  4. ๐Ÿ“Š Monitor Progress: View real-time scoreboard and statistics
  5. ๐Ÿ’ฌ Team Chat: Communicate with team members
  6. ๐Ÿ“ˆ Track Performance: Monitor submission history and statistics

๐ŸŽฏ Scoring System

  • ๐ŸŽฏ 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

๐Ÿ”ง Configuration

๐Ÿ“Š Scoring Configuration

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

โฑ๏ธ Timing Configuration

  • Competition Duration: Set start and end times
  • Passive Points Interval: Frequency of passive points awarding
  • Rate Limits: Max submissions per minute to prevent abuse

๐Ÿค Contribution

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

๐Ÿ™ Acknowledgments

  • Thanks to Next.js for the awesome framework
  • Inspired by real-world CTF platforms and community input
  • Icons by Lucide
  • UI components by shadcn/ui

๐ŸŒŸ Star this repository if you found it helpful!

About

A comprehensive, real-time Capture The Flag (CTF) platform designed for Attack-Defense style competitions with advanced scoring, team management, and administrative features.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages