From 75cc3c3d5cd1e4d03dee1cf31ba67dd8139b941c Mon Sep 17 00:00:00 2001 From: Swastik Sarkar <40518186+sswastik02@users.noreply.github.com> Date: Sun, 24 Mar 2024 17:49:31 +0530 Subject: [PATCH] libcdb.unstrip_libc: debug symbols are fetched only if not present (#2374) * libcdb.unstrip_libc: debug symbols are fetched only if not present * Usage of `ELF.debuginfo` to check if debug symbols exist closes #2324 --------- Signed-off-by: sswastik02 <40518186+sswastik02@users.noreply.github.com> * Add CHANGELOG Signed-off-by: sswastik02 <40518186+sswastik02@users.noreply.github.com> --------- Signed-off-by: sswastik02 <40518186+sswastik02@users.noreply.github.com> --- CHANGELOG.md | 2 ++ pwnlib/libcdb.py | 4 ++++ 2 files changed, 6 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index e253c3cf3..2bd84bd4c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -72,8 +72,10 @@ The table below shows which release corresponds to each branch, and what date th ## 4.14.0 (`dev`) - [#2356][2356] Add local libc database provider for libcdb +- [#2374][2374] libcdb.unstrip_libc: debug symbols are fetched only if not present [2356]: https://github.com/Gallopsled/pwntools/pull/2356 +[2374]: https://github.com/Gallopsled/pwntools/pull/2374 ## 4.13.0 (`beta`) diff --git a/pwnlib/libcdb.py b/pwnlib/libcdb.py index 329ed187f..0902c40d6 100644 --- a/pwnlib/libcdb.py +++ b/pwnlib/libcdb.py @@ -291,6 +291,10 @@ def unstrip_libc(filename): log.warn_once('Given libc does not have a buildid. Cannot look for debuginfo to unstrip.') return False + if libc.debuginfo: + log.debug('Given libc already contains debug information. Skipping unstrip.') + return True + log.debug('Trying debuginfod servers: %r', DEBUGINFOD_SERVERS) for server_url in DEBUGINFOD_SERVERS: