diff --git a/README.md b/README.md index c5da3f7..1e6589d 100644 --- a/README.md +++ b/README.md @@ -13,6 +13,21 @@ brew bundle prek install ``` +## Lab + +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. + +| 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 | + +- 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`. + ## Security checks | Command | Purpose | diff --git a/justfile b/justfile index 0ca2eea..2f11945 100644 --- a/justfile +++ b/justfile @@ -1,3 +1,5 @@ +compose := "docker compose -f owasp_juiceshop/compose.yaml" + [private] list: @just --list @@ -9,3 +11,17 @@ gitleaks *args: # Audit GitHub Actions workflows 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)" + +# Stop the lab +juice-shop-down: juice-shop-timer-cancel + {{ compose }} down + +[private] +juice-shop-timer-cancel: + -@pkill -f '[j]uice-shop-auto-off' diff --git a/owasp_juiceshop/compose.yaml b/owasp_juiceshop/compose.yaml new file mode 100644 index 0000000..6ed92e4 --- /dev/null +++ b/owasp_juiceshop/compose.yaml @@ -0,0 +1,35 @@ +name: juice-shop + +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: diff --git a/owasp_juiceshop/kali/Dockerfile b/owasp_juiceshop/kali/Dockerfile new file mode 100644 index 0000000..1e938d8 --- /dev/null +++ b/owasp_juiceshop/kali/Dockerfile @@ -0,0 +1,31 @@ +FROM kalilinux/kali-rolling + +ENV DEBIAN_FRONTEND=noninteractive + +RUN apt-get update \ + && apt-get install -y \ + kali-linux-default \ + kali-desktop-xfce \ + burpsuite \ + dbus-x11 \ + novnc \ + sudo \ + tigervnc-standalone-server \ + tigervnc-tools \ + websockify \ + zaproxy \ + && rm -rf /var/lib/apt/lists/* + +RUN useradd --create-home --shell /bin/bash --groups sudo kali \ + && echo "kali ALL=(ALL) NOPASSWD:ALL" > /etc/sudoers.d/kali \ + && mkdir -p /tmp/.X11-unix \ + && chmod 1777 /tmp/.X11-unix + +COPY --chmod=755 entrypoint.sh /usr/local/bin/entrypoint.sh + +USER kali +ENV USER=kali +WORKDIR /home/kali + +EXPOSE 6080 +ENTRYPOINT ["/usr/local/bin/entrypoint.sh"] diff --git a/owasp_juiceshop/kali/entrypoint.sh b/owasp_juiceshop/kali/entrypoint.sh new file mode 100644 index 0000000..1864569 --- /dev/null +++ b/owasp_juiceshop/kali/entrypoint.sh @@ -0,0 +1,14 @@ +#!/bin/sh +set -eu + +mkdir -p "$HOME/.vnc" +printf '%s\n' "$VNC_PASSWORD" | vncpasswd -f > "$HOME/.vnc/passwd" +chmod 600 "$HOME/.vnc/passwd" + +# Stale locks survive a container restart and block the display. +rm -f /tmp/.X1-lock /tmp/.X11-unix/X1 + +tigervncserver :1 -localhost yes -geometry 1600x900 -depth 24 \ + -PasswordFile "$HOME/.vnc/passwd" + +exec websockify --web=/usr/share/novnc 6080 localhost:5901