Skip to content

Commit

Permalink
Update libcdb debuginfod default URL to federating server (#2101)
Browse files Browse the repository at this point in the history
* Switch to federated debuginfod service

elfutils.org offers a federating proxy server which forwards the requests to all other debuginfod servers of the different linux distributions.

https://sourceware.org/elfutils/Debuginfod.html

Use that instead by default to increase our successrate and potentially include new servers automatically once the distro sets one up.

* Use DEBUGINFOD_URLS envvar for server selection

The `DEBUGINFOD_URLS` environment variable is what you use for your normal debuginfod setup to tell it where to look for debug symbols.

Parse it as well and prepend it to the list of servers to try to allow for dynamic adjusting of the target servers.
  • Loading branch information
peace-maker authored Sep 25, 2022
1 parent 302a4ef commit 7d1dae1
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion pwnlib/libcdb.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,11 @@
log = getLogger(__name__)

HASHES = ['build_id', 'sha1', 'sha256', 'md5']
DEBUGINFOD_SERVERS = ['https://debuginfod.systemtap.org/']
DEBUGINFOD_SERVERS = ['https://debuginfod.elfutils.org/']

if 'DEBUGINFOD_URLS' in os.environ:
urls = os.environ['DEBUGINFOD_URLS'].split(' ')
DEBUGINFOD_SERVERS = urls + DEBUGINFOD_SERVERS

# https://gitlab.com/libcdb/libcdb wasn't updated after 2019,
# but still is a massive database of older libc binaries.
Expand Down Expand Up @@ -228,6 +232,8 @@ def unstrip_libc(filename):
log.warn_once('Given libc does not have a buildid. Cannot look for debuginfo to unstrip.')
return False

log.debug('Trying debuginfod servers: %r', DEBUGINFOD_SERVERS)

for server_url in DEBUGINFOD_SERVERS:
libc_dbg = _search_debuginfo_by_hash(server_url, enhex(libc.buildid))
if libc_dbg:
Expand Down

0 comments on commit 7d1dae1

Please sign in to comment.