Skip to main content
This guide covers advanced setup options for working with specific glibc versions, essential for testing techniques against different library implementations.

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?

You’ll encounter symbol versioning issues if you try to LD_PRELOAD different libcs to a binary compiled on your host machine. These methods bypass that limitation.
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
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.41
2

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 glibc_run.sh script to set up and run binaries:
This script:
  • 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

The glibc_run.sh script is a powerful wrapper that handles libc version management.

Basic Usage

Options

Examples

How It Works

The script uses patchelf to modify the binary:
After running 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:
This runs each technique 20 times to account for ASLR and race conditions.

Troubleshooting

Symbol Versioning Errors

Problem: Error like version GLIBC_2.34 not foundSolution: Use Method 1 (link against older libc) instead of trying to LD_PRELOAD different versions.

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

make distclean will remove all downloaded glibc versions. You’ll need to re-download them on the next build.

Advanced Configuration

Building for Specific Architecture

By default, how2heap builds for x86-64. For 32-bit:

Custom Compiler Flags

Modify Makefile 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