BIG BIG BIG BIG BIG UPDATES

Co-authored-by: Copilot <[email protected]>
This commit is contained in:
gabdevele
2026-05-04 23:59:48 +02:00
co-authored by Copilot
Unverified
parent 46f7cd6a5f
commit 93ba8e9ac2
88 changed files with 7591 additions and 447 deletions
+54 -49
View File
@@ -1,79 +1,84 @@
# thePlug - plugger/proxy Barese
# thePlug
icona di una presa della spina idk
Wrapper web per gestire proxy `mitmdump` davanti ai servizi di una competizione
CTF attack/defense.
## Architettura
## Struttura
```
FastAPI + MongoDB + Redis
```text
backend/ FastAPI, MongoDB, Redis, mitmdump manager
frontend/ Vue 3, Vite, Monaco editor
```
## Quick Setup (prod)
## Setup rapido
```bash
bash <(curl -s https://git.reloia.uk/reloia/thePlug/raw/branch/master/setup.sh)
./setup.sh
```
## Setup Dev
Lo script crea `backend/.env`, genera le credenziali mancanti e avvia lo stack
Docker completo:
imposta le variabili d'ambiente
```text
Frontend http://localhost:5173
Backend http://localhost:3671
```
Per installare anche il servizio systemd user:
```bash
cp .env.example .env
# modifica le variabili
nano .env
./setup.sh service
```
variabili auth richieste in `.env`:
## Dev backend
```bash
JWT_SECRET_KEY=change-this-secret
JWT_ALGORITHM=HS256
JWT_EXPIRE_MINUTES=30
AUTH_USERNAME=admin
AUTH_PASSWORD=change-this-password
cp backend/.env.example backend/.env
docker compose --env-file backend/.env up -d mongodb redis
npm run dev:backend
```
avvia i servizi e il server locale
Docs FastAPI in dev: `http://localhost:3671/docs`.
## Dev frontend
```bash
docker compose up -d mongodb redis
cd frontend
npm install
npm run dev
```
Il dev server usa `/api` come proxy verso `http://127.0.0.1:3671`.
## Test
```bash
fastapi dev app/main.py
npm run test
```
accedi a FastAPI su: [FastAPI docs](http://localhost:3671/docs)
Equivalente a:
## Auth API
```bash
cd backend && uv run ruff check . && uv run pytest
cd frontend && npm run build
```
Gli endpoint auth disponibili sono solo:
## API principali
- `POST /auth/login`
- `POST /auth/logout`
- `GET /proxy`
- `POST /proxy`
- `POST /proxy/{port}/start`
- `POST /proxy/{port}/stop`
- `POST /proxy/{port}/restart`
- `GET /proxy/{port}/health`
- `GET /proxy/{port}/logs`
- `GET /proxy/mitmproxy/options`
- `GET /proxy/mitmproxy/examples`
Esempio login:
```bash
curl -X POST http://localhost:3671/auth/login \
-H "Content-Type: application/json" \
-d '{"username":"admin","password":"change-this-password"}'
```
L'access token ottenuto va inviato come bearer token:
```bash
curl http://localhost:3671/proxy \
-H "Authorization: Bearer <ACCESS_TOKEN>"
```
Esempio logout (revoca server-side del token):
```bash
curl -X POST http://localhost:3671/auth/logout \
-H "Authorization: Bearer <ACCESS_TOKEN>"
```
## Documentazione per Sviluppo
[MitMProxy examples](https://docs.mitmproxy.org/stable/addons/examples/)
## Riferimenti
- Mitmproxy addons: https://docs.mitmproxy.org/stable/addons/examples/
- Mitmproxy modes: https://docs.mitmproxy.org/stable/concepts/modes/
- Mitmproxy options: https://docs.mitmproxy.org/stable/concepts/options/