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-platform
git clone https://github.com/Alter-N0X/ctf-attack-defense-platform.git
cd ctf-attack-defense-platform
npm install
# or
yarn install
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"
Initialize the database with the setup script:
npm run setup-db
This creates the initial admin account:
- Username:
admin
- Password:
admin
npm run dev
The 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