Libc Heap

Tip

AWS ํ•ดํ‚น ๋ฐฐ์šฐ๊ธฐ ๋ฐ ์—ฐ์Šตํ•˜๊ธฐ:HackTricks Training AWS Red Team Expert (ARTE)
GCP ํ•ดํ‚น ๋ฐฐ์šฐ๊ธฐ ๋ฐ ์—ฐ์Šตํ•˜๊ธฐ: HackTricks Training GCP Red Team Expert (GRTE) Azure ํ•ดํ‚น ๋ฐฐ์šฐ๊ธฐ ๋ฐ ์—ฐ์Šตํ•˜๊ธฐ: HackTricks Training Azure Red Team Expert (AzRTE)

HackTricks ์ง€์›ํ•˜๊ธฐ

Heap Basics

Heap์€ ํ”„๋กœ๊ทธ๋žจ์ด malloc, calloc ๋“ฑ๊ณผ ๊ฐ™์€ ํ•จ์ˆ˜๋ฅผ ํ˜ธ์ถœํ•ด ๋ฐ์ดํ„ฐ๋ฅผ ์š”์ฒญํ•  ๋•Œ ๋ฐ์ดํ„ฐ๋ฅผ ์ €์žฅํ•˜๋Š” ๊ณต๊ฐ„์ด๋‹ค. ๋˜ํ•œ ์ด ๋ฉ”๋ชจ๋ฆฌ๊ฐ€ ๋” ์ด์ƒ ํ•„์š”ํ•˜์ง€ ์•Š์œผ๋ฉด free ํ•จ์ˆ˜๋ฅผ ํ˜ธ์ถœํ•ด ๋ฐ˜ํ™˜๋œ๋‹ค.

As itโ€™s shown, its just after where the binary is being loaded in memory (check the [heap] section):

Basic Chunk Allocation

๋ฐ์ดํ„ฐ๋ฅผ heap์— ์ €์žฅํ•˜๋„๋ก ์š”์ฒญํ•˜๋ฉด heap์˜ ์ผ๋ถ€ ๊ณต๊ฐ„์ด ํ• ๋‹น๋œ๋‹ค. ์ด ๊ณต๊ฐ„์€ bin์— ์†ํ•˜๋ฉฐ ์š”์ฒญํ•œ ๋ฐ์ดํ„ฐ + bin headers์˜ ๊ณต๊ฐ„ + ์ตœ์†Œ bin ํฌ๊ธฐ ์˜คํ”„์…‹๋งŒ chunk๋กœ ์˜ˆ์•ฝ๋œ๋‹ค. ๋ชฉํ‘œ๋Š” ๊ฐ chunk์˜ ์œ„์น˜๋ฅผ ์ฐพ๊ธฐ ๋ณต์žกํ•˜๊ฒŒ ๋งŒ๋“ค์ง€ ์•Š์œผ๋ฉด์„œ ๊ฐ€๋Šฅํ•œ ์ตœ์†Œ ๋ฉ”๋ชจ๋ฆฌ๋งŒ ์˜ˆ์•ฝํ•˜๋Š” ๊ฒƒ์ด๋‹ค. ์ด๋ฅผ ์œ„ํ•ด metadata chunk ์ •๋ณด๊ฐ€ ์‚ฌ์šฉ๋˜์–ด ๊ฐ ์‚ฌ์šฉ/ํ•ด์ œ๋œ chunk์˜ ์œ„์น˜๋ฅผ ํŒŒ์•…ํ•œ๋‹ค.

๊ณต๊ฐ„์„ ์˜ˆ์•ฝํ•˜๋Š” ๋ฐฉ๋ฒ•์€ ์‚ฌ์šฉ๋˜๋Š” bin์— ๋”ฐ๋ผ ๋‹ค๋ฅด์ง€๋งŒ, ์ผ๋ฐ˜์ ์ธ ์ ˆ์ฐจ๋Š” ๋‹ค์Œ๊ณผ ๊ฐ™๋‹ค:

  • ํ”„๋กœ๊ทธ๋žจ์ด ์ผ์ •๋Ÿ‰์˜ ๋ฉ”๋ชจ๋ฆฌ๋ฅผ ์š”์ฒญํ•œ๋‹ค.
  • chunk ๋ชฉ๋ก์—์„œ ์š”์ฒญ์„ ์ถฉ์กฑํ•  ์ˆ˜ ์žˆ๋Š” ์ถฉ๋ถ„ํžˆ ํฐ ๊ฐ€์šฉ chunk๊ฐ€ ์žˆ์œผ๋ฉด ๊ทธ๊ฒƒ์„ ์‚ฌ์šฉํ•œ๋‹ค.
  • ์ด๋Š” ๊ฐ€์šฉ chunk์˜ ์ผ๋ถ€๋งŒ ์ด ์š”์ฒญ์— ์‚ฌ์šฉ๋˜๊ณ  ๋‚จ์€ ๋ถ€๋ถ„์€ chunk ๋ชฉ๋ก์— ๋‹ค์‹œ ์ถ”๊ฐ€๋  ์ˆ˜ ์žˆ์Œ์„ ์˜๋ฏธํ•œ๋‹ค.
  • ๋ชฉ๋ก์— ์‚ฌ์šฉ ๊ฐ€๋Šฅํ•œ chunk๊ฐ€ ์—†์ง€๋งŒ ์•„์ง ํ• ๋‹น๋œ heap ๋ฉ”๋ชจ๋ฆฌ์— ๊ณต๊ฐ„์ด ๋‚จ์•„์žˆ๋‹ค๋ฉด, heap ๊ด€๋ฆฌ์ž๋Š” ์ƒˆ chunk๋ฅผ ์ƒ์„ฑํ•œ๋‹ค.
  • ์ƒˆ chunk๋ฅผ ํ• ๋‹นํ• ๋งŒํ•œ heap ๊ณต๊ฐ„์ด ๋ถ€์กฑํ•˜๋ฉด, heap ๊ด€๋ฆฌ์ž๋Š” ์ปค๋„์— heap์— ํ• ๋‹น๋œ ๋ฉ”๋ชจ๋ฆฌ๋ฅผ ํ™•์žฅํ•˜๋„๋ก ์š”์ฒญํ•œ ๋’ค ์ด ๋ฉ”๋ชจ๋ฆฌ๋ฅผ ์‚ฌ์šฉํ•ด ์ƒˆ chunk๋ฅผ ๋งŒ๋“ ๋‹ค.
  • ๋ชจ๋“  ๊ฒƒ์ด ์‹คํŒจํ•˜๋ฉด malloc์€ null์„ ๋ฐ˜ํ™˜ํ•œ๋‹ค.

