friByte has a tradition for hosting Capture the Flag, this is our open source code repository for our self developed and self hosted solution.
Functionality:
VSCode
docker run --name postgres -p 5432:5432 -e POSTGRES_PASSWORD=postgres -d postgres;
cd friByte.capture-the-flag.service
dotnet run
Visual Studio
docker run --name postgres -p 5432:5432 -e POSTGRES_PASSWORD=postgres -d postgres;
We are using Entity Framework for handling database models. We are using the concept called Code-First
where we define models in CSharp then EFCore automatically create SQL code.
Basic guide from Microsoft: https://learn.microsoft.com/en-us/ef/core/get-started/overview/first-app?tabs=netcore-cli
Essentially:
cd friByte.capture-the-flag.service/friByte.capture-the-flag.service
from root of repositorydotnet ef migrations add <NAME-OF-MIGRATION> --context CtfContext
ex: dotnet ef migrations add CtfFlag-AddHint --context CtfContext
dotnet run
.Install dependencies: npm i
or yarn
Start the application: npm run dev
or yarn run dev
To make sessions acquired from logging in with swagger persist to the frontend, make sure you access them using the same hostname (either 127.0.0.1 or localhost, as long as you use the same both places)
cd frontend
npm install
npm run dev
friByte
and password: super-duper-secret-password
(password is defined in friByte.capture-the-flag.service/friByte.capture-the-flag.service/appsettings.json
)cd frontend
npm install
npm run dev:prod-api
-> And frontend will target the production backend https://ctf-api.fribyte.no/swaggerfriByte
and password would probably be the usualThis is done to update the frontend's knowledge about routes the backend exposes.
yarn run gen-backend-hooks
or npm run gen-backend-hooks
NOTE: I've (Johannes Skivdal) experienced an error "Bindings not found" when running this command using npm. Works fine with yarn.
Make sure the backend is running on your machine on :5072 when running this command.