Skip to main content

CLE Loads Everything (at least, many binary formats!) and provides a pythonic interface to analyze what they are and what they would look like in memory.

Project description

CLE

Latest Release Python Version PyPI Statistics License

CLE loads binaries and their associated libraries, resolves imports and provides an abstraction of process memory the same way as if it was loader by the OS's loader.

Project Links

Project repository: https://github.com/angr/cle

Documentation: https://api.angr.io/projects/cle/en/latest/

Installation

pip install cle

Usage example

>>> import cle
>>> ld = cle.Loader("/bin/ls")
>>> hex(ld.main_object.entry)
'0x4048d0'
>>> ld.shared_objects
{'ld-linux-x86-64.so.2': <ELF Object ld-2.21.so, maps [0x5000000:0x522312f]>,
 'libacl.so.1': <ELF Object libacl.so.1.1.0, maps [0x2000000:0x220829f]>,
 'libattr.so.1': <ELF Object libattr.so.1.1.0, maps [0x4000000:0x4204177]>,
 'libc.so.6': <ELF Object libc-2.21.so, maps [0x3000000:0x33a1a0f]>,
 'libcap.so.2': <ELF Object libcap.so.2.24, maps [0x1000000:0x1203c37]>}
>>> ld.addr_belongs_to_object(0x5000000)
<ELF Object ld-2.21.so, maps [0x5000000:0x522312f]>
>>> libc_main_reloc = ld.main_object.imports['__libc_start_main']
>>> hex(libc_main_reloc.addr)       # Address of GOT entry for libc_start_main
'0x61c1c0'
>>> import pyvex
>>> some_text_data = ld.memory.load(ld.main_object.entry, 0x100)
>>> irsb = pyvex.lift(some_text_data, ld.main_object.entry, ld.main_object.arch)
>>> irsb.pp()
IRSB {
   t0:Ity_I32 t1:Ity_I32 t2:Ity_I32 t3:Ity_I64 t4:Ity_I64 t5:Ity_I64 t6:Ity_I32 t7:Ity_I64 t8:Ity_I32 t9:Ity_I64 t10:Ity_I64 t11:Ity_I64 t12:Ity_I64 t13:Ity_I64 t14:Ity_I64

   15 | ------ IMark(0x4048d0, 2, 0) ------
   16 | t5 = 32Uto64(0x00000000)
   17 | PUT(rbp) = t5
   18 | t7 = GET:I64(rbp)
   19 | t6 = 64to32(t7)
   20 | t2 = t6
   21 | t9 = GET:I64(rbp)
   22 | t8 = 64to32(t9)
   23 | t1 = t8
   24 | t0 = Xor32(t2,t1)
   25 | PUT(cc_op) = 0x0000000000000013
   26 | t10 = 32Uto64(t0)
   27 | PUT(cc_dep1) = t10
   28 | PUT(cc_dep2) = 0x0000000000000000
   29 | t11 = 32Uto64(t0)
   30 | PUT(rbp) = t11
   31 | PUT(rip) = 0x00000000004048d2
   32 | ------ IMark(0x4048d2, 3, 0) ------
   33 | t12 = GET:I64(rdx)
   34 | PUT(r9) = t12
   35 | PUT(rip) = 0x00000000004048d5
   36 | ------ IMark(0x4048d5, 1, 0) ------
   37 | t4 = GET:I64(rsp)
   38 | t3 = LDle:I64(t4)
   39 | t13 = Add64(t4,0x0000000000000008)
   40 | PUT(rsp) = t13
   41 | PUT(rsi) = t3
   42 | PUT(rip) = 0x00000000004048d6
   43 | t14 = GET:I64(rip)
   NEXT: PUT(rip) = t14; Ijk_Boring
}

Valid options

For a full listing and description of the options that can be provided to the loader and the methods it provides, please examine the docstrings in cle/loader.py. If anything is unclear or poorly documented (there is much) please complain through whatever channel you feel appropriate.

Loading Backends

