CLE: Common Library for Executables

9.2.209 · active · verified Mon Apr 13

CLE (Common Library for Executables) is a Python library that loads binaries and their associated libraries, resolves imports, and provides an abstraction of process memory, mimicking how an operating system's loader would present them. It is a core component of the larger angr binary analysis framework. The current version is 9.2.209, and it maintains an active release cadence as part of the angr project.

Warnings

Install

Imports

Quickstart

This quickstart demonstrates how to load a binary file using `cle.Loader`, access its entry point, list its shared objects, and inspect an imported symbol. Replace `/bin/ls` with a path to an actual executable on your system for a functional example. Environment variable `CLE_BINARY_PATH` can be used to specify the binary.

import cle
import os

# For demonstration, use a common system binary like '/bin/ls'
# On Windows, you might use a path to an executable like 'C:\Windows\System32\calc.exe'
binary_path = os.environ.get('CLE_BINARY_PATH', '/bin/ls')

try:
    ld = cle.Loader(binary_path)

    print(f"Loaded binary: {ld.main_object.binary_path}")
    print(f"Entry point: {hex(ld.main_object.entry)}")
    print("Shared objects:")
    for obj_name, obj_data in ld.shared_objects.items():
        print(f"  - {obj_name}: {obj_data}")

    # Example of accessing an import
    if '__libc_start_main' in ld.main_object.imports:
        libc_main_reloc = ld.main_object.imports['__libc_start_main']
        print(f"Address of __libc_start_main GOT entry: {hex(libc_main_reloc.addr)}")

except Exception as e:
    print(f"Error loading binary {binary_path}: {e}")
    print("Please ensure the binary exists and is a valid executable format for CLE.")

view raw JSON →