์š”์ฒญํ•œ ๋ฉ”๋ชจ๋ฆฌ๊ฐ€ ์ž„๊ณ„๊ฐ’์„ ๋„˜์œผ๋ฉด, **mmap**์ด ์‚ฌ์šฉ๋˜์–ด ์š”์ฒญํ•œ ๋ฉ”๋ชจ๋ฆฌ๋ฅผ ๋งคํ•‘ํ•œ๋‹ค.

Arenas

๋ฉ€ํ‹ฐ์Šค๋ ˆ๋“œ ์• ํ”Œ๋ฆฌ์ผ€์ด์…˜์—์„œ heap ๊ด€๋ฆฌ์ž๋Š” ์ถฉ๋Œ๋กœ ์ธํ•œ ํฌ๋ž˜์‹œ๋ฅผ ๋ง‰๊ธฐ ์œ„ํ•ด race conditions๋ฅผ ๋ฐฉ์ง€ํ•ด์•ผ ํ•œ๋‹ค. ์ดˆ๊ธฐ์—๋Š” ์ „์—ญ mutex๋ฅผ ์‚ฌ์šฉํ•ด ํ•œ ๋ฒˆ์— ํ•˜๋‚˜์˜ ์Šค๋ ˆ๋“œ๋งŒ heap์— ์ ‘๊ทผํ•˜๋„๋ก ํ–ˆ์ง€๋งŒ, ์ด๋Š” mutex๋กœ ์ธํ•œ ๋ณ‘๋ชฉ ํ˜„์ƒ ๋•Œ๋ฌธ์— ์„ฑ๋Šฅ ๋ฌธ์ œ๋ฅผ ์ผ์œผ์ผฐ๋‹ค.

์ด๋ฅผ ํ•ด๊ฒฐํ•˜๊ธฐ ์œ„ํ•ด ptmalloc2 heap allocator๋Š” โ€œarenasโ€œ๋ฅผ ๋„์ž…ํ–ˆ๋‹ค. ๊ฐ arena๋Š” ์ž์ฒด ๋ฐ์ดํ„ฐ ๊ตฌ์กฐ์™€ mutex๋ฅผ ๊ฐ€์ง„ ๋ณ„๋„์˜ heap์ฒ˜๋Ÿผ ๋™์ž‘ํ•˜์—ฌ, ์„œ๋กœ ๋‹ค๋ฅธ arena๋ฅผ ์‚ฌ์šฉํ•˜๋Š” ํ•œ ์—ฌ๋Ÿฌ ์Šค๋ ˆ๋“œ๊ฐ€ ์„œ๋กœ ๊ฐ„์„ญํ•˜์ง€ ์•Š๊ณ  heap ์ž‘์—…์„ ์ˆ˜ํ–‰ํ•  ์ˆ˜ ์žˆ๋‹ค.

๊ธฐ๋ณธ โ€œmainโ€ arena๋Š” ๋‹จ์ผ ์Šค๋ ˆ๋“œ ์• ํ”Œ๋ฆฌ์ผ€์ด์…˜์˜ heap ์ž‘์—…์„ ์ฒ˜๋ฆฌํ•œ๋‹ค. ์ƒˆ๋กœ์šด ์Šค๋ ˆ๋“œ๊ฐ€ ์ถ”๊ฐ€๋˜๋ฉด heap ๊ด€๋ฆฌ์ž๋Š” ๊ฒฝ์Ÿ์„ ์ค„์ด๊ธฐ ์œ„ํ•ด ์ด๋“ค์—๊ฒŒ secondary arenas๋ฅผ ํ• ๋‹นํ•œ๋‹ค. ๊ด€๋ฆฌ์ž๋Š” ๋จผ์ € ์‚ฌ์šฉ๋˜์ง€ ์•Š๋Š” arena์— ์ƒˆ๋กœ์šด ์Šค๋ ˆ๋“œ๋ฅผ ๋ถ™์ด๋ ค ์‹œ๋„ํ•˜๊ณ , ํ•„์š”ํ•˜๋ฉด ์ƒˆ arena๋ฅผ ์ƒ์„ฑํ•˜๋ฉฐ, 32๋น„ํŠธ ์‹œ์Šคํ…œ์—์„œ๋Š” CPU ์ฝ”์–ด ์ˆ˜์˜ 2๋ฐฐ, 64๋น„ํŠธ ์‹œ์Šคํ…œ์—์„œ๋Š” 8๋ฐฐ๊นŒ์ง€ ์ƒ์„ฑํ•œ๋‹ค. ํ•œ๋„์— ๋„๋‹ฌํ•˜๋ฉด ์Šค๋ ˆ๋“œ๋“ค์ด arena๋ฅผ ๊ณต์œ ํ•ด์•ผ ํ•˜๋ฏ€๋กœ ๊ฒฝ์Ÿ์ด ๋ฐœ์ƒํ•  ์ˆ˜ ์žˆ๋‹ค.

main arena๋Š” brk ์‹œ์Šคํ…œ ์ฝœ์„ ์‚ฌ์šฉํ•ด ํ™•์žฅ๋˜๋Š” ๋ฐ˜๋ฉด, secondary arenas๋Š” mmap๊ณผ mprotect๋ฅผ ์‚ฌ์šฉํ•ด subheaps๋ฅผ ์ƒ์„ฑํ•˜์—ฌ heap ๋™์ž‘์„ ์‹œ๋ฎฌ๋ ˆ์ด์…˜ํ•˜๋ฏ€๋กœ ๋ฉ€ํ‹ฐ์Šค๋ ˆ๋“œ ์ž‘์—…์— ๋Œ€ํ•œ ๋ฉ”๋ชจ๋ฆฌ ๊ด€๋ฆฌ์— ์œ ์—ฐ์„ฑ์„ ์ œ๊ณตํ•œ๋‹ค.

Subheaps

