Learn heap exploitation techniques by running real examples. This guide will get you started quickly with the basics.Documentation Index
Fetch the complete documentation index at: https://mintlify.com/shellphish/how2heap/llms.txt
Use this file to discover all available pages before exploring further.
Quick Setup
The fastest way to get started is with the Quick Setup method, which uses your system’s glibc.Install Required Tools
Make sure you have the following packages installed:Also ensure
/usr/bin/python points to your Python binary:Clone and Build
Clone the repository and build the base binaries:This builds the base binaries:
malloc_playground, first_fit, and calc_tcache_idx.Using Malloc Playground
The malloc playground allows you to allocate, free, and manipulate memory interactively.Basic Commands
Available Commands
| Command | Description | Example |
|---|---|---|
malloc n | Allocate n bytes | malloc 256 |
free [p] | Free memory (default: last allocated) | free or free 0 |
write str [p] | Write string to pointer | write test 0 |
listp | List active pointers | listp |
listpall | List all pointer slots | listpall |
clearlist | Free all allocations | clearlist |
stats | Show malloc statistics | stats |
info | Show detailed malloc info | info |
The malloc playground tracks up to 20 pointers at once. Use
clearlist to reset and free all allocations.Your First Technique: First Fit
Now let’s run your first heap exploitation technique demo.Run the Example
Execute the compiled binary:You’ll see output demonstrating how glibc reuses freed chunks:
Exploring Techniques
The repository includes dozens of techniques organized by glibc version:Fastbin Techniques
fastbin_dup- Double free attackfastbin_dup_into_stack- Arbitrary pointerfastbin_dup_consolidate- Bypass checks
Tcache Techniques
tcache_poisoning- Poison tcache entriestcache_dup- Double free in tcachehouse_of_botcake- Advanced tcache exploit
House Techniques
house_of_spirit- Fake fastbin chunkshouse_of_lore- Smallbin exploitationhouse_of_einherjar- Null byte overflow
Advanced
unsafe_unlink- Arbitrary writepoison_null_byte- Single byte overflowlarge_bin_attack- Large bin exploitation
Next Steps
Complete Setup
Configure specific glibc versions using Docker or linker methods
Debugging
Use GDB with heap visualization tools like pwndbg or gef
