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 currently selected 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 >>> filename = search_by_build_id('a5a3c3f65fd94f4c7f323a175707c3a79cbbd614') >>> hex(ELF(filename).symbols.read) '0xeef40'
- 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 md5sum (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_md5('XX') True >>> filename = search_by_md5('74f2d3062180572fc8bcd964b587eeae') >>> hex(ELF(filename).symbols.read) '0xeef40'
- 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 sha1sum (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 >>> filename = search_by_sha1('0041d2f397bc2498f62aeb4134d522c5b2635e87') >>> hex(ELF(filename).symbols.read) '0xeef40'
- 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 sha256sum (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 >>> filename = search_by_sha256('5d78fc60054df18df20480c71f3379218790751090f452baffb62ac6b2aff7ee') >>> hex(ELF(filename).symbols.read) '0xeef40'