2025-12-04 14:05:39 +03:00
ads
2025-12-04 13:26:39 +03:00
2025-12-04 14:02:13 +03:00
2025-12-02 20:41:40 +03:00
asd
2025-12-04 13:32:41 +03:00
ads
2025-12-04 13:26:39 +03:00
2025-12-02 14:01:34 +03:00
2025-12-03 11:03:37 +03:00
2025-12-01 21:59:32 +03:00
2025-12-02 14:01:34 +03:00
2025-12-04 14:05:39 +03:00
asd
2025-12-03 14:28:45 +03:00
2025-12-02 14:01:34 +03:00
2025-12-02 14:01:34 +03:00
2025-12-02 14:18:21 +03:00
2025-12-02 14:01:34 +03:00
2025-12-02 14:01:34 +03:00
2025-12-02 14:01:34 +03:00

A/D Infrastructure Control System

A comprehensive infrastructure control system for Attack/Defense CTF competitions. Manages services, monitors attacks, sends alerts, and provides a unified web dashboard.

Features

🎮 Service Controller

  • Start/stop/restart docker-compose services via API
  • Auto-pull changes from git repositories
  • Real-time service logs viewing
  • Service action history tracking

🎯 Scoreboard Injector

  • Real-time monitoring of ForcAD scoreboard WebSocket
  • Automatic attack detection and classification
  • Point loss threshold alerts
  • Attack statistics by service

📱 Telegram Bot

  • Automatic critical alert notifications
  • Manual message sending via API
  • Message delivery tracking
  • Group chat integration

🌐 Web Dashboard

  • Unified control panel for all services
  • Real-time attack visualization
  • Service management interface
  • Alert monitoring and testing

Quick Start

One-Line Installation

curl -sSL https://raw.githubusercontent.com/YOUR-REPO/main/install.sh | bash

Manual Installation

  1. Clone the repository
git clone https://github.com/YOUR-USERNAME/attack-defence-infr-control.git
cd attack-defence-infr-control
  1. Configure environment
cp .env.example .env
# Edit .env with your configuration
nano .env
  1. Start the infrastructure
docker-compose up -d
  1. Access the dashboard Open http://localhost:8000 in your browser (default password: admin123)

Configuration

Required Environment Variables

Edit .env file:

# Database
POSTGRES_PASSWORD=your_secure_password

# Authentication
SECRET_TOKEN=your_random_secret_token
WEB_PASSWORD=your_web_password

# Telegram
TELEGRAM_BOT_TOKEN=your_bot_token
TELEGRAM_CHAT_ID=your_chat_id

# Game Settings
OUR_TEAM_ID=1
SCOREBOARD_WS_URL=ws://scoreboard:8080/api/events

Getting Telegram Credentials

  1. Create a bot with @BotFather
  2. Get your chat ID from @userinfobot
  3. Add bot to your group and make it admin

Service Setup

After starting the infrastructure, setup your A/D services:

cd setuper
./setup.sh

This will guide you through setting up:

API Documentation

Controller API (Port 8001)

# List services
curl -H "Authorization: Bearer YOUR_TOKEN" http://localhost:8001/services

# Start a service
curl -X POST -H "Authorization: Bearer YOUR_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{"action": "start"}' \
  http://localhost:8001/services/1/action

# Get service logs
curl -H "Authorization: Bearer YOUR_TOKEN" \
  http://localhost:8001/services/1/logs?lines=100

Scoreboard Injector API (Port 8002)

# Get attack statistics
curl -H "Authorization: Bearer YOUR_TOKEN" http://localhost:8002/stats

# Get recent attacks
curl -H "Authorization: Bearer YOUR_TOKEN" \
  http://localhost:8002/attacks?limit=50&attacks_to_us=true

# Get alerts
curl -H "Authorization: Bearer YOUR_TOKEN" http://localhost:8002/alerts

Telegram Bot API (Port 8003)

# Send message
curl -X POST -H "Authorization: Bearer YOUR_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{"message": "Test alert"}' \
  http://localhost:8003/send

# Get message history
curl -H "Authorization: Bearer YOUR_TOKEN" http://localhost:8003/messages

Architecture

┌─────────────────────────────────────────────────────┐
│                  Web Dashboard :8000                │
│            (Flask + Bootstrap + jQuery)             │
└─────────────────────────────────────────────────────┘
                          │
         ┌────────────────┼────────────────┐
         │                │                │
         ▼                ▼                ▼
┌──────────────┐  ┌──────────────┐  ┌──────────────┐
│  Controller  │  │  Scoreboard  │  │  Telegram    │
│  API :8001   │  │  Injector    │  │  Bot :8003   │
│              │  │  :8002       │  │              │
└──────────────┘  └──────────────┘  └──────────────┘
         │                │                │
         └────────────────┼────────────────┘
                          │
                          ▼
                  ┌──────────────┐
                  │  PostgreSQL  │
                  │   Database   │
                  └──────────────┘

Directory Structure

.
├── controler/              # Service controller API
│   ├── main.py
│   ├── requirements.txt
│   └── Dockerfile
├── scoreboard_injector/    # Attack monitor
│   ├── main.py
│   ├── requirements.txt
│   └── Dockerfile
├── tg-bot/                 # Telegram notifications
│   ├── main.py
│   ├── requirements.txt
│   └── Dockerfile
├── web/                    # Web dashboard
│   ├── app.py
│   ├── templates/
│   ├── requirements.txt
│   └── Dockerfile
├── setuper/                # Service setup scripts
│   ├── setup.sh
│   └── README.md
├── services/               # Managed services directory
├── docker-compose.yaml     # Main compose file
├── init-db.sql            # Database schema
└── .env.example           # Configuration template

Database Schema

The system uses a single PostgreSQL instance with tables for:

  • services - Registered services
  • service_logs - Action history
  • attacks - Attack events
  • attack_alerts - Generated alerts
  • telegram_messages - Message log
  • settings - System configuration

Management Commands

# View all logs
docker-compose logs -f

# View specific service logs
docker-compose logs -f web
docker-compose logs -f controller

# Restart all services
docker-compose restart

# Stop all services
docker-compose down

# Stop and remove volumes
docker-compose down -v

# Rebuild after code changes
docker-compose up -d --build

Troubleshooting

Services won't start

# Check logs
docker-compose logs

# Verify .env configuration
cat .env

# Ensure ports are available
netstat -tulpn | grep -E '8000|8001|8002|8003'

Database connection errors

# Check PostgreSQL is running
docker-compose ps postgres

# Verify database credentials in .env
# Restart PostgreSQL
docker-compose restart postgres

WebSocket connection to scoreboard fails

  • Verify SCOREBOARD_WS_URL in .env
  • Check scoreboard is accessible
  • Ensure firewall allows WebSocket connections

Security Considerations

  1. Change default passwords in .env
  2. Use strong random tokens for SECRET_TOKEN
  3. Restrict network access to API ports in production
  4. Enable HTTPS for web dashboard in production
  5. Regularly update Docker images

Contributing

Contributions welcome! Please:

  1. Fork the repository
  2. Create a feature branch
  3. Submit a pull request

License

MIT License - see LICENSE file for details

Support

For issues and questions:

  • Open an issue on GitHub
  • Check existing documentation
  • Review logs: docker-compose logs -f

Credits

Built for Attack/Defense CTF competitions. Integrates with:

Description
No description provided
Readme MIT 136 KiB
Languages
Python 61.9%
HTML 21.6%
Shell 13.5%
Makefile 2.4%
Dockerfile 0.6%