بسم الله الرحمن الرحيم
الحمد لله رب العالمين والصلاة والسلام على أشرف المرسلين سيدنا محمد وعلى آله وصحبه ومن تبعهم بإحسان إلى يوم الدين.


اليوم راح نتكلم عن هجوم Fastbin Dup

حسابي في التويتر هنا 

المتطلبات

  1. فهم أساسيات لغة C و Assembly

  2. فهم Memory Management

  3. معرفة أبسط الاشياء في الHeap ولديك معرفة في Stack Overflow


البداية

ماهو الGlibc ؟

يرمز Glibc الى GNU C Library هي المكتبات الأساسية لنظام GNU system و GNU/Linux systems وداخلها العديد من الfunctions مثل printf و write و read و open و العديد من الالfunctions و أيضاً GLIBC هي open source يمكنك الاطلاع على source code او الكود المصدري الخاص بها من هنا وتم تطويرها من قبل 30 سنة.

ماهو الHeap ؟

هي مكان في الذاكرة أو الMemory مخصصة لكل برنامج على عكس الStack الHeap ديناميكي هذا يعني يمكن “‘طلب“ و “تحرير“ الذاكرة متى مأ اراد المستخدم ذلك ويتعامل مع الPointers ومع Memory Allocators ويمكن أن يكون هناك أكثر من heap في نفس الوقت.

Memory Allocators

dlmalloc – General purpose allocator ptmalloc2 – glibc jemalloc – FreeBSD and Firefox tcmalloc – Google libumem - Solaris

ماهي malloc function ؟

هي GLIBC memory allocator وتستخدم لطلب قطع (Chunks) في الHeap.

malloc description

/* malloc(size_t n) Returns a pointer to a newly allocated chunk of at least n bytes, or null if no space is available. Additionally, on failure, errno is set to ENOMEM on ANSI C systems. If n is zero, malloc returns a minumum-sized chunk. (The minimum size is 16 bytes on most 32bit systems, and 24 or 32 bytes on 64bit systems.) On most systems, size_t is an unsigned type, so calls with negative arguments are interpreted as requests for huge amounts of space, which will often fail. The maximum supported value of n differs across systems, but is in all cases less than the maximum representable value of a size_t. */

التعامل معها بسيط فقط تستدعيها وتعطيها حجم القطعة التي تود حجزها في الHeap هكذا malloc(0x90)

ماهي Free function ؟

Join