Subheaps๋Š” ๋ฉ€ํ‹ฐ์Šค๋ ˆ๋“œ ์• ํ”Œ๋ฆฌ์ผ€์ด์…˜์—์„œ secondary arenas๊ฐ€ ๋ณ„๋„๋กœ ์„ฑ์žฅํ•˜๊ณ  ์ž์‹ ๋งŒ์˜ heap ์˜์—ญ์„ ๊ด€๋ฆฌํ•  ์ˆ˜ ์žˆ๋„๋ก ํ•˜๋Š” ๋ฉ”๋ชจ๋ฆฌ ์˜ˆ์•ฝ ๊ณต๊ฐ„์ด๋‹ค. Subheaps๊ฐ€ ์ดˆ๊ธฐ heap๊ณผ ์–ด๋–ป๊ฒŒ ๋‹ค๋ฅธ์ง€ ๋ฐ ์–ด๋–ป๊ฒŒ ๋™์ž‘ํ•˜๋Š”์ง€๋Š” ๋‹ค์Œ๊ณผ ๊ฐ™๋‹ค:

  1. Initial Heap vs. Subheaps:
  • ์ดˆ๊ธฐ heap์€ ๋ฐ”์ด๋„ˆ๋ฆฌ ๋ฐ”๋กœ ๋’ค์— ์œ„์น˜ํ•˜๋ฉฐ sbrk ์‹œ์Šคํ…œ ์ฝœ์„ ์‚ฌ์šฉํ•ด ํ™•์žฅ๋œ๋‹ค.
  • secondary arenas์—์„œ ์‚ฌ์šฉํ•˜๋Š” subheaps๋Š” ์ง€์ •๋œ ๋ฉ”๋ชจ๋ฆฌ ์˜์—ญ์„ ๋งคํ•‘ํ•˜๋Š” ์‹œ์Šคํ…œ ์ฝœ์ธ mmap์„ ํ†ตํ•ด ์ƒ์„ฑ๋œ๋‹ค.
  1. Memory Reservation with mmap:
  • heap ๊ด€๋ฆฌ์ž๊ฐ€ subheap์„ ์ƒ์„ฑํ•  ๋•Œ, mmap์„ ํ†ตํ•ด ํฐ ๋ธ”๋ก์˜ ๋ฉ”๋ชจ๋ฆฌ๋ฅผ ์˜ˆ์•ฝํ•œ๋‹ค. ์ด ์˜ˆ์•ฝ์€ ์ฆ‰์‹œ ๋ฌผ๋ฆฌ ๋ฉ”๋ชจ๋ฆฌ๋ฅผ ํ• ๋‹นํ•˜์ง€ ์•Š์œผ๋ฉฐ, ๋‹จ์ง€ ๋‹ค๋ฅธ ์‹œ์Šคํ…œ ํ”„๋กœ์„ธ์Šค๋‚˜ ํ• ๋‹น์ด ํ•ด๋‹น ์˜์—ญ์„ ์‚ฌ์šฉํ•˜์ง€ ๋ชปํ•˜๋„๋ก ์˜์—ญ์„ ์ง€์ •ํ•˜๋Š” ๊ฒƒ์ด๋‹ค.
  • ๊ธฐ๋ณธ์ ์œผ๋กœ subheap์˜ ์˜ˆ์•ฝ ํฌ๊ธฐ๋Š” 32๋น„ํŠธ ํ”„๋กœ์„ธ์Šค์—์„œ 1 MB, 64๋น„ํŠธ ํ”„๋กœ์„ธ์Šค์—์„œ 64 MB์ด๋‹ค.
  1. Gradual Expansion with mprotect:
  • ์˜ˆ์•ฝ๋œ ๋ฉ”๋ชจ๋ฆฌ ์˜์—ญ์€ ์ฒ˜์Œ์— PROT_NONE๋กœ ํ‘œ์‹œ๋˜์–ด ์ปค๋„์ด ์•„์ง ๋ฌผ๋ฆฌ ๋ฉ”๋ชจ๋ฆฌ๋ฅผ ํ• ๋‹นํ•  ํ•„์š”๊ฐ€ ์—†์Œ์„ ๋‚˜ํƒ€๋‚ธ๋‹ค.
  • subheap์„ โ€œ์„ฑ์žฅโ€œ์‹œํ‚ค๊ธฐ ์œ„ํ•ด heap ๊ด€๋ฆฌ์ž๋Š” mprotect๋ฅผ ์‚ฌ์šฉํ•˜์—ฌ ํŽ˜์ด์ง€ ๊ถŒํ•œ์„ PROT_NONE์—์„œ PROT_READ | PROT_WRITE๋กœ ๋ณ€๊ฒฝํ•˜๊ณ , ์ด๋กœ ์ธํ•ด ์ปค๋„์€ ์ด์ „์— ์˜ˆ์•ฝ๋œ ์ฃผ์†Œ์— ๋ฌผ๋ฆฌ ๋ฉ”๋ชจ๋ฆฌ๋ฅผ ํ• ๋‹นํ•œ๋‹ค. ์ด ๋‹จ๊ณ„๋ณ„ ์ ‘๊ทผ ๋ฐฉ์‹์€ subheap์ด ํ•„์š”์— ๋”ฐ๋ผ ํ™•์žฅ๋˜๋„๋ก ํ—ˆ์šฉํ•œ๋‹ค.
  • ์ „์ฒด subheap์ด ์†Œ์ง„๋˜๋ฉด heap ๊ด€๋ฆฌ์ž๋Š” ์ƒˆ๋กœ์šด subheap์„ ์ƒ์„ฑํ•˜์—ฌ ํ• ๋‹น์„ ๊ณ„์†ํ•œ๋‹ค.

heap_info

์ด struct๋Š” heap์— ๋Œ€ํ•œ ๊ด€๋ จ ์ •๋ณด๋ฅผ ํ• ๋‹นํ•œ๋‹ค. ๋˜ํ•œ ์ถ”๊ฐ€ ํ• ๋‹น ์ดํ›„์—๋Š” heap ๋ฉ”๋ชจ๋ฆฌ๊ฐ€ ์—ฐ์†์ ์ด์ง€ ์•Š์„ ์ˆ˜ ์žˆ์œผ๋ฏ€๋กœ, ์ด struct๋Š” ๊ทธ ์ •๋ณด๋ฅผ ์ €์žฅํ•˜๊ธฐ๋„ ํ•œ๋‹ค.

// From https://github.com/bminor/glibc/blob/a07e000e82cb71238259e674529c37c12dc7d423/malloc/arena.c#L837

