#!/usr/bin/env bash
# Run binwalk v3 against an artifact. Extraction (-e) output lands in ./output/.
#
# Usage:
#   ./re-binwalk <file-in-artifacts> [binwalk options...]
#   ./re-binwalk dump.bin -e        # scan + carve/extract embedded payloads
set -euo pipefail
cd "$(dirname "$0")"
if [ "$#" -lt 1 ]; then
    echo "usage: $0 <file-in-artifacts> [binwalk options...]" >&2
    exit 2
fi
ART="$1"; shift
exec docker compose run --rm -T --entrypoint /bin/bash \
    tools -lc 'cd /data/output && exec binwalk "$@"' _ "$@" "/data/artifacts/${ART}"
