From 649f2a54c352b2afc1927388b60529a8ae6a15d7 Mon Sep 17 00:00:00 2001 From: "Florian Amette (F4K)" <50982737+florianamette@users.noreply.github.com> Date: Mon, 16 Nov 2026 01:28:11 +0100 Subject: [PATCH 1/6] ./check.sh: the repository's check, which CI runs The workflow's checks were written in it. They are now `./check.sh` (the scripts: the VM set-up's three compositions parse, shellcheck over check.sh, player-account.sh and smoke-test.sh) and `./check.sh image` (the local build and its smoke test), and image.yml's `scripts` and `smoke` jobs run those, as a contributor does. The README says how. Ran here: `./check.sh` (ok) and actionlint. Co-Authored-By: Claude Opus 5.5 --- .github/workflows/image.yml | 22 +++++----------------- README.md | 7 ++++--- check.sh | 34 ++++++++++++++++++++++++++++++++++ 3 files changed, 43 insertions(+), 20 deletions(-) create mode 100755 check.sh diff --git a/.github/workflows/image.yml b/.github/workflows/image.yml index 5a99cb6..faa2292 100644 --- a/.github/workflows/image.yml +++ b/.github/workflows/image.yml @@ -33,18 +33,8 @@ jobs: timeout-minutes: 10 steps: - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 - # The VM set-up's parts are fragments of one script (vm/kali.sh defines `$keep`): each - # composition the launcher makes must parse, with the player's account between the toolset - # and the desktop. - - name: The VM set-up parses - run: | - set -euo pipefail - for parts in "vm/kali.sh vm/toolset.sh" "vm/kali.sh vm/toolset.sh vm/desktop.sh" "vm/kali.sh vm/desktop.sh"; do - # shellcheck disable=SC2086 - { cat $parts; } | sh -n - done - - name: shellcheck - run: shellcheck player-account.sh smoke-test.sh + # The VM set-up's compositions parse, and shellcheck (check.sh, as a contributor runs it). + - run: ./check.sh scripts smoke: strategy: @@ -61,11 +51,9 @@ jobs: - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 # The image is large (~14 GB unpacked): Docker keeps its data on the runner's scratch disk. - uses: ./.github/actions/scratch-disk-docker - # No registry, no secrets: a plain local build, so pull requests from forks run it too. - - name: Build - run: docker build --pull -t attack-box:smoke . - - name: Smoke test - run: ./smoke-test.sh attack-box:smoke + # No registry, no secrets: a plain local build and its smoke test (check.sh), so pull + # requests from forks run it too. + - run: ./check.sh image build: needs: [scripts, smoke] diff --git a/README.md b/README.md index 444d8aa..42cc47d 100644 --- a/README.md +++ b/README.md @@ -32,11 +32,12 @@ The launcher assembles one `sh` script from these parts, in this order: ## Building and testing ```sh -docker build --pull -t attack-box:local . -./smoke-test.sh attack-box:local +./check.sh # the scripts: the VM set-up's compositions parse, shellcheck +./check.sh image # the image built locally and smoke-tested +./check.sh all # both ``` -The workflow builds and smoke-tests every pull request on amd64 and arm64; a push to `main`, the +The workflow runs the same command: it checks the scripts, and builds and smoke-tests every pull request on amd64 and arm64; a push to `main`, the weekly run or a manual run publishes, only once both pass, then pulls the published digest and smoke-tests it again before pinning it in the launcher. diff --git a/check.sh b/check.sh new file mode 100755 index 0000000..4707b98 --- /dev/null +++ b/check.sh @@ -0,0 +1,34 @@ +#!/usr/bin/env bash +# The attack box's check, the command CI runs (.github/workflows/image.yml) and a contributor runs: +# +# ./check.sh the scripts: the VM set-up's compositions parse, shellcheck passes +# ./check.sh image the image built locally (no registry, no secrets) and smoke-tested +# ./check.sh all both +# +# The VM set-up's parts are fragments of one script (vm/kali.sh defines `$keep`): each composition +# the launcher makes must parse, with the player's account between the toolset and the desktop. +set -euo pipefail +cd "$(dirname "$0")" + +scripts() { + local parts + for parts in "vm/kali.sh vm/toolset.sh" "vm/kali.sh vm/toolset.sh vm/desktop.sh" "vm/kali.sh vm/desktop.sh"; do + # shellcheck disable=SC2086 # the list is the files, split on purpose + if ! cat $parts | sh -n; then echo "check: the VM set-up doesn't parse as $parts" >&2; return 1; fi + done + shellcheck check.sh player-account.sh smoke-test.sh + echo "check: scripts ok" +} + +image() { + docker build --pull -t attack-box:smoke . + ./smoke-test.sh attack-box:smoke + echo "check: image ok" +} + +case "${1:-scripts}" in + scripts) scripts ;; + image) image ;; + all) scripts && image ;; + *) echo "usage: ./check.sh [scripts|image|all]" >&2; exit 2 ;; +esac From 108bdfa2ab3cfe20a5563a5256bf7863f8be871c Mon Sep 17 00:00:00 2001 From: "Florian Amette (F4K)" <50982737+florianamette@users.noreply.github.com> Date: Mon, 16 Nov 2026 14:23:32 +0100 Subject: [PATCH 2/6] The image carries an SBOM and its provenance, and the published index a signed attestation Each architecture's build pushes BuildKit's attestations with the image (an SPDX SBOM, the full SLSA provenance), and the publish job attests the multi-arch index it pushed (Sigstore, kept by GitHub and pushed to Docker Hub). README.md: how to check them for the digest the launcher pins. Co-Authored-By: Claude Opus 5.5 --- .github/workflows/image.yml | 19 ++++++++++++++++++- README.md | 14 ++++++++++++++ 2 files changed, 32 insertions(+), 1 deletion(-) diff --git a/.github/workflows/image.yml b/.github/workflows/image.yml index faa2292..ca6cffd 100644 --- a/.github/workflows/image.yml +++ b/.github/workflows/image.yml @@ -8,7 +8,9 @@ name: Attack box image # never reaches players. The launcher doesn't follow `latest`: it pins the image by digest, with # this repository's files as they were at the commit that published it. Once a publish is out, the # pushed digest is pulled and smoke-tested again on both architectures, then the `pin` job opens a -# pull request into the launcher's dev with both. +# pull request into the launcher's dev with both. Each architecture's image carries BuildKit's SBOM +# and provenance attestations, and the published index a GitHub build provenance attestation +# (README.md, "Verify the image"). on: pull_request: push: @@ -81,6 +83,10 @@ jobs: context: . platforms: ${{ matrix.platform }} outputs: type=image,name=${{ env.IMAGE }},push-by-digest=true,name-canonical=true,push=true + # BuildKit's attestations, pushed with the image: an SPDX SBOM of its packages and the + # full SLSA provenance of its build (the repository has no build secrets to leak). + sbom: true + provenance: mode=max - run: | set -euo pipefail mkdir -p /tmp/digests @@ -96,6 +102,10 @@ jobs: needs: build runs-on: ubuntu-24.04 timeout-minutes: 20 + permissions: + contents: read + id-token: write # sign the provenance attestation (Sigstore, keyless) + attestations: write outputs: digest: ${{ steps.digest.outputs.digest }} steps: @@ -127,6 +137,13 @@ jobs: [[ $digest =~ ^sha256:[0-9a-f]{64}$ ]] || { echo "::error::unexpected digest '$digest'"; exit 1; } echo "Published $IMAGE@$digest" echo "digest=$digest" >> "$GITHUB_OUTPUT" + # The published index's build provenance, signed through Sigstore, kept by GitHub and pushed + # to Docker Hub beside the image: `gh attestation verify oci://...`. + - uses: actions/attest-build-provenance@4d101475d8b20a2381f78447822ac1eab6504dd8 # v4.2.2 + with: + subject-name: index.docker.io/${{ env.IMAGE }} + subject-digest: ${{ steps.digest.outputs.digest }} + push-to-registry: true # The pushed image itself, by digest, on both architectures: the smoke job tested a local build. verify: diff --git a/README.md b/README.md index 42cc47d..c8af6e2 100644 --- a/README.md +++ b/README.md @@ -44,3 +44,17 @@ smoke-tests it again before pinning it in the launcher. It needs the Docker Hub organization's credentials (`DOCKER_ORGA`, `DOCKER_OAT`) and, for the pin, `LAUNCHER_TOKEN`: a token that can push a branch to the launcher's repository and open a pull request there. + +## Verify the image + +Each architecture's image carries BuildKit's attestations (an SPDX SBOM of its packages and the +SLSA provenance of its build), and the published multi-arch index a build provenance attestation +signed through Sigstore and kept by GitHub. With the digest the launcher pins: + +```sh +PINNED=cyberctf/attack-box@sha256:... +docker buildx imagetools inspect "$PINNED" --format '{{ json .SBOM }}' # the SBOM +docker buildx imagetools inspect "$PINNED" --format '{{ json .Provenance }}' # BuildKit's provenance +gh attestation verify "oci://index.docker.io/$PINNED" --repo CyberCTF/attack-box \ + --signer-workflow CyberCTF/attack-box/.github/workflows/image.yml # built by image.yml here +``` From 7af9d9cb2b516a3a050c4e50e054b0a15e5ff8e6 Mon Sep 17 00:00:00 2001 From: "Florian Amette (F4K)" <50982737+florianamette@users.noreply.github.com> Date: Wed, 18 Nov 2026 13:34:21 +0100 Subject: [PATCH 3/6] player-account.sh: the folder's group is the account's own where it is squashed shared_squashed=1 says the folder's mount writes as its owner whichever account writes: QEMU's virtiofsd on Linux, which vagrant-qemu runs unprivileged and Isoloom squashes every guest id to the computer's user. That virtiofsd refuses a write made through a supplementary group (it would have to take the group itself), so the player, put in the folder's group, got "Operation not permitted" creating a file there. The box still checks the folder's permissions, so the account needs the group: there it becomes its primary group, which the guest sends no supplementary-group request for. Unset, as before. Co-Authored-By: Claude Opus 5.5 --- player-account.sh | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/player-account.sh b/player-account.sh index 5d3e40f..b19bbe6 100644 --- a/player-account.sh +++ b/player-account.sh @@ -3,6 +3,11 @@ # login shell and sudo without a password. Where the shared folder ("$shared", mounted from the # computer running the lab) belongs to a user the box doesn't have, the account takes that user's # uid, and it joins the folder's group: the player writes there as that computer's user does. +# Where the folder's mount writes as its owner whoever writes ("$shared_squashed" is 1), the folder's +# group is the account's own (primary) group instead: QEMU's virtiofsd on Linux runs unprivileged, +# every account of the box squashed to the computer's user, and refuses a write made through a +# supplementary group (it would have to take that group itself, which only a privileged virtiofsd +# can), while the box still checks the folder's permissions, so the account needs the group. # Where the launcher gave the account a password, "$password_hash" is a root-only file holding its # crypt(3) hash: handed to chpasswd on its standard input, so neither the password nor its hash is # ever on a command line. The screen locker, a login, su and SSH take that password; sudo asks none. @@ -11,10 +16,11 @@ # may predate the account, or the folder's owner may differ from the image's), and once when a VM # box is set up. The launcher names the account (`attack_box::PLAYER`) and the folder. # -# account= [shared=] [password_hash=] sh player-account.sh +# account= [shared=] [shared_squashed=1] [password_hash=] sh player-account.sh set -e : "${account:?the account to make}" shared=${shared:-} +shared_squashed=${shared_squashed:-} password_hash=${password_hash:-} owner=0 @@ -43,7 +49,9 @@ fi if [ "$group" != 0 ]; then getent group "$group" >/dev/null || groupadd --gid "$group" shared || : name=$(getent group "$group" | cut -d: -f1) - if [ -n "$name" ]; then + if [ -n "$name" ] && [ "$shared_squashed" = 1 ]; then + usermod -g "$name" "$account" || echo "player-account: $shared's group isn't $account's own" >&2 + elif [ -n "$name" ]; then usermod -a -G "$name" "$account" || echo "player-account: $account isn't in $shared's group" >&2 fi fi From cb39d268d7ac0fafa5bce655f578fa9aa8acf9fc Mon Sep 17 00:00:00 2001 From: "Florian Amette (F4K)" <50982737+florianamette@users.noreply.github.com> Date: Thu, 19 Nov 2026 23:35:48 +0100 Subject: [PATCH 4/6] The launcher pins a commit and the scripts' hashes; their tests live here The launcher stops keeping a copy of the scripts (src-tauri/attack-box/): it downloads them at the commit src-tauri/attack-box.json pins and refuses one whose SHA-256 differs. The pin job writes that file (image, commit, hashes) instead of copying the files. The scripts' behaviour the launcher relied on, tested in its Rust tests until now, is tested here: tests/scripts.sh, run by ./check.sh, on stand-ins for the tools (Kali's key check, the toolset only where missing, the account and the shared folder's group, the desktop's sign-in and screen lock). Co-Authored-By: Claude Opus 5.5 --- .github/workflows/image.yml | 25 +++++---- README.md | 10 ++-- check.sh | 6 ++- tests/scripts.sh | 100 ++++++++++++++++++++++++++++++++++++ 4 files changed, 125 insertions(+), 16 deletions(-) create mode 100755 tests/scripts.sh diff --git a/.github/workflows/image.yml b/.github/workflows/image.yml index ca6cffd..af7d346 100644 --- a/.github/workflows/image.yml +++ b/.github/workflows/image.yml @@ -174,7 +174,7 @@ jobs: timeout-minutes: 15 env: LAUNCHER: Cyber-Courses/Cyber-CTF-Launcher - DIR: src-tauri/attack-box + PIN: src-tauri/attack-box.json steps: - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 with: @@ -192,22 +192,25 @@ jobs: PINNED: ${{ env.IMAGE }}@${{ needs.publish.outputs.digest }} run: | set -euo pipefail - file="$DIR/image.json" - if [ "$(jq -er .image "$file")" = "$PINNED" ]; then - echo "The launcher already pins $PINNED" + if [ "$(jq -er .image "$PIN")" = "$PINNED" ] && [ "$(jq -er .commit "$PIN")" = "$GITHUB_SHA" ]; then + echo "The launcher already pins $PINNED with the files at $GITHUB_SHA" exit 0 fi - # The old pin joins `previous`, so a player's saved old default moves to the new one. - jq --arg new "$PINNED" '.previous = ([.image] + .previous | map(select(. != $new)) | unique) | .image = $new' "$file" > "$RUNNER_TEMP/image.json" - mv "$RUNNER_TEMP/image.json" "$file" - cp ../attack-box/player-account.sh "$DIR/player-account.sh" - mkdir -p "$DIR/vm" - cp ../attack-box/vm/kali.sh ../attack-box/vm/toolset.sh ../attack-box/vm/desktop.sh "$DIR/vm/" + # The launcher keeps no copy of the scripts: it downloads them at this commit and checks + # each against its SHA-256 here. + files="$(cd ../attack-box && for f in player-account.sh vm/kali.sh vm/toolset.sh vm/desktop.sh; do + printf '%s\t%s\n' "$f" "$(sha256sum "$f" | cut -d' ' -f1)"; done | jq -Rn '[inputs | split("\t") | {(.[0]): .[1]}] | add')" + # An image that changed: the old one joins `previous`, so a player's saved old default + # moves to the new one. + jq --arg new "$PINNED" --arg commit "$GITHUB_SHA" --argjson files "$files" \ + '(if .image != $new then .previous = ([.image] + .previous | map(select(. != $new)) | unique) else . end) + | .image = $new | .commit = $commit | .files = $files' "$PIN" > "$RUNNER_TEMP/attack-box.json" + mv "$RUNNER_TEMP/attack-box.json" "$PIN" branch="attack-box-pin-${PINNED: -12}" git config user.name "github-actions[bot]" git config user.email "41898282+github-actions[bot]@users.noreply.github.com" git checkout -q -b "$branch" - git add "$DIR" + git add "$PIN" git commit -qm "Attack box: pin ${PINNED#*@}" -m "Published and smoke-tested on amd64 and arm64 by $GITHUB_SERVER_URL/$GITHUB_REPOSITORY/actions/runs/$GITHUB_RUN_ID, with the attack box's files at $GITHUB_SHA." git push -q origin "$branch" gh pr create --repo "$LAUNCHER" --base dev --head "$branch" \ diff --git a/README.md b/README.md index c8af6e2..77a2c2e 100644 --- a/README.md +++ b/README.md @@ -25,9 +25,13 @@ The launcher assembles one `sh` script from these parts, in this order: - The account is `player` (`ARG PLAYER=player`), with a home, passwordless sudo and a password of the box's own; the launcher opens its shell as that account. `smoke-test.sh` checks it. -- The launcher pins this repository's output: the image by its digest, and these files as they - were at the commit that published it. A publish opens a pull request into the launcher's `dev` - with both (`.github/workflows/image.yml`, its `pin` job). +- The launcher pins this repository's output in its `src-tauri/attack-box.json`: the image by its + digest, the commit that published it, and each script's SHA-256 there. It keeps no copy of the + scripts: it downloads them at that commit and refuses one whose hash differs. A publish opens a + pull request into the launcher's `dev` with the new pin (`.github/workflows/image.yml`, its `pin` + job). +- The scripts' behaviour is tested here (`tests/scripts.sh`, run by `./check.sh`); the launcher + tests only how it puts them together. ## Building and testing diff --git a/check.sh b/check.sh index 4707b98..3f6eb3f 100755 --- a/check.sh +++ b/check.sh @@ -1,7 +1,8 @@ #!/usr/bin/env bash # The attack box's check, the command CI runs (.github/workflows/image.yml) and a contributor runs: # -# ./check.sh the scripts: the VM set-up's compositions parse, shellcheck passes +# ./check.sh the scripts: the VM set-up's compositions parse, shellcheck passes, and +# their tests (tests/scripts.sh) pass # ./check.sh image the image built locally (no registry, no secrets) and smoke-tested # ./check.sh all both # @@ -16,7 +17,8 @@ scripts() { # shellcheck disable=SC2086 # the list is the files, split on purpose if ! cat $parts | sh -n; then echo "check: the VM set-up doesn't parse as $parts" >&2; return 1; fi done - shellcheck check.sh player-account.sh smoke-test.sh + shellcheck check.sh player-account.sh smoke-test.sh tests/scripts.sh + tests/scripts.sh echo "check: scripts ok" } diff --git a/tests/scripts.sh b/tests/scripts.sh new file mode 100755 index 0000000..da5e1c1 --- /dev/null +++ b/tests/scripts.sh @@ -0,0 +1,100 @@ +#!/usr/bin/env bash +# shellcheck disable=SC2016 # the scripts' own text, its `$` literal +# The scripts' behaviour, on stand-ins for the tools they call (no root, no VM): what the launcher +# relies on when it downloads them at its pinned commit. Run by ./check.sh. Moved from the +# launcher's own tests (src-tauri/src/runtime/attack_box/tests.rs) when it stopped keeping a copy. +set -euo pipefail +cd "$(dirname "$0")/.." + +failed=0 +fail() { echo "FAIL: $*" >&2; failed=1; } +ok() { echo "ok: $*"; } +contains() { case "$1" in *"$2"*) return 0 ;; *) return 1 ;; esac; } +# The position of $2 in $1 (its first), -1 when absent. +at() { local rest="${1%%"$2"*}"; if [ "$rest" = "$1" ]; then echo -1; else echo "${#rest}"; fi; } + +tmp="$(mktemp -d)" +trap 'rm -rf "$tmp"' EXIT + +# Stand-in programs in a folder of their own, first on PATH. +stub() { mkdir -p "$1"; printf '%s\n' "$3" > "$1/$2"; chmod 755 "$1/$2"; } + +# --- vm/kali.sh: Kali's archive keyring checked before apt trusts it -------------------------- +kali="$(cat vm/kali.sh)" +for key in 827C8569F2518CC677FECA1AED65462EC8D5E4C5 44C6513A8E4FB3D30875F758ED444FF07D8D0BF6; do + contains "$kali" "$key" || fail "kali.sh: Kali's archive key $key" +done +download=$(at "$kali" "archive.kali.org/archive-keyring.gpg") +checked=$(at "$kali" '[ "$k" = "44C6513A8E4FB3D30875F758ED444FF07D8D0BF6 827C8569F2518CC677FECA1AED65462EC8D5E4C5" ]') +refused=$(at "$kali" "Nothing was installed") +trusted=$(at "$kali" "/usr/share/keyrings/kali-archive-keyring.gpg") +used=$(at "$kali" "signed-by=") +if [ "$download" -ge 0 ] && [ "$download" -lt "$checked" ] && [ "$checked" -lt "$trusted" ] && [ "$refused" -lt "$trusted" ] && [ "$trusted" -lt "$used" ]; then + ok "kali.sh checks the keyring before apt trusts it" +else + fail "kali.sh: downloaded ($download) < checked ($checked) and refused ($refused) < trusted ($trusted) < used ($used)" +fi +if ! contains "$kali" '-o "$d/key"' || contains "$kali" "-o /usr/share/keyrings"; then fail "kali.sh: the keyring is downloaded into the private folder"; fi + +# --- vm/toolset.sh: Kali's toolset only where the box lacks it ------------------------------- +toolset_calls() { # $1: dpkg-query's answer for the toolset + local dir="$tmp/toolset-$RANDOM" + stub "$dir" dpkg-query "#!/bin/sh +printf '%s' '$1'" + stub "$dir" apt-get "#!/bin/sh +echo \"\$*\" >> '$dir/calls'" + { echo "keep=''"; cat vm/toolset.sh; } | PATH="$dir:/usr/bin:/bin" sh + cat "$dir/calls" 2>/dev/null || true +} +if [ -z "$(toolset_calls 'install ok installed')" ]; then ok "a box with the toolset takes nothing from the archive"; else fail "toolset.sh: a box with the toolset called apt-get"; fi +want=$'update\ninstall -y kali-linux-headless' +got="$(toolset_calls '')" +if [ "$got" = "$want" ]; then ok "a box without the toolset is given it"; else fail "toolset.sh: without the toolset: got [$got], want [$want]"; fi + +# --- player-account.sh: the account, its sudo, its password, the shared folder's group ------- +account="$(cat player-account.sh)" +if contains "$account" '{ printf '"'"'%s:'"'"' "$account"; cat "$password_hash"; } | chpasswd -e'; then ok "the password's hash goes to chpasswd on its standard input, never a command line"; else fail "player-account.sh: the hash read from its file into chpasswd -e"; fi +if ! contains "$account" "NOPASSWD: ALL" || ! contains "$account" "--create-home"; then fail "player-account.sh: a home and sudo with no password"; fi +account_calls() { # $1: shared_squashed's value; a shared folder owned by uid/gid 1000 (`vagrant`) + local dir="$tmp/account-$RANDOM" + mkdir -p "$dir/shared" "$dir/sudoers.d" + local record="#!/bin/sh +echo \"\$(basename \"\$0\") \$*\" >> '$dir/calls'" + stub "$dir/bin" stat "#!/bin/sh +echo 1000" + stub "$dir/bin" getent "#!/bin/sh +case \"\$1 \$2\" in + 'passwd 1000') echo 'vagrant:x:1000:1000::/home/vagrant:/bin/sh' ;; + 'group 1000') echo 'vagrant:x:1000:' ;; + *) exit 2 ;; +esac" + stub "$dir/bin" id "#!/bin/sh +exit 1" + for t in useradd usermod groupadd; do stub "$dir/bin" "$t" "$record"; done + # The sudo rule goes to the test's folder, not the computer's. + sed "s|/etc/sudoers.d|$dir/sudoers.d|g" player-account.sh > "$dir/player-account.sh" + PATH="$dir/bin:/usr/bin:/bin" account=player shared="$dir/shared" shared_squashed="$1" sh "$dir/player-account.sh" + [ -f "$dir/sudoers.d/player" ] || fail "player-account.sh: its sudo rule" + cat "$dir/calls" +} +shell=/bin/sh; [ -x /bin/bash ] && shell=/bin/bash +got="$(account_calls '')" +want="useradd --create-home --shell $shell player"$'\n'"usermod -a -G vagrant player" +if [ "$got" = "$want" ]; then ok "the player joins the shared folder's group"; else fail "player-account.sh: not squashed: got [$got], want [$want]"; fi +# Regression: on QEMU under Linux the player couldn't write in the shared folder through a +# supplementary group, which the unprivileged virtiofsd refuses. +got="$(account_calls 1)" +want="useradd --create-home --shell $shell player"$'\n'"usermod -g vagrant player" +if [ "$got" = "$want" ]; then ok "where the folder is squashed, its group is the player's own"; else fail "player-account.sh: squashed: got [$got], want [$want]"; fi + +# --- vm/desktop.sh: XFCE, the player signed in, the screen never locked ---------------------- +desktop="$(cat vm/desktop.sh)" +for want in "install -y \$keep kali-desktop-xfce lightdm" "autologin-user=player" "systemctl set-default graphical.target" \ + "xserver-command=X -s 0 -dpms" "for locker in light-locker xfce4-screensaver" "Hidden=true" "xset s off -dpms" \ + "off xfce4-screensaver /lock/enabled" "off xfce4-power-manager /xfce4-power-manager/lock-screen-suspend-hibernate" \ + "off xfce4-session /shutdown/LockScreen" "/etc/xdg/autostart/cyberctf-no-screen-lock.desktop" "/home/player/.config/autostart"; do + contains "$desktop" "$want" || fail "desktop.sh: $want" +done +if [ "$failed" = 0 ]; then ok "the scripts behave as the launcher relies on"; fi + +exit "$failed" From 8ac69a8e54a456ef305b428ad736bc9ad414603a Mon Sep 17 00:00:00 2001 From: "Florian Amette (F4K)" <50982737+florianamette@users.noreply.github.com> Date: Fri, 20 Nov 2026 00:22:27 +0100 Subject: [PATCH 5/6] tests/scripts.sh: nothing is accepted on the player's behalf The launcher's consent scan read these scripts from its copy; with the copy gone, the same switches are looked for here. Co-Authored-By: Claude Opus 5.5 --- tests/scripts.sh | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/tests/scripts.sh b/tests/scripts.sh index da5e1c1..7a28b7c 100755 --- a/tests/scripts.sh +++ b/tests/scripts.sh @@ -95,6 +95,16 @@ for want in "install -y \$keep kali-desktop-xfce lightdm" "autologin-user=player "off xfce4-session /shutdown/LockScreen" "/etc/xdg/autostart/cyberctf-no-screen-lock.desktop" "/home/player/.config/autostart"; do contains "$desktop" "$want" || fail "desktop.sh: $want" done +# --- nothing accepted on the player's behalf --------------------------------------------------- +# No switch that accepts a licence, an agreement or terms for the player (comments aside): where a +# vendor asks, its own window shows it and the player accepts it there. Moved from the launcher's +# consent scan (src-tauri/src/testing/source_scan/consent.rs). +accepts='--accept-license|--accept-licence|--accept-package-agreements|--accept-source-agreements|--accept-eula|--accept-terms|--agree-tos|-license accept|accepted-license|license select true|accept_eula|accepteula|/eula' +for f in player-account.sh vm/*.sh Dockerfile bashrc.cyberctf; do + found="$(grep -vE '^[[:space:]]*#' "$f" | grep -inE -e "$accepts" || true)" + if [ -n "$found" ]; then fail "$f accepts for the player: $found"; fi +done + if [ "$failed" = 0 ]; then ok "the scripts behave as the launcher relies on"; fi exit "$failed" From 54261e23f2ac1e81dd047a989059c5f23d693201 Mon Sep 17 00:00:00 2001 From: "Florian Amette (F4K)" <50982737+florianamette@users.noreply.github.com> Date: Sat, 21 Nov 2026 12:38:00 +0100 Subject: [PATCH 6/6] vm/toolset.sh: a small fixed set where Kali's toolset isn't there Kali's own box (amd64) ships kali-linux-default: nothing was installed there, and still isn't. A Debian VM made Kali (on Arm, where Kali has no box) got all of kali-linux-headless, ten minutes and more on UTM. It now gets a small set, the same for every lab so it hints at no lab's solution: Kali's core and the common web, network and password tools. The player installs more with sudo apt install. The owner's choice (2026-11-21). Co-Authored-By: Claude Opus 5.5 --- README.md | 4 +++- tests/scripts.sh | 11 ++++++++--- vm/toolset.sh | 11 ++++++++++- 3 files changed, 21 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index 77a2c2e..adc32d6 100644 --- a/README.md +++ b/README.md @@ -16,7 +16,9 @@ The launcher assembles one `sh` script from these parts, in this order: 1. `vm/kali.sh`: on a Debian VM (where Kali has no image for the computer's CPU), Kali's archive in place of Debian's, its keyring checked against Kali's two archive keys before apt trusts it, keeping the VM's own kernel. It defines `$keep`, which the parts after it use. -2. `vm/toolset.sh`: Kali's headless toolset, unless the box has it already. +2. `vm/toolset.sh`: nothing where the box has Kali's toolset (Kali's own box, amd64); elsewhere (a + Debian VM made Kali, on Arm) a small set, the same for every lab: Kali's core and the common web, + network and password tools. The player installs more with `sudo apt install`. 3. The player's account: `player-account.sh`, run by the launcher with the box's shared folder and password file. 4. `vm/desktop.sh`, for a box with a desktop: XFCE, `player` signed in by LightDM, no screen lock. diff --git a/tests/scripts.sh b/tests/scripts.sh index 7a28b7c..d2941f2 100755 --- a/tests/scripts.sh +++ b/tests/scripts.sh @@ -36,7 +36,7 @@ else fi if ! contains "$kali" '-o "$d/key"' || contains "$kali" "-o /usr/share/keyrings"; then fail "kali.sh: the keyring is downloaded into the private folder"; fi -# --- vm/toolset.sh: Kali's toolset only where the box lacks it ------------------------------- +# --- vm/toolset.sh: nothing on Kali's own box, a small fixed set elsewhere ------------------- toolset_calls() { # $1: dpkg-query's answer for the toolset local dir="$tmp/toolset-$RANDOM" stub "$dir" dpkg-query "#!/bin/sh @@ -47,9 +47,14 @@ echo \"\$*\" >> '$dir/calls'" cat "$dir/calls" 2>/dev/null || true } if [ -z "$(toolset_calls 'install ok installed')" ]; then ok "a box with the toolset takes nothing from the archive"; else fail "toolset.sh: a box with the toolset called apt-get"; fi -want=$'update\ninstall -y kali-linux-headless' got="$(toolset_calls '')" -if [ "$got" = "$want" ]; then ok "a box without the toolset is given it"; else fail "toolset.sh: without the toolset: got [$got], want [$want]"; fi +first="$(printf '%s\n' "$got" | head -1)" +install="$(printf '%s\n' "$got" | sed -n 2p)" +if [ "$first" = update ] && contains "$install" 'install -y kali-linux-core nmap' && contains "$install" ' sqlmap ' && ! contains "$install" kali-linux-headless; then + ok "a box without Kali's toolset (Debian made Kali, on Arm) is given the small set, not all of it" +else + fail "toolset.sh: without the toolset: got [$got]" +fi # --- player-account.sh: the account, its sudo, its password, the shared folder's group ------- account="$(cat player-account.sh)" diff --git a/vm/toolset.sh b/vm/toolset.sh index 100bedf..ac19482 100644 --- a/vm/toolset.sh +++ b/vm/toolset.sh @@ -1,4 +1,13 @@ +# Kali's tools. Kali's own box (amd64) ships its whole toolset (kali-linux-default): nothing is +# installed there. Elsewhere, a Debian VM made Kali by kali.sh (on Arm, where Kali has no box), +# gets a small set that serves every lab, the same for each so it hints at no lab's solution: +# Kali's core and the common web, network and password tools. The player installs more with +# `sudo apt install`. +tools='kali-linux-core nmap curl wget netcat-traditional socat dnsutils whois tcpdump jq git vim + sqlmap gobuster ffuf dirb nikto whatweb hydra john wordlists smbclient impacket-scripts + python3-requests' if ! dpkg-query -W -f='${Status}' kali-linux-headless 2>/dev/null | grep -q 'ok installed'; then apt-get update - apt-get install -y $keep kali-linux-headless + # shellcheck disable=SC2086 # $keep and $tools are lists of words + apt-get install -y $keep $tools fi