CLE's loader is implemented in the Loader class. There are several backends that can be used to load a single file:

  • ELF, as its name says, loads ELF binaries. ELF files loaded this way are statically parsed using PyElfTools.

  • PE is a backend to load Microsoft's Portable Executable format, effectively Windows binaries. It uses the (optional) pefile module.

  • Mach-O is a backend to load, you guessed it, Mach-O binaries. Support is limited for this backend.

  • Blob is a backend to load unknown data. It requires that you specify the architecture it would be run on, in the form of a class from ArchInfo.

Which backend you use can be specified as an argument to Loader. If left unspecified, the loader will pick a reasonable default.

Finding shared libraries

  • If the auto_load_libs option is set to False, the Loader will not automatically load libraries requested by loaded objects. Otherwise...

  • The loader determines which shared objects are needed when loading binaries, and searches for them in the following order:

    • in the current working directory
    • in folders specified in the ld_path option
    • in the same folder as the main binary
    • in the system (in the corresponding library path for the architecture of the binary, e.g., /usr/arm-linux-gnueabi/lib for ARM, note that you need to install cross libraries for this, e.g., libc6-powerpc-cross on Debian - needs emdebian repos)
    • in the system, but with mismatched version numbers from what is specified as a dependency, if the ignore_import_version_numbers option is True
  • If no binary is found with the correct architecture, the loader raises an exception if except_missing_libs option is True. Otherwise it simply leaves the dependencies unresolved.

Project details


Release history Release notifications | RSS feed

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

cle-9.2.222.tar.gz (423.8 kB view details)

Uploaded Source

Built Distributions

If you're not sure about the file name format, learn more about wheel file names.

cle-9.2.222-cp312-abi3-win_amd64.whl (483.3 kB view details)

Uploaded CPython 3.12+Windows x86-64

cle-9.2.222-cp312-abi3-musllinux_1_2_x86_64.whl (648.7 kB view details)

Uploaded CPython 3.12+musllinux: musl 1.2+ x86-64

cle-9.2.222-cp312-abi3-musllinux_1_2_aarch64.whl (646.2 kB view details)

Uploaded CPython 3.12+musllinux: musl 1.2+ ARM64

cle-9.2.222-cp312-abi3-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl (649.6 kB view details)

Uploaded CPython 3.12+manylinux: glibc 2.17+ x86-64manylinux: glibc 2.28+ x86-64

cle-9.2.222-cp312-abi3-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl (649.9 kB view details)

Uploaded CPython 3.12+manylinux: glibc 2.17+ ARM64manylinux: glibc 2.28+ ARM64

cle-9.2.222-cp312-abi3-macosx_11_0_arm64.whl (503.7 kB view details)

Uploaded CPython 3.12+macOS 11.0+ ARM64

File details

Details for the file cle-9.2.222.tar.gz.

File metadata

  • Download URL: cle-9.2.222.tar.gz
  • Upload date:
  • Size: 423.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.13

File hashes

Hashes for cle-9.2.222.tar.gz
Algorithm Hash digest
SHA256 e17a65805ae93ecba8d94ec6cf4030760981529f9f63337a9126509f746e73fa
MD5 ec761c45ac875eac4b8e81f65c94c7d6
BLAKE2b-256 63b356b6c61932a67c3b92d94858527b7163f9f794ac7f1ed500e9e45c2f7197

See more details on using hashes here.

Provenance

The following attestation bundles were made for cle-9.2.222.tar.gz:

Publisher: angr-release.yml on angr/ci-settings

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file cle-9.2.222-cp312-abi3-win_amd64.whl.

File metadata

  • Download URL: cle-9.2.222-cp312-abi3-win_amd64.whl
  • Upload date:
  • Size: 483.3 kB
  • Tags: CPython 3.12+, Windows x86-64
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.13

File hashes

Hashes for cle-9.2.222-cp312-abi3-win_amd64.whl
Algorithm Hash digest
SHA256 210031f6573bdba5359a1537156920c3090b4a5bb5a84584a9b3025e8968d7f2
MD5 f189b9c836e822b9fc4737ab40ce5963
BLAKE2b-256 f55d7c27f783129daee9fb26f39419c0616fee79c4f72a096c993025ea3e62b3