typedef struct _heap_info
{
mstate ar_ptr; /* Arena for this heap. */
struct _heap_info *prev; /* Previous heap. */
size_t size;   /* Current size in bytes. */
size_t mprotect_size; /* Size in bytes that has been mprotected
PROT_READ|PROT_WRITE.  */
size_t pagesize; /* Page size used when allocating the arena.  */
/* Make sure the following data is properly aligned, particularly
that sizeof (heap_info) + 2 * SIZE_SZ is a multiple of
MALLOC_ALIGNMENT. */
char pad[-3 * SIZE_SZ & MALLOC_ALIGN_MASK];
} heap_info;

malloc_state

๊ฐ heap (main arena ๋˜๋Š” ๋‹ค๋ฅธ ์Šค๋ ˆ๋“œ์˜ arenas)์—๋Š” malloc_state ๊ตฌ์กฐ์ฒด๊ฐ€ ์žˆ์Šต๋‹ˆ๋‹ค.
ํŠนํžˆ main arena malloc_state ๊ตฌ์กฐ์ฒด๋Š” libc ์•ˆ์˜ ์ „์—ญ ๋ณ€์ˆ˜(๋”ฐ๋ผ์„œ libc ๋ฉ”๋ชจ๋ฆฌ ๊ณต๊ฐ„์— ์œ„์น˜)๋ผ๋Š” ์ ์ด ์ค‘์š”ํ•ฉ๋‹ˆ๋‹ค.
์Šค๋ ˆ๋“œ๋“ค์˜ heap์— ์žˆ๋Š” malloc_state ๊ตฌ์กฐ์ฒด๋“ค์€ ๊ฐ ์Šค๋ ˆ๋“œ์˜ โ€œheapโ€ ๋‚ด๋ถ€์— ์œ„์น˜ํ•ฉ๋‹ˆ๋‹ค.

๋‹ค์Œ์€ ์ด ๊ตฌ์กฐ์ฒด์—์„œ ์ฃผ๋ชฉํ•  ๋งŒํ•œ ๋ช‡ ๊ฐ€์ง€ ์‚ฌํ•ญ์ž…๋‹ˆ๋‹ค(์•„๋ž˜ C ์ฝ”๋“œ ์ฐธ๊ณ ):

  • __libc_lock_define (, mutex);๋Š” heap์˜ ์ด ๊ตฌ์กฐ์ฒด์— ํ•œ ๋ฒˆ์— ํ•œ ์Šค๋ ˆ๋“œ๋งŒ ์ ‘๊ทผํ•˜๋„๋ก ๋ณด์žฅํ•˜๊ธฐ ์œ„ํ•ด ์กด์žฌํ•ฉ๋‹ˆ๋‹ค.

  • Flags:

#define NONCONTIGUOUS_BIT (2U)

#define contiguous(M) (((M)->flags & NONCONTIGUOUS_BIT) == 0) #define noncontiguous(M) (((M)->flags & NONCONTIGUOUS_BIT) != 0) #define set_noncontiguous(M) ((M)->flags |= NONCONTIGUOUS_BIT) #define set_contiguous(M) ((M)->flags &= ~NONCONTIGUOUS_BIT)


- `mchunkptr bins[NBINS * 2 - 2];`๋Š” small, large ๋ฐ unsorted bins์˜ first์™€ last chunks์— ๋Œ€ํ•œ pointers๋ฅผ ํฌํ•จํ•ฉ๋‹ˆ๋‹ค( -2๋Š” index 0์ด ์‚ฌ์šฉ๋˜์ง€ ์•Š๊ธฐ ๋•Œ๋ฌธ์ž…๋‹ˆ๋‹ค).
- ๋”ฐ๋ผ์„œ ์ด bins๋“ค์˜ **first chunk**๋Š” ์ด ๊ตฌ์กฐ์ฒด๋กœ ํ–ฅํ•˜๋Š” **backwards pointer**๋ฅผ ๊ฐ€์ง€๋ฉฐ, **last chunk**๋Š” ์ด ๊ตฌ์กฐ์ฒด๋กœ ํ–ฅํ•˜๋Š” **forward pointer**๋ฅผ ๊ฐ€์ง‘๋‹ˆ๋‹ค. ์ฆ‰, main arena์—์„œ ์ด๋Ÿฌํ•œ ์ฃผ์†Œ๋ฅผ leakํ•  ์ˆ˜ ์žˆ๋‹ค๋ฉด libc ์•ˆ์˜ ๊ตฌ์กฐ์ฒด๋ฅผ ๊ฐ€๋ฆฌํ‚ค๋Š” ํฌ์ธํ„ฐ๋ฅผ ์–ป๊ฒŒ ๋ฉ๋‹ˆ๋‹ค.
- `struct malloc_state *next;` ๋ฐ `struct malloc_state *next_free;` ๊ตฌ์กฐ์ฒด๋“ค์€ arenas์˜ linked list์ž…๋‹ˆ๋‹ค.
- `top` chunk์€ ๋งˆ์ง€๋ง‰ "chunk"๋กœ, ๊ธฐ๋ณธ์ ์œผ๋กœ ๋‚จ์•„์žˆ๋Š” ๋ชจ๋“  heap ๊ณต๊ฐ„์ž…๋‹ˆ๋‹ค. `top` chunk๊ฐ€ "๋น„์›Œ์ง€๋ฉด", heap์ด ์™„์ „ํžˆ ์‚ฌ์šฉ๋œ ๊ฒƒ์ด๋ฉฐ ๋” ๋งŽ์€ ๊ณต๊ฐ„์„ ์š”์ฒญํ•ด์•ผ ํ•ฉ๋‹ˆ๋‹ค.
- `last reminder` chunk๋Š” ์ •ํ™•ํ•œ ํฌ๊ธฐ์˜ chunk๊ฐ€ ์—†์„ ๋•Œ ๋” ํฐ chunk๋ฅผ ๋ถ„ํ• ํ•˜์—ฌ ๋‚จ๋Š” ๋ถ€๋ถ„์˜ ํฌ์ธํ„ฐ๊ฐ€ ์—ฌ๊ธฐ์— ๋†“์ด๋Š” ๊ฒฝ์šฐ์—์„œ ์˜ต๋‹ˆ๋‹ค.
```c
// From https://github.com/bminor/glibc/blob/a07e000e82cb71238259e674529c37c12dc7d423/malloc/malloc.c#L1812

struct malloc_state
{
/* Serialize access.  */
__libc_lock_define (, mutex);

/* Flags (formerly in max_fast).  */
int flags;

/* Set if the fastbin chunks contain recently inserted free blocks.  */
/* Note this is a bool but not all targets support atomics on booleans.  */
int have_fastchunks;

/* Fastbins */
mfastbinptr fastbinsY[NFASTBINS];

/* Base of the topmost chunk -- not otherwise kept in a bin */
mchunkptr top;

/* The remainder from the most recent split of a small request */
mchunkptr last_remainder;

/* Normal bins packed as described above */
mchunkptr bins[NBINS * 2 - 2];

/* Bitmap of bins */
unsigned int binmap[BINMAPSIZE];

/* Linked list */
struct malloc_state *next;

/* Linked list for free arenas.  Access to this field is serialized
by free_list_lock in arena.c.  */
struct malloc_state *next_free;

/* Number of threads attached to this arena.  0 if the arena is on
the free list.  Access to this field is serialized by
free_list_lock in arena.c.  */
INTERNAL_SIZE_T attached_threads;

/* Memory allocated from the system in this arena.  */
INTERNAL_SIZE_T system_mem;
INTERNAL_SIZE_T max_system_mem;
};

malloc_chunk

์ด ๊ตฌ์กฐ์ฒด๋Š” ํŠน์ • ๋ฉ”๋ชจ๋ฆฌ chunk๋ฅผ ๋‚˜ํƒ€๋ƒ…๋‹ˆ๋‹ค. ๊ฐ ํ•„๋“œ๋Š” allocated ๋ฐ unallocated chunk์— ๋Œ€ํ•ด ์„œ๋กœ ๋‹ค๋ฅธ ์˜๋ฏธ๋ฅผ ๊ฐ€์ง‘๋‹ˆ๋‹ค.

// https://github.com/bminor/glibc/blob/master/malloc/malloc.c
struct malloc_chunk {
INTERNAL_SIZE_T      mchunk_prev_size;  /* Size of previous chunk, if it is free. */
INTERNAL_SIZE_T      mchunk_size;       /* Size in bytes, including overhead. */
struct malloc_chunk* fd;                /* double links -- used only if this chunk is free. */
struct malloc_chunk* bk;
/* Only used for large blocks: pointer to next larger size.  */
struct malloc_chunk* fd_nextsize; /* double links -- used only if this chunk is free. */
struct malloc_chunk* bk_nextsize;
};

typedef struct malloc_chunk* mchunkptr;

As commented previously, these chunks also have some metadata, very good represented in this image:

https://azeria-labs.com/wp-content/uploads/2019/03/chunk-allocated-CS.png

The metadata is usually 0x08B indicating the current chunk size using the last 3 bits to indicate:

  • A: If 1 it comes from a subheap, if 0 itโ€™s in the main arena
  • M: If 1, this chunk is part of a space allocated with mmap and not part of a heap
  • P: If 1, the previous chunk is in use

Then, the space for the user data, and finally 0x08B to indicate the previous chunk size when the chunk is available (or to store user data when itโ€™s allocated).

Moreover, when available, the user data is used to contain also some data:

  • fd: Pointer to the next chunk
  • bk: Pointer to the previous chunk
  • fd_nextsize: Pointer to the first chunk in the list is smaller than itself
  • bk_nextsize: Pointer to the first chunk the list that is larger than itself

https://azeria-labs.com/wp-content/uploads/2019/03/chunk-allocated-CS.png

Tip

Note how liking the list this way prevents the need to having an array where every single chunk is being registered.

Chunk Pointers

When malloc is used a pointer to the content that can be written is returned (just after the headers), however, when managing chunks, itโ€™s needed a pointer to the begining of the headers (metadata).
For these conversions these functions are used:

// https://github.com/bminor/glibc/blob/master/malloc/malloc.c

/* Convert a chunk address to a user mem pointer without correcting the tag.  */
#define chunk2mem(p) ((void*)((char*)(p) + CHUNK_HDR_SZ))

/* Convert a user mem pointer to a chunk address and extract the right tag.  */
#define mem2chunk(mem) ((mchunkptr)tag_at (((char*)(mem) - CHUNK_HDR_SZ)))

/* The smallest possible chunk */
#define MIN_CHUNK_SIZE        (offsetof(struct malloc_chunk, fd_nextsize))

/* The smallest size we can malloc is an aligned minimal chunk */

#define MINSIZE  \
(unsigned long)(((MIN_CHUNK_SIZE+MALLOC_ALIGN_MASK) & ~MALLOC_ALIGN_MASK))

์ •๋ ฌ ๋ฐ ์ตœ์†Œ ํฌ๊ธฐ

chunk์— ๋Œ€ํ•œ pointer์™€ 0x0f๋Š” 0์ด์–ด์•ผ ํ•œ๋‹ค.

// From https://github.com/bminor/glibc/blob/a07e000e82cb71238259e674529c37c12dc7d423/sysdeps/generic/malloc-size.h#L61
#define MALLOC_ALIGN_MASK (MALLOC_ALIGNMENT - 1)

// https://github.com/bminor/glibc/blob/a07e000e82cb71238259e674529c37c12dc7d423/sysdeps/i386/malloc-alignment.h
#define MALLOC_ALIGNMENT 16


// https://github.com/bminor/glibc/blob/master/malloc/malloc.c
/* Check if m has acceptable alignment */
#define aligned_OK(m)  (((unsigned long)(m) & MALLOC_ALIGN_MASK) == 0)

#define misaligned_chunk(p) \
((uintptr_t)(MALLOC_ALIGNMENT == CHUNK_HDR_SZ ? (p) : chunk2mem (p)) \
& MALLOC_ALIGN_MASK)


/* pad request bytes into a usable size -- internal version */
/* Note: This must be a macro that evaluates to a compile time constant
if passed a literal constant.  */
#define request2size(req)                                         \
(((req) + SIZE_SZ + MALLOC_ALIGN_MASK < MINSIZE)  ?             \
MINSIZE :                                                      \
((req) + SIZE_SZ + MALLOC_ALIGN_MASK) & ~MALLOC_ALIGN_MASK)

/* Check if REQ overflows when padded and aligned and if the resulting
value is less than PTRDIFF_T.  Returns the requested size or
MINSIZE in case the value is less than MINSIZE, or 0 if any of the
previous checks fail.  */
static inline size_t
checked_request2size (size_t req) __nonnull (1)
{
if (__glibc_unlikely (req > PTRDIFF_MAX))
return 0;

/* When using tagged memory, we cannot share the end of the user
block with the header for the next chunk, so ensure that we
allocate blocks that are rounded up to the granule size.  Take
care not to overflow from close to MAX_SIZE_T to a small
number.  Ideally, this would be part of request2size(), but that
must be a macro that produces a compile time constant if passed
a constant literal.  */
if (__glibc_unlikely (mtag_enabled))
{
/* Ensure this is not evaluated if !mtag_enabled, see gcc PR 99551.  */
asm ("");

req = (req + (__MTAG_GRANULE_SIZE - 1)) &
~(size_t)(__MTAG_GRANULE_SIZE - 1);
}

return request2size (req);
}

Note that for calculating the total space needed itโ€™s only added SIZE_SZ 1 time because the prev_size field can be used to store data, therefore only the initial header is needed.

Chunk ๋ฐ์ดํ„ฐ ๊ฐ€์ ธ์˜ค๊ธฐ ๋ฐ metadata ๋ณ€๊ฒฝ

์ด ํ•จ์ˆ˜๋“ค์€ chunk์— ๋Œ€ํ•œ pointer๋ฅผ ๋ฐ›์•„ ๋™์ž‘ํ•˜๋ฉฐ metadata๋ฅผ ํ™•์ธ/์„ค์ •ํ•˜๋Š” ๋ฐ ์œ ์šฉํ•ฉ๋‹ˆ๋‹ค:

  • chunk์˜ flags ํ™•์ธ
// From https://github.com/bminor/glibc/blob/master/malloc/malloc.c


/* size field is or'ed with PREV_INUSE when previous adjacent chunk in use */
#define PREV_INUSE 0x1

/* extract inuse bit of previous chunk */
#define prev_inuse(p)       ((p)->mchunk_size & PREV_INUSE)


/* size field is or'ed with IS_MMAPPED if the chunk was obtained with mmap() */
#define IS_MMAPPED 0x2

/* check for mmap()'ed chunk */
#define chunk_is_mmapped(p) ((p)->mchunk_size & IS_MMAPPED)


/* size field is or'ed with NON_MAIN_ARENA if the chunk was obtained
from a non-main arena.  This is only set immediately before handing
the chunk to the user, if necessary.  */
#define NON_MAIN_ARENA 0x4

/* Check for chunk from main arena.  */
#define chunk_main_arena(p) (((p)->mchunk_size & NON_MAIN_ARENA) == 0)

/* Mark a chunk as not being on the main arena.  */
#define set_non_main_arena(p) ((p)->mchunk_size |= NON_MAIN_ARENA)
  • ํฌ๊ธฐ ๋ฐ pointers to other chunks
/*
Bits to mask off when extracting size

Note: IS_MMAPPED is intentionally not masked off from size field in
macros for which mmapped chunks should never be seen. This should
cause helpful core dumps to occur if it is tried by accident by
people extending or adapting this malloc.
*/
#define SIZE_BITS (PREV_INUSE | IS_MMAPPED | NON_MAIN_ARENA)

/* Get size, ignoring use bits */
#define chunksize(p) (chunksize_nomask (p) & ~(SIZE_BITS))

/* Like chunksize, but do not mask SIZE_BITS.  */
#define chunksize_nomask(p)         ((p)->mchunk_size)

/* Ptr to next physical malloc_chunk. */
#define next_chunk(p) ((mchunkptr) (((char *) (p)) + chunksize (p)))

/* Size of the chunk below P.  Only valid if !prev_inuse (P).  */
#define prev_size(p) ((p)->mchunk_prev_size)

/* Set the size of the chunk below P.  Only valid if !prev_inuse (P).  */
#define set_prev_size(p, sz) ((p)->mchunk_prev_size = (sz))

/* Ptr to previous physical malloc_chunk.  Only valid if !prev_inuse (P).  */
#define prev_chunk(p) ((mchunkptr) (((char *) (p)) - prev_size (p)))

/* Treat space at ptr + offset as a chunk */
#define chunk_at_offset(p, s)  ((mchunkptr) (((char *) (p)) + (s)))
  • ์‚ฌ์šฉ ์ค‘ ๋น„ํŠธ
/* extract p's inuse bit */
#define inuse(p)							      \
((((mchunkptr) (((char *) (p)) + chunksize (p)))->mchunk_size) & PREV_INUSE)

/* set/clear chunk as being inuse without otherwise disturbing */
#define set_inuse(p)							      \
((mchunkptr) (((char *) (p)) + chunksize (p)))->mchunk_size |= PREV_INUSE

#define clear_inuse(p)							      \
((mchunkptr) (((char *) (p)) + chunksize (p)))->mchunk_size &= ~(PREV_INUSE)


/* check/set/clear inuse bits in known places */
#define inuse_bit_at_offset(p, s)					      \
(((mchunkptr) (((char *) (p)) + (s)))->mchunk_size & PREV_INUSE)

#define set_inuse_bit_at_offset(p, s)					      \
(((mchunkptr) (((char *) (p)) + (s)))->mchunk_size |= PREV_INUSE)

#define clear_inuse_bit_at_offset(p, s)					      \
(((mchunkptr) (((char *) (p)) + (s)))->mchunk_size &= ~(PREV_INUSE))
  • ํ—ค๋”์™€ ํ‘ธํ„ฐ ์„ค์ • (chunk nos ์‚ฌ์šฉ ์ค‘์ผ ๋•Œ
/* Set size at head, without disturbing its use bit */
#define set_head_size(p, s)  ((p)->mchunk_size = (((p)->mchunk_size & SIZE_BITS) | (s)))

/* Set size/use field */
#define set_head(p, s)       ((p)->mchunk_size = (s))

/* Set size at footer (only when chunk is not in use) */
#define set_foot(p, s)       (((mchunkptr) ((char *) (p) + (s)))->mchunk_prev_size = (s))
  • chunk ๋‚ด๋ถ€์˜ ์‹ค์ œ ์‚ฌ์šฉ ๊ฐ€๋Šฅํ•œ ๋ฐ์ดํ„ฐ ํฌ๊ธฐ๋ฅผ ์–ป๊ธฐ
#pragma GCC poison mchunk_size
#pragma GCC poison mchunk_prev_size

/* This is the size of the real usable data in the chunk.  Not valid for
dumped heap chunks.  */
#define memsize(p)                                                    \
(__MTAG_GRANULE_SIZE > SIZE_SZ && __glibc_unlikely (mtag_enabled) ? \
chunksize (p) - CHUNK_HDR_SZ :                                    \
chunksize (p) - CHUNK_HDR_SZ + (chunk_is_mmapped (p) ? 0 : SIZE_SZ))

/* If memory tagging is enabled the layout changes to accommodate the granule
size, this is wasteful for small allocations so not done by default.
Both the chunk header and user data has to be granule aligned.  */
_Static_assert (__MTAG_GRANULE_SIZE <= CHUNK_HDR_SZ,
"memory tagging is not supported with large granule.");

static __always_inline void *
tag_new_usable (void *ptr)
{
if (__glibc_unlikely (mtag_enabled) && ptr)
{
mchunkptr cp = mem2chunk(ptr);
ptr = __libc_mtag_tag_region (__libc_mtag_new_tag (ptr), memsize (cp));
}
return ptr;
}

์˜ˆ์ œ

๋น ๋ฅธ Heap ์˜ˆ์ œ

https://guyinatuxedo.github.io/25-heap/index.html์˜ ๋น ๋ฅธ heap ์˜ˆ์ œ์ด์ง€๋งŒ arm64์šฉ:

#include <stdio.h>
#include <stdlib.h>
#include <string.h>

void main(void)
{
char *ptr;
ptr = malloc(0x10);
strcpy(ptr, "panda");
}

main ํ•จ์ˆ˜์˜ ๋์— breakpoint๋ฅผ ์„ค์ •ํ•˜๊ณ  ์ •๋ณด๊ฐ€ ์–ด๋””์— ์ €์žฅ๋˜์—ˆ๋Š”์ง€ ์•Œ์•„๋ณด์ž:

๋ฌธ์ž์—ด panda๊ฐ€ 0xaaaaaaac12a0์— ์ €์žฅ๋œ ๊ฒƒ์„ ํ™•์ธํ•  ์ˆ˜ ์žˆ๋‹ค(์ด ์ฃผ์†Œ๋Š” x0 ์•ˆ์—์„œ malloc์ด ๋ฐ˜ํ™˜ํ•œ ์ฃผ์†Œ๋‹ค). 0x10 ๋ฐ”์ดํŠธ ์•ž์„ ํ™•์ธํ•ด๋ณด๋ฉด 0x0์ด previous chunk is not used(๊ธธ์ด 0)์„ ๋‚˜ํƒ€๋‚ด๋ฉฐ, ์ด ์ฒญํฌ์˜ ๊ธธ์ด๋Š” 0x21์ด๋‹ค.

์ถ”๊ฐ€๋กœ ์˜ˆ์•ฝ๋œ ๊ณต๊ฐ„(0x21-0x10=0x11)์€ added headers(0x10)์—์„œ ์˜จ ๊ฒƒ์ด๋ฉฐ, 0x1์€ 0x21B๊ฐ€ ์˜ˆ์•ฝ๋˜์—ˆ๋‹ค๋Š” ์˜๋ฏธ๊ฐ€ ์•„๋‹ˆ๋ผ ํ˜„์žฌ ํ—ค๋” ๊ธธ์ด์˜ ๋งˆ์ง€๋ง‰ 3๋น„ํŠธ๊ฐ€ ํŠน๋ณ„ํ•œ ์˜๋ฏธ๋ฅผ ๊ฐ€์ง„๋‹ค๋Š” ๋œป์ด๋‹ค. ๊ธธ์ด๋Š” ํ•ญ์ƒ 16-byte aligned(64bits machines)์ด๋ฏ€๋กœ, ์ด ๋น„ํŠธ๋“ค์€ ์‹ค์ œ ๊ธธ์ด ์ˆซ์ž์—์„œ๋Š” ์‚ฌ์šฉ๋˜์ง€ ์•Š๋Š”๋‹ค.

0x1:     Previous in Use     - Specifies that the chunk before it in memory is in use
0x2:     Is MMAPPED          - Specifies that the chunk was obtained with mmap()
0x4:     Non Main Arena      - Specifies that the chunk was obtained from outside of the main arena

๋ฉ€ํ‹ฐ์Šค๋ ˆ๋”ฉ ์˜ˆ์ œ

๋ฉ€ํ‹ฐ์Šค๋ ˆ๋”ฉ ```c #include #include #include #include #include

void* threadFuncMalloc(void* arg) { printf(โ€œHello from thread 1\nโ€); char* addr = (char*) malloc(1000); printf(โ€œAfter malloc and before free in thread 1\nโ€); free(addr); printf(โ€œAfter free in thread 1\nโ€); }

void* threadFuncNoMalloc(void* arg) { printf(โ€œHello from thread 2\nโ€); }

int main() { pthread_t t1; void* s; int ret; char* addr;

printf(โ€œBefore creating thread 1\nโ€); getchar(); ret = pthread_create(&t1, NULL, threadFuncMalloc, NULL); getchar();

printf(โ€œBefore creating thread 2\nโ€); ret = pthread_create(&t1, NULL, threadFuncNoMalloc, NULL);

printf(โ€œBefore exit\nโ€); getchar();

return 0; }

</details>

์ด์ „ ์˜ˆ์ œ๋ฅผ ๋””๋ฒ„๊น…ํ•˜๋ฉด ์‹œ์ž‘ํ•  ๋•Œ arena๊ฐ€ 1๊ฐœ๋งŒ ์žˆ์Œ์„ ํ™•์ธํ•  ์ˆ˜ ์žˆ๋‹ค:

<figure><img src="../../images/image (1) (1) (1) (1) (1) (1) (1) (1) (1).png" alt=""><figcaption></figcaption></figure>

