401-403-bypass-techniq…
401/403 bypass playbook. Use when encountering access-denied responses on admin panels, API endpoints, or restricted paths. Covers path manipulation, HTTP…
Heap exploitation playbook. Use when targeting ptmalloc2/glibc heap vulnerabilities including UAF, double free, overflow, off-by-one/null, and leveraging tcache/fastbin/unsortedbin attacks for arbitrary write or code execution.
$ npx -y skills add yaklang/hack-skills --skill heap-exploitation --agent claude-codeHow it fires
How this skill gets triggered: by you, by Claude, or both.
/heap-exploitationContext preview
The summary Claude sees to decide when to auto-load this skill.
Heap exploitation playbook. Use when targeting ptmalloc2/glibc heap vulnerabilities including UAF, double free, overflow, off-by-one/null, and leveraging tcache/fastbin/unsortedbin attacks for arbitrary write or code execution.
name: heap-exploitation description: >- Heap exploitation playbook. Use when targeting ptmalloc2/glibc heap vulnerabilities including UAF, double free, overflow, off-by-one/null, and leveraging tcache/fastbin/unsortedbin attacks for arbitrary write or code execution.
> **AI LOAD INSTRUCTION**: Expert glibc heap exploitation techniques. Covers ptmalloc2 internals, bin structures, tcache mechanics, libc/heap leak methods, and attack selection by glibc version. Distilled from ctf-wiki heap sections, how2heap, and real-world exploitation. Base models often confuse glibc version constraints and miss safe-linking (PROTECT_PTR) introduced in 2.32.
---
chunk pointer (returned by malloc - 0x10)
┌──────────────────────────┐
0x00 │ prev_size (if prev free)│
0x08 │ size | A | M | P │ ← P=PREV_INUSE, M=IS_MMAPPED, A=NON_MAIN_ARENA
├──────────────────────────┤ ← user data starts here (returned pointer)
0x10 │ fd (if free) │ ← forward pointer to next free chunk
0x18 │ bk (if free) │ ← backward pointer to prev free chunk
0x20 │ fd_nextsize (large only)│
0x28 │ bk_nextsize (large only)│
└──────────────────────────┘| Bin | Size Range (64-bit) | Structure | LIFO/FIFO | |---|---|---|---| | tcache (per-thread) | ≤ 0x410 (7 entries per size) | Singly linked (next pointer) | LIFO | | fastbin | ≤ 0x80 (default) | Singly linked (fd) | LIFO | | unsortedbin | Any freed size | Doubly linked circular | FIFO | | smallbin | < 0x400 | Doubly linked circular | FIFO | | largebin | ≥ 0x400 | Doubly linked + size-sorted | Sorted |
| Structure | Location | Purpose | |---|---|---| | `main_arena` | libc .data segment | Contains bin heads, top chunk, system_mem | | `mp_` | libc .data | malloc parameters (tcache settings, mmap threshold) | | `tcache_perthread_struct` | Heap (first allocation) | Per-thread tcache bins and counts |
---
| Method | Precondition | Technique | |---|---|---| | Unsortedbin fd/bk | Free a chunk > tcache range (or fill tcache) | fd/bk → `main_arena + 0x60` (or +0x70 depending on version) → libc base | | Smallbin fd/bk | Chunk moved from unsortedbin to smallbin | Same as unsortedbin leak | | stdout FILE leak | Write to `_IO_2_1_stdout_` | Corrupt `_IO_write_base` to leak libc data (see IO_FILE) |
| Method | Precondition | Technique | |---|---|---| | Tcache fd pointer | Free two tcache chunks, read first's fd | fd → heap address (XOR'd in ≥ 2.32) | | Fastbin fd | Free two fastbin chunks | fd → heap address | | UAF read | Use-after-free on freed chunk | Read fd/bk directly |
# PROTECT_PTR: fd_stored = (chunk_addr >> 12) ^ real_fd
# To decode: real_fd = fd_stored ^ (chunk_addr >> 12)
# To encode: fd_stored = (chunk_addr >> 12) ^ target_addr
def deobfuscate(stored_fd, chunk_addr):
return stored_fd ^ (chunk_addr >> 12)
def obfuscate(target, chunk_addr):
return (chunk_addr >> 12) ^ target---
| Attack | Primitive Needed | Result | |---|---|---| | Fastbin dup | Double free | Arbitrary allocation | | Unsortedbin attack | Corrupt unsortedbin bk | Write `main_arena` addr to target (used for __malloc_hook nearby overwrite) | | Unlink attack | Heap overflow into prev_size + fd/bk | Arbitrary write (with known heap pointer) | | House of Force | Top chunk size overwrite | Arbitrary allocation | | House of Spirit | Write fake chunk header | Fastbin allocation at fake chunk | | Off-by-one null | Null byte overflow into next chunk size | Overlapping chunks |
| Attack | Notes | |---|---| | Tcache poisoning | Overwrite tcache fd → arbitrary allocation, no size check | | Tcache dup | Double free into tcache (no double-free detection yet) | | All previous attacks | Still work, but chunks go to tcache first |
| Attack | Bypass for tcache key | |---|---| | Tcache dup | Corrupt `key` field (at chunk+0x18) before second free | | House of Botcake | Double free: one in unsortedbin, one in tcache → overlapping | | Tcache stashing unlink | Abuse smallbin→tcache refill to get arbitrary chunk |
| Attack | Adaptation | |---|---| | Tcache poisoning | Encode target with `(chunk_addr >> 12) ^ target` | | Heap leak required | Need heap addr to decode/encode safe-linked pointers | | Fastbin dup | Same encoding required |
| Change | Impact | |---|---| | `__malloc_hook` removed | Cannot overwrite hook for one_gadget | | `__free_hook` removed | Cannot overwrite hook | | `__realloc_hook` removed | Cannot use realloc trick for one_gadget constraints |
**Post-2.34 targets**: see [arbitrary-write-to-rce](../arbitrary-write-to-rce/SKILL.md) for `_IO_FILE`, `exit_funcs`, `TLS_dtor_list`, `_dl_fini`.
---
Master Entry → Category Entries → Deep Topic Skills One master entry, six category entries, and 102 deep topic skills across 14 security domains.
Repo: yaklang/hack-skills
401/403 bypass playbook. Use when encountering access-denied responses on admin panels, API endpoints, or restricted paths. Covers path manipulation, HTTP…
Active Directory ACL abuse playbook. Use when exploiting misconfigured AD permissions including GenericAll, WriteDACL, DCSync rights, shadow credentials, LAPS…
AD Certificate Services attack playbook. Use when targeting misconfigured AD CS for privilege escalation via ESC1-ESC13 template abuse, NTLM relay to…
Kerberos attack playbook for Active Directory. Use when targeting AD authentication via AS-REP roasting, Kerberoasting, golden/silver/diamond tickets,…
AI/ML security playbook. Use when assessing model supply chain attacks (pickle RCE, poisoned weights), adversarial examples, model poisoning, model stealing,…
Android pentesting playbook. Use when testing Android applications for SSL pinning bypass, exported component abuse, WebView vulnerabilities, intent…