See more details on using hashes here.

Provenance

The following attestation bundles were made for cle-9.2.222-cp312-abi3-win_amd64.whl:

Publisher: angr-release.yml on angr/ci-settings

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file cle-9.2.222-cp312-abi3-musllinux_1_2_x86_64.whl.

File metadata

File hashes

Hashes for cle-9.2.222-cp312-abi3-musllinux_1_2_x86_64.whl
Algorithm Hash digest
SHA256 93ef52f30a2c21d2ebff888fc97beb7e26884b08e720bc5badbc8213720c2795
MD5 a7d7028c5a35df1b83e6cacacddd9027
BLAKE2b-256 2ed4b392a14613cfbeff00d64471dc538f30d851045c3e2613c5ce04790f514c

See more details on using hashes here.

Provenance

The following attestation bundles were made for cle-9.2.222-cp312-abi3-musllinux_1_2_x86_64.whl:

Publisher: angr-release.yml on angr/ci-settings

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file cle-9.2.222-cp312-abi3-musllinux_1_2_aarch64.whl.

File metadata

File hashes

Hashes for cle-9.2.222-cp312-abi3-musllinux_1_2_aarch64.whl
Algorithm Hash digest
SHA256 23a58dfe315a0ef0a3c7c371b7fe460e3b341fe1deb4d73c48eaf1320f48aa74
MD5 7dcc8dc0452a7aae530cba881f873325
BLAKE2b-256 fceb28a03b074596c6fcf053602947b97e69dfbfbc0655426599cc895650b1c7

See more details on using hashes here.

Provenance

The following attestation bundles were made for cle-9.2.222-cp312-abi3-musllinux_1_2_aarch64.whl:

Publisher: angr-release.yml on angr/ci-settings

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file cle-9.2.222-cp312-abi3-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for cle-9.2.222-cp312-abi3-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 8495eb64e2622de533f2ff79b5c06ad37b4c11b56867342ba13425507ff06fb1
MD5 be5c47405b622debbc959c39b69bbf6c
BLAKE2b-256 4a13b4ace9ac5eb9b984a13d09a27afed7ff34f0ee06cc8f78545586ead43f82

See more details on using hashes here.

Provenance

The following attestation bundles were made for cle-9.2.222-cp312-abi3-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl:

Publisher: angr-release.yml on angr/ci-settings

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file cle-9.2.222-cp312-abi3-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl.

File metadata

File hashes

Hashes for cle-9.2.222-cp312-abi3-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 c52cda81d0fa5913582f6eeca39323402915a3942ad2c120a11b7f00d7b32283
MD5 4c150497307b0b3711738a1f6f9a0dd0
BLAKE2b-256 5a6b4e41efc5cbe5e2350c2dd9e0661760997c253dac77e4d73b3f2cdb7086f9

See more details on using hashes here.

Provenance

The following attestation bundles were made for cle-9.2.222-cp312-abi3-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl:

Publisher: angr-release.yml on angr/ci-settings

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file cle-9.2.222-cp312-abi3-macosx_11_0_arm64.whl.

File metadata

  • Download URL: cle-9.2.222-cp312-abi3-macosx_11_0_arm64.whl
  • Upload date:
  • Size: 503.7 kB
  • Tags: CPython 3.12+, macOS 11.0+ ARM64
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.13

File hashes

Hashes for cle-9.2.222-cp312-abi3-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 837bd2f8b3090ee8b6d0ee1a7713dfbe64af2338a703a9adecd817f2ff330d67
MD5 9ba6ac1655e125c3858c26358a310af3
BLAKE2b-256 ab31c8da0f2e96b7924bd12ea5b4b753f2546657c7a8b377efe5dffb2b1926f5

See more details on using hashes here.

Provenance

The following attestation bundles were made for cle-9.2.222-cp312-abi3-macosx_11_0_arm64.whl:

Publisher: angr-release.yml on angr/ci-settings

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page