Skip to content

Platfrom with catalog of vuln services for ctf games and for generate configurations for a easy start ctf attack-defence

License

Notifications You must be signed in to change notification settings

ctf01d/ctf01d-training-platform

Folders and files

NameName
Last commit message
Last commit date
Apr 4, 2025
Apr 5, 2025
Apr 24, 2025
Apr 17, 2025
Apr 24, 2025
Apr 4, 2025
Apr 18, 2025
Apr 17, 2025
Apr 24, 2025
Apr 5, 2025
Aug 31, 2024
Apr 24, 2025
Jun 11, 2024
Sep 18, 2024
Apr 18, 2025
Apr 16, 2024
Apr 17, 2025
Apr 18, 2025
Apr 20, 2025
Apr 20, 2025

Repository files navigation

ctf01d-training-platform Backend

Go + PostgreSQL backend for CTF01D training platform.

Roadmap | Concept | Experemental Frontend


Features

  • REST API (OpenAPI 3)
  • User/team management
  • Game and scoreboard logic
  • PostgreSQL migrations

Quick Start

# 1. Запуск Π‘Π” (PostgreSQL)
docker run -d --name ctf01d-postgres -e POSTGRES_DB=ctf01d -e POSTGRES_USER=postgres -e POSTGRES_PASSWORD=postgres -p 5432:5432 postgres

# 2. Установка зависимостСй
go mod download && go mod tidy

# 3. Π‘Π±ΠΎΡ€ΠΊΠ° ΠΈ запуск
go build -o main cmd/main.go
./main

Π‘Π΅Ρ€Π²Π΅Ρ€ Π±ΡƒΠ΄Π΅Ρ‚ доступСн Π½Π° http://localhost:4102

Default admin credentials: admin/admin


Development

Requirements

  • Go 1.24+
  • Docker (для локальной Π‘Π”)

ГСнСрация ΠΊΠΎΠ΄Π° ΠΈΠ· OpenAPI

oapi-codegen -generate models,gin -o internal/server/httpserver.gen.go --package routers api/openapi.yaml

Π‘ΠΎΠ·Π΄Π°Π½ΠΈΠ΅ ΠΌΠΈΠ³Ρ€Π°Ρ†ΠΈΠΈ

go run scripts/create-migration.go

Database

  • ΠšΠΎΠ½Ρ„ΠΈΠ³: configs/config.*.yml
  • ΠŸΠΎΠ΄ΠΊΠ»ΡŽΡ‡Π΅Π½ΠΈΠ΅:
    db:
      driver: postgres
      data_source: postgres://postgres@localhost:5432/ctf01d
    
  • ΠŸΠΎΠ΄ΠΊΠ»ΡŽΡ‡Π΅Π½ΠΈΠ΅ ΠΊ ΠΊΠΎΠ½Ρ‚Π΅ΠΉΠ½Π΅Ρ€Ρƒ:
    docker exec -it ctf01d-postgres psql -U postgres

Project Structure

.
β”œβ”€β”€ api # openapi schema
β”‚   └── openapi.yaml
β”œβ”€β”€ build # docker files
β”œβ”€β”€ cmd # main app
β”‚   └── main.go
β”œβ”€β”€ configs # app config and other config (linter)
β”‚   β”œβ”€β”€ config.*.yml
β”‚   β”œβ”€β”€ golangci
β”‚   β”‚   └── golangci.yml
β”‚   └── spectral
β”‚       └── spectral.yaml
β”œβ”€β”€ docs # project documentation
β”‚   └── *.md
β”œβ”€β”€ html # current frontend
β”œβ”€β”€ internal
β”‚   β”œβ”€β”€ config
β”‚   β”‚   └── config.go
β”‚   β”œβ”€β”€ handler # backend handlers
β”‚   β”‚   └── *.go
β”‚   β”œβ”€β”€ helper # shared code
β”‚   β”‚   └── helper.go
β”‚   β”œβ”€β”€ logger
β”‚   β”‚   └── logger.go
β”‚   β”œβ”€β”€ migrations # sql migrations
β”‚   β”‚   └── psql
β”‚   β”‚       β”œβ”€β”€ struct_updater.go
β”‚   β”‚       └── update*.go
β”‚   β”œβ”€β”€ model # api json template
β”‚   β”‚   └── *.go
β”‚   β”œβ”€β”€ repository # work with db, query ...
β”‚   β”‚   └── *.go
β”‚   β”œβ”€β”€ httpserver # autogenerated code from oapi-codegen
β”‚   β”‚   β”œβ”€β”€ html_spa.go
β”‚   β”‚   └── httpserver.gen.go
β”‚   └── view
β”‚       └── session.go
β”œβ”€β”€ pkg
β”‚   └── avatar # uniq pic for user
β”‚       └── avatar.go
β”œβ”€β”€ scripts
β”‚   └── create-migration.go # make new file for migration
└── test
    └── server_integration_test.go

Contributing

See Contributing Guidelines.

About

Platfrom with catalog of vuln services for ctf games and for generate configurations for a easy start ctf attack-defence

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published