๊ทธ๋Ÿฐ ๋‹ค์Œ ์ฒซ ๋ฒˆ์งธ thread, ์ฆ‰ malloc์„ ํ˜ธ์ถœํ•˜๋Š” thread๋ฅผ ์‹คํ–‰ํ•˜๋ฉด ์ƒˆ๋กœ์šด arena๊ฐ€ ์ƒ์„ฑ๋œ๋‹ค:

<figure><img src="../../images/image (1) (1) (1) (1) (1) (1) (1) (1) (1) (1).png" alt=""><figcaption></figcaption></figure>

๊ทธ ๋‚ด๋ถ€์—๋Š” ๋ช‡๋ช‡ chunks๊ฐ€ ์กด์žฌํ•œ๋‹ค:

<figure><img src="../../images/image (2) (1) (1) (1) (1) (1).png" alt=""><figcaption></figcaption></figure>

## Bins & Memory Allocations/Frees

bins๊ฐ€ ๋ฌด์—‡์ธ์ง€, ์–ด๋–ป๊ฒŒ ์กฐ์ง๋˜๋Š”์ง€, ๊ทธ๋ฆฌ๊ณ  ๋ฉ”๋ชจ๋ฆฌ๊ฐ€ ์–ด๋–ป๊ฒŒ ํ• ๋‹น๋˜๊ณ  ํ•ด์ œ๋˜๋Š”์ง€ ํ™•์ธํ•˜๋ผ:


