diff --git a/README.md b/README.md index 1e6589d..9cbcbbb 100644 --- a/README.md +++ b/README.md @@ -13,20 +13,26 @@ brew bundle prek install ``` -## Lab +## Labs -Requires Docker. The lab lives in `owasp_juiceshop/`: OWASP Juice Shop (target) and a Kali desktop (attacker) run on an internal Docker network with no internet access. +Requires Docker. Each lab pairs a vulnerable target with the shared Kali desktop in `kali/` on an internal Docker network with no internet access. Only one lab runs at a time; starting one stops the other. -| Command | Purpose | -| ----------------------- | ----------------------------------------------- | -| `just juice-shop-up` | Build and start the lab; auto-off after 2 hours | -| `just juice-shop-up 30` | Same, with auto-off after 30 minutes | -| `just juice-shop-down` | Stop the lab | +| Command | Purpose | +| ----------------------- | ---------------------------------------------------------- | +| `just juice-shop-up` | Build and start the Juice Shop lab; auto-off after 2 hours | +| `just dvwa-up` | Build and start the DVWA lab; auto-off after 2 hours | +| `just juice-shop-up 30` | Either `up` command takes an auto-off time in minutes | +| `just juice-shop-down` | Stop the lab (`just dvwa-down` does the same) | + +| Lab | Directory | Target URL inside Kali | Notes | +| ---------- | ------------------ | ------------------------ | ------------------------------------------------------------------ | +| Juice Shop | `owasp_juiceshop/` | `http://juice-shop:3000` | | +| DVWA | `dvwa/` | `http://dvwa` | Log in as `admin` / `password`, then click Create / Reset Database | - Kali desktop: , password `kalilab` (override with `VNC_PASSWORD`, max 8 characters). -- Juice Shop is reachable only from inside Kali, at `http://juice-shop:3000`. -- `/home/kali` persists in the `kali-home` volume; everything else resets on `just juice-shop-down`. -- To add or update tools, edit `owasp_juiceshop/kali/Dockerfile` and run `docker compose -f owasp_juiceshop/compose.yaml build --pull --no-cache kali`. +- Targets are reachable only from inside Kali. +- `/home/kali` persists in the `kali-home` volume, shared by both labs; everything else resets when a lab stops. +- To add or update tools, edit `kali/Dockerfile` and run `docker compose -f kali/compose.yaml build --pull --no-cache kali`. ## Security checks @@ -37,4 +43,3 @@ Requires Docker. The lab lives in `owasp_juiceshop/`: OWASP Juice Shop (target) | `prek run -a` | Run the pre-commit hooks manually | Both checks run on commit via prek and in CI via `.github/workflows/security.yml`. - \ No newline at end of file diff --git a/dvwa/compose.yaml b/dvwa/compose.yaml new file mode 100644 index 0000000..fe1409b --- /dev/null +++ b/dvwa/compose.yaml @@ -0,0 +1,22 @@ +name: dvwa + +include: + - ../kali/compose.yaml + +services: + dvwa: + image: ghcr.io/digininja/dvwa:latest + environment: + DB_SERVER: db + depends_on: [db] + networks: [lab] + + # DVWA's stock database credentials; the lab network is isolated. + db: + image: mariadb:10 + environment: + MYSQL_ROOT_PASSWORD: dvwa + MYSQL_DATABASE: dvwa + MYSQL_USER: dvwa + MYSQL_PASSWORD: p@ssw0rd + networks: [lab] diff --git a/justfile b/justfile index 2f11945..a12f25d 100644 --- a/justfile +++ b/justfile @@ -1,5 +1,3 @@ -compose := "docker compose -f owasp_juiceshop/compose.yaml" - [private] list: @just --list @@ -12,16 +10,27 @@ gitleaks *args: zizmor *args: zizmor {{ args }} . -# Start the lab; it shuts itself down after `ttl` minutes -juice-shop-up ttl="120": juice-shop-timer-cancel - {{ compose }} up -d --build - nohup sh -c 'sleep $(({{ ttl }} * 60)) && {{ compose }} down' juice-shop-auto-off >/dev/null 2>&1 & - @echo "Kali desktop: http://127.0.0.1:6080/vnc.html (auto-off in {{ ttl }} min)" +# Start the Juice Shop lab; it shuts itself down after `ttl` minutes +juice-shop-up ttl="120": (lab-up "owasp_juiceshop" ttl) + +# Stop the Juice Shop lab +juice-shop-down: lab-down + +# Start the DVWA lab; it shuts itself down after `ttl` minutes +dvwa-up ttl="120": (lab-up "dvwa" ttl) -# Stop the lab -juice-shop-down: juice-shop-timer-cancel - {{ compose }} down +# Stop the DVWA lab +dvwa-down: lab-down + +# Labs share the Kali desktop port, so only one runs at a time. +[private] +lab-up dir ttl: lab-down + docker compose -f {{ dir }}/compose.yaml up -d --build + nohup sh -c 'sleep $(({{ ttl }} * 60)) && docker compose -f {{ dir }}/compose.yaml down' lab-auto-off >/dev/null 2>&1 & + @echo "Kali desktop: http://127.0.0.1:6080/vnc.html (auto-off in {{ ttl }} min)" [private] -juice-shop-timer-cancel: - -@pkill -f '[j]uice-shop-auto-off' +lab-down: + -@pkill -f '[l]ab-auto-off' + docker compose -f owasp_juiceshop/compose.yaml down + docker compose -f dvwa/compose.yaml down diff --git a/owasp_juiceshop/kali/Dockerfile b/kali/Dockerfile similarity index 100% rename from owasp_juiceshop/kali/Dockerfile rename to kali/Dockerfile diff --git a/kali/compose.yaml b/kali/compose.yaml new file mode 100644 index 0000000..a8829f8 --- /dev/null +++ b/kali/compose.yaml @@ -0,0 +1,33 @@ +# Shared attacker desktop, included by each lab's compose.yaml. +services: + kali: + build: . + image: lab-kali + environment: + VNC_PASSWORD: ${VNC_PASSWORD:-kalilab} + shm_size: 2gb + volumes: + - kali-home:/home/kali + networks: [lab] + + # Only path between the host and the lab: forwards the Kali desktop (noVNC). + gateway: + image: alpine/socat + command: TCP-LISTEN:6080,fork,reuseaddr TCP:kali:6080 + ports: + - "127.0.0.1:6080:6080" + read_only: true + cap_drop: [ALL] + depends_on: [kali] + networks: [lab, edge] + +networks: + # No route to the host network or the internet. + lab: + internal: true + edge: + +volumes: + # Fixed name so every lab shares the same home directory. + kali-home: + name: kali-home diff --git a/owasp_juiceshop/kali/entrypoint.sh b/kali/entrypoint.sh similarity index 100% rename from owasp_juiceshop/kali/entrypoint.sh rename to kali/entrypoint.sh diff --git a/owasp_juiceshop/compose.yaml b/owasp_juiceshop/compose.yaml index 6ed92e4..96aecdf 100644 --- a/owasp_juiceshop/compose.yaml +++ b/owasp_juiceshop/compose.yaml @@ -1,35 +1,9 @@ name: juice-shop +include: + - ../kali/compose.yaml + services: juice-shop: image: bkimminich/juice-shop networks: [lab] - - kali: - build: ./kali - environment: - VNC_PASSWORD: ${VNC_PASSWORD:-kalilab} - shm_size: 2gb - volumes: - - kali-home:/home/kali - networks: [lab] - - # Only path between the host and the lab: forwards the Kali desktop (noVNC). - gateway: - image: alpine/socat - command: TCP-LISTEN:6080,fork,reuseaddr TCP:kali:6080 - ports: - - "127.0.0.1:6080:6080" - read_only: true - cap_drop: [ALL] - depends_on: [kali] - networks: [lab, edge] - -networks: - # No route to the host network or the internet. - lab: - internal: true - edge: - -volumes: - kali-home: