#!/usr/bin/env bash # Boot the Tier-3 *target* VM (the intentionally-vulnerable guest the # exploit fires against). Companion to ``launch_demo.sh``, which boots # the *idle* Alpine guest used in Tiers 1-2. # # Networking note: this launcher uses SLIRP usermode networking with # ``restrict=on`` plus an explicit ``hostfwd`` for each vulnerable port. # That gives us: # - the host can reach the guest's services (for msfrpcd + the # exploit module to drive ``RHOSTS=127.0.0.1``) # - the guest cannot reach the host or the internet (no NAT exit) # # The host-only ``br-malware`` bridge described in docs/architecture.md # replaces SLIRP once the bridge-side pcap collector (source 4) lands — # at which point payloads with ``reverse_tcp`` callbacks become viable # too. Until then, we restrict module choices to ones that return a # shell on the same socket they exploit (e.g. vsftpd_234_backdoor). # # Run-dir contract (read by run_tier3_demo.py): # $RUN_DIR/qemu.pid # $RUN_DIR/qmp.sock # $RUN_DIR/monitor.sock # $RUN_DIR/serial.sock set -euo pipefail REPO_ROOT="$(cd "$(dirname "$0")/.." && pwd)" IMAGE="${IMAGE:-$REPO_ROOT/vm/images/metasploitable2.qcow2}" SLOT="${SLOT:-0}" RUN_DIR="${RUN_DIR:-/tmp/cis490-target-$SLOT}" RAM_MIB="${RAM_MIB:-512}" # When BRIDGE is set, attach a tap to the host-only bridge instead of # using SLIRP. Pcap-feature episodes (source 4) require this. BRIDGE="${BRIDGE:-}" TAP="${TAP:-cis490target$SLOT}" # Ports the host should forward to the guest. Comma-separated host:guest pairs. # Default covers the vsftpd module's RPORT. Host port uses an unprivileged # range (>1023) so the service user (cis490) can bind it without root. # Slot offset makes per-VM fleet runs collision-free # (slot 0 → 2021, slot 1 → 2121, slot 2 → 2221, ...). PORT_BASE="${PORT_BASE:-$((2021 + SLOT * 100))}" TARGET_PORTS="${TARGET_PORTS:-${PORT_BASE}:21}" # KVM if the host can take it; otherwise fall back to TCG. Cross-arch # images (Metasploitable2 is x86-only) on aarch64 hosts will need TCG. ACCEL="${ACCEL:-}" mkdir -p "$RUN_DIR" QMP_SOCK="$RUN_DIR/qmp.sock" MON_SOCK="$RUN_DIR/monitor.sock" PID_FILE="$RUN_DIR/qemu.pid" SERIAL_SOCK="$RUN_DIR/serial.sock" if [[ ! -f "$IMAGE" ]]; then cat >&2 <