pwnlib.libcdb — Libc Database

Fetch a LIBC binary based on some heuristics.

pwnlib.libcdb.get_build_id_offsets()[source]

Returns a list of file offsets where the Build ID should reside within an ELF file of the currentlys-elected architecture.

pwnlib.libcdb.search_by_build_id(hex_encoded_id)[source]

Given a hex-encoded Build ID, attempt to download a matching libc from libcdb.

Parameters:hex_encoded_id (str) – Hex-encoded Build ID (e.g. ‘ABCDEF…’) of the library
Returns:Path to the downloaded library on disk, or None.

Examples

>>> filename = search_by_build_id('fe136e485814fee2268cf19e5c124ed0f73f4400')
>>> hex(ELF(filename).symbols.read)
'0xda260'
>>> None == search_by_build_id('XX')
True
pwnlib.libcdb.search_by_sha1(hex_encoded_id)[source]

Given a hex-encoded sha1, attempt to download a matching libc from libcdb.

Parameters:hex_encoded_id (str) – Hex-encoded Build ID (e.g. ‘ABCDEF…’) of the library
Returns:Path to the downloaded library on disk, or None.

Examples

>>> filename = search_by_sha1('34471e355a5e71400b9d65e78d2cd6ce7fc49de5')
>>> hex(ELF(filename).symbols.read)
'0xda260'
>>> None == search_by_sha1('XX')
True
pwnlib.libcdb.search_by_sha256(hex_encoded_id)[source]

Given a hex-encoded sha256, attempt to download a matching libc from libcdb.

Parameters:hex_encoded_id (str) – Hex-encoded Build ID (e.g. ‘ABCDEF…’) of the library
Returns:Path to the downloaded library on disk, or None.

Examples

>>> filename = search_by_sha256('5e877a8272da934812d2d1f9ee94f73c77c790cbc5d8251f5322389fc9667f21')
>>> hex(ELF(filename).symbols.read)
'0xda260'
>>> None == search_by_sha256('XX')
True
pwnlib.libcdb.search_by_md5(hex_encoded_id)[source]

Given a hex-encoded md5sum, attempt to download a matching libc from libcdb.

Parameters:hex_encoded_id (str) – Hex-encoded Build ID (e.g. ‘ABCDEF…’) of the library
Returns:Path to the downloaded library on disk, or None.

Examples

>>> filename = search_by_md5('7a71dafb87606f360043dcd638e411bd')
>>> hex(ELF(filename).symbols.read)
'0xda260'
>>> None == search_by_build_id('XX')
True