<a class="content_ref" href="bins-and-memory-allocations.md"><span class="content_ref_label">Bins & Memory Allocations</span></a>

## Heap ํ•จ์ˆ˜ ๋ณด์•ˆ ๊ฒ€์‚ฌ

Heap๊ณผ ๊ด€๋ จ๋œ ํ•จ์ˆ˜๋“ค์€ ๋™์ž‘์„ ์ˆ˜ํ–‰ํ•˜๊ธฐ ์ „์— heap์ด ์†์ƒ๋˜์ง€ ์•Š์•˜๋Š”์ง€ ํ™•์ธํ•˜๊ธฐ ์œ„ํ•ด ํŠน์ • ๊ฒ€์‚ฌ๋ฅผ ์ˆ˜ํ–‰ํ•œ๋‹ค:


<a class="content_ref" href="heap-memory-functions/heap-functions-security-checks.md"><span class="content_ref_label">Heap Functions Security Checks</span></a>

## musl mallocng exploitation notes (Alpine)

- **Slab group/slot grooming for huge linear copies:** mallocng sizeclasses๋Š” ์Šฌ๋กฏ์ด ๋น„์–ด ์žˆ์„ ๋•Œ ์™„์ „ํžˆ `munmap()`๋˜๋Š” mmap()'d ๊ทธ๋ฃน์„ ์‚ฌ์šฉํ•œ๋‹ค. ๊ธด ์„ ํ˜• ๋ณต์‚ฌ(~0x15555555 bytes)์˜ ๊ฒฝ์šฐ, span์„ ๋งคํ•‘๋œ ์ƒํƒœ๋กœ ์œ ์ง€(ํ•ด์ œ๋œ ๊ทธ๋ฃน์œผ๋กœ ์ธํ•œ ๊ตฌ๋ฉ์„ ํ”ผํ•จ)ํ•˜๊ณ  victim allocation์„ source slot์— ์ธ์ ‘ํ•˜๊ฒŒ ๋ฐฐ์น˜ํ•˜๋ผ.
- **Cycling offset mitigation:** slot ์žฌ์‚ฌ์šฉ ์‹œ mallocng์€ slack์ด ์ถ”๊ฐ€ 4-byte header๋ฅผ ์ˆ˜์šฉํ•  ๋•Œ user-data ์‹œ์ž‘์„ `UNIT` (0x10) ๋ฐฐ์ˆ˜๋งŒํผ ์•ž๋‹น๊ธธ ์ˆ˜ ์žˆ๋‹ค. ์ด๋กœ ์ธํ•ด overwrite offsets(์˜ˆ: LSB pointer hits)๊ฐ€ ์ด๋™ํ•œ๋‹ค. reuse counts๋ฅผ ์ œ์–ดํ•˜๊ฑฐ๋‚˜ slack์ด ์—†๋Š” strides(์˜ˆ: stride 0x50์˜ Lua `Table` ๊ฐ์ฒด๋Š” offset 0์„ ๋ณด์ž„)๋ฅผ ๊ณ ์ˆ˜ํ•˜์ง€ ์•Š๋Š” ํ•œ ๊ทธ๋ ‡๋‹ค. offsets๋Š” muslheapโ€™s `mchunkinfo`๋กœ ๊ฒ€์‚ฌํ•˜๋ผ:
```gdb
pwndbg> mchunkinfo 0x7ffff7a94e40
... stride: 0x140
... cycling offset : 0x1 (userdata --> 0x7ffff7a94e40)
  • Prefer runtime-object corruption over allocator metadata: mallocng mixes cookies/guarded out-of-band metadata, so target higher-level objects. In Redisโ€™s Lua 5.1, Table->array points to an array of TValue tagged values; overwriting the LSB of a pointer in TValue->value (e.g., with the JSON terminator byte 0x22) can pivot references without touching malloc metadata.
  • Debugging stripped/static Lua on Alpine: ์ผ์น˜ํ•˜๋Š” Lua๋ฅผ ๋นŒ๋“œํ•˜๊ณ , readelf -Ws๋กœ ์‹ฌ๋ณผ์„ ํ™•์ธํ•œ ๋‹ค์Œ objcopy --strip-symbol๋กœ ํ•จ์ˆ˜ ์‹ฌ๋ณผ์„ ์ œ๊ฑฐํ•ด GDB์—์„œ ๊ตฌ์กฐ์ฒด ๋ ˆ์ด์•„์›ƒ์„ ๋…ธ์ถœ์‹œํ‚ค์„ธ์š”. ๊ทธ๋Ÿฐ ๋‹ค์Œ Lua-aware pretty-printers (GdbLuaExtension for Lua 5.1)์™€ muslheap์„ ์‚ฌ์šฉํ•ด ์˜ค๋ฒ„ํ”Œ๋กœ๋ฅผ ํŠธ๋ฆฌ๊ฑฐํ•˜๊ธฐ ์ „์— stride/reserved/cycling-offset ๊ฐ’๋“ค์„ ํ™•์ธํ•˜์„ธ์š”.

Case Studies

์‹ค์ œ ๋ฒ„๊ทธ์—์„œ ํŒŒ์ƒ๋œ allocator-specific primitives๋ฅผ ์—ฐ๊ตฌํ•˜์„ธ์š”:

Virtualbox Slirp Nat Packet Heap Exploitation

Gnu Obstack Function Pointer Hijack

References

Tip

AWS ํ•ดํ‚น ๋ฐฐ์šฐ๊ธฐ ๋ฐ ์—ฐ์Šตํ•˜๊ธฐ:HackTricks Training AWS Red Team Expert (ARTE)
GCP ํ•ดํ‚น ๋ฐฐ์šฐ๊ธฐ ๋ฐ ์—ฐ์Šตํ•˜๊ธฐ: HackTricks Training GCP Red Team Expert (GRTE) Azure ํ•ดํ‚น ๋ฐฐ์šฐ๊ธฐ ๋ฐ ์—ฐ์Šตํ•˜๊ธฐ: HackTricks Training Azure Red Team Expert (AzRTE)

HackTricks ์ง€์›ํ•˜๊ธฐ