# SecTools MISP lab

This single-instance lab uses fictional data and five Docker Compose services. It pins MISP core and nginx to `2.5.53` and misp-modules to `3.1.6`. The host entry point is `http://localhost:18081`. Inside Compose, use `http://misp-nginx:8080`.

## Start the lab

With Docker Engine already running, use `python3 lab/start.py` from the repository root to initialize or reuse credentials, wait for healthy services, and verify the login page. The manual steps are below.

From the repository root:

```sh
python3 lab/init-env.py
cd lab
docker compose config --quiet
docker compose pull
docker compose up -d --wait --wait-timeout 900
```

The initializer leaves an existing `.env` in place. Keep its encryption key with the data it protects. Read administrator credentials in a local editor and keep them out of logs and demonstrations.

## Verify the workflows

Run these commands from `lab`. The host scripts use the Python standard library. The PyMISP check uses the version included in the core image.

```sh
python3 http-check.py
python3 verify.py
python3 import-check.py
python3 modules-check.py
docker compose exec -T misp-core python3 < pymisp-check.py
python3 sharing-check.py
```

- `http-check.py` checks the login route, password and CSRF handling, cookie session, and API Auth key.
- `verify.py` loads local catalogs and checks the fictional Event, Object, tags, correlation, publication, reruns, detection queries, and STIX 2.1 export.
- `import-check.py` adds two sample Events per run and queries them by newly generated UUIDs.
- `modules-check.py` verifies workers, enables two module settings and two Warninglists, and checks the offline module round trip and Warninglist matches.
- `pymisp-check.py` checks queries and ordered pagination, then adds one Sighting per run.
- `sharing-check.py` checks visibility of three local Distribution settings and confirms the partner cannot edit the community Event. It removes the temporary key it used for the partner checks.

## Recreate containers with their named volumes

This interrupts the lab and retains named volumes. The verification after restart checks the existing data without writing replacement data.

```sh
docker compose down
docker compose up -d --wait --wait-timeout 900
python3 persistence-check.py
```

## Rehearse a MariaDB restore

```sh
python3 backup-drill.py
```

The drill restores a dump into a fresh database named `misp_restore_drill`, checks key table counts, and confirms that the training Event can be found by UUID. It leaves the live `misp` database in place. A full system recovery also requires configuration, files, and GPG material and a test after starting the restored instance.

## Stop the lab

```sh
docker compose stop
# If running the dedicated Colima environment:
colima stop --profile misp-tutorial
```

The [English handbook](https://misp-zh.sectools.tw/en/) describes the commands and the [recorded evidence](https://misp-zh.sectools.tw/en/chapters/13-verification.html). The [Traditional Chinese lab README](README.md) uses the same Compose environment.
