Prerequisites
1
Install Build Tools
Install required packages and tools:
2
Ensure Python Symlink
The build system requires
/usr/bin/python to exist:3
Clone Repository
Clone the how2heap repository:
Setup Methods
You can choose between two methods depending on your needs:Method 1: Link Against Older libc
Links binaries directly to specific glibc versions with debug symbols
Method 2: Docker Environment
Compiles in Ubuntu containers matching the target glibc version
Why Specific Glibc Versions?
Heap exploitation techniques are version-specific because:- Glibc constantly adds security checks
- Techniques may work on older versions but fail on newer ones
- Some attacks require precise knowledge of internal structures
Method 1: Link Against Older libc
This method tells the linker to link target binaries with the target libc and includes debug symbols.1
Build for Specific Version
Build all techniques for a specific glibc version:Available versions:
2.23, 2.24, 2.27, 2.31, 2.32, 2.33, 2.34, 2.35, 2.36, 2.37, 2.38, 2.39, 2.40, 2.412
Run the Binaries
Execute the compiled binaries directly:The binaries are already linked with the correct libc and include debug symbols.
3
Debug with GDB
Debug with full symbol support:
Building Specific Techniques
The first build downloads the corresponding libc from glibc-all-in-one. Subsequent builds for the same version are faster.
Method 2: Docker Environment
This method uses Docker to compile binaries inside an Ubuntu container that matches the target libc version.1
Install Docker
Make sure Docker is installed and you have access:
2
Build Base Binaries
First, build the base binaries:
3
Prepare with glibc_run.sh
Use the This script:
glibc_run.sh script to set up and run binaries:- Downloads the target libc if needed
- Patches the binary’s interpreter and RUNPATH
- Optionally builds a Docker environment
- Runs the binary with the correct libc
Using glibc_run.sh
Theglibc_run.sh script is a powerful wrapper that handles libc version management.
Basic Usage
Options
Examples
How It Works
The script usespatchelf to modify the binary:
glibc_run.sh, the binary is patched to use:
- Interpreter: The ld-linux loader from the target glibc version
- RUNPATH: Path to the downloaded glibc libraries
The script only patches the binary if the system glibc version differs from the target version.
Environment Configuration
Directory Structure
After setup, your directory will look like:Verifying Setup
Check that binaries are correctly linked:Testing Techniques
Run automated tests for all techniques in a specific version:Troubleshooting
Symbol Versioning Errors
Missing Dependencies
Docker Permission Denied
Failed to Download Libc
Binary Segfaults Immediately
Check that you’re using compatible architectures:GDB Can’t Find Debug Symbols
Cleaning Up
Advanced Configuration
Building for Specific Architecture
By default, how2heap builds for x86-64. For 32-bit:Custom Compiler Flags
ModifyMakefile to add custom flags:
Using with CTF Challenges
To test your exploit against a specific libc version:Next Steps
Start Learning
Begin with the quickstart guide and try your first technique
Debugging Tools
Install pwndbg, gef, or Pwngdb for advanced heap visualization
