#!/usr/bin/env bash
# Archived for authorized security research only.
# Source: https://github.com/abraxas/cve-2026-134401-chrome-variations-http-seed (see README for attribution/license)
# CVE-2026-134401 differential lab. Downloads the pinned Chrome for Testing
# builds (vulnerable 158.0.8127.36, patched 158.0.8127.88), then runs poc.py.
set -euo pipefail
cd "$(dirname "$0")"

command -v curl >/dev/null || { echo "FAIL curl-missing"; exit 1; }
command -v unzip >/dev/null || { echo "FAIL unzip-missing"; exit 1; }

CACHE=cft-cache
BASE=https://storage.googleapis.com/chrome-for-testing-public

fetch() { # version
  local app="$CACHE/chrome-$1/chrome-mac-arm64/Google Chrome for Testing.app/Contents/MacOS/Google Chrome for Testing"
  if [ ! -x "$app" ]; then
    mkdir -p "$CACHE"
    if [ ! -f "$CACHE/chrome-$1.zip" ]; then
      echo "[*] downloading Chrome for Testing $1"
      curl -fL -o "$CACHE/chrome-$1.zip" "$BASE/$1/mac-arm64/chrome-mac-arm64.zip"
    fi
    rm -rf "$CACHE/chrome-$1"
    mkdir -p "$CACHE/chrome-$1"
    unzip -q "$CACHE/chrome-$1.zip" -d "$CACHE/chrome-$1"
  fi
}

fetch 158.0.8127.36
fetch 158.0.8127.88

python3 poc.py 2>&1 | tee poc-last-run.txt
