From e9d9bd9ddbf89f90a95311502a07639df542ca19 Mon Sep 17 00:00:00 2001 From: peace-maker Date: Sun, 26 Jan 2025 23:18:16 +0100 Subject: [PATCH 1/2] Fix installation on Python 3.5 and lower on stable (#2533) * Fix installation on Python 3.5 and lower on stable The unix-ar package requires Python 3.6. Only install it on Python 3.6 then and use the Python 2 fallback for Python <= 3.5 too. * Update CHANGELOG --- CHANGELOG.md | 6 ++++++ pwnlib/libcdb.py | 3 ++- pyproject.toml | 2 +- 3 files changed, 9 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index f809a8d24..27b122537 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -112,6 +112,12 @@ The table below shows which release corresponds to each branch, and what date th [2476]: https://github.com/Gallopsled/pwntools/pull/2476 [2364]: https://github.com/Gallopsled/pwntools/pull/2364 +## 4.14.1 + +- [#2533][2533] Fix installation on Python 3.5 and lower + +[2533]: https://github.com/Gallopsled/pwntools/pull/2533 + ## 4.14.0 (`stable`) - [#2356][2356] Add local libc database provider for libcdb diff --git a/pwnlib/libcdb.py b/pwnlib/libcdb.py index 3685465ed..9daeb4a99 100644 --- a/pwnlib/libcdb.py +++ b/pwnlib/libcdb.py @@ -8,6 +8,7 @@ import time import six import tempfile +import sys from pwnlib.context import context from pwnlib.elf import ELF @@ -419,7 +420,7 @@ def _extract_tarfile(cache_dir, data_filename, tarball): def _extract_debfile(cache_dir, package_filename, package): # Extract data.tar in the .deb archive. - if six.PY2: + if sys.version_info < (3, 6): if not which('ar'): log.error('Missing command line tool "ar" to extract .deb archive. Please install "ar" first.') diff --git a/pyproject.toml b/pyproject.toml index 1e394d838..2f4e687d9 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -56,7 +56,7 @@ dependencies = [ "colored_traceback<0.4; python_version < '3'", "colored_traceback; python_version >= '3'", "pathlib2; python_version < '3.4'", - "unix-ar; python_version >= '3'", + "unix-ar; python_version >= '3.6'", "zstandard", ] From b2345f214e0c2c260989646826559c234842832b Mon Sep 17 00:00:00 2001 From: Meetesh Saini <93069177+Meetesh-Saini@users.noreply.github.com> Date: Mon, 27 Jan 2025 03:58:14 +0530 Subject: [PATCH 2/2] fix: update apport coredump path handling for CorefileFinder (#2518) * fix: update apport coredump path handling for CorefileFinder * chore: update comment on Apport core path handling * Update CHANGELOG --------- Co-authored-by: Peace-Maker --- CHANGELOG.md | 2 ++ pwnlib/elf/corefile.py | 13 ++++++++++++- 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 27b122537..91079ac18 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -115,8 +115,10 @@ The table below shows which release corresponds to each branch, and what date th ## 4.14.1 - [#2533][2533] Fix installation on Python 3.5 and lower +- [#2518][2518] fix: update apport coredump path handling for CorefileFinder [2533]: https://github.com/Gallopsled/pwntools/pull/2533 +[2518]: https://github.com/Gallopsled/pwntools/pull/2518 ## 4.14.0 (`stable`) diff --git a/pwnlib/elf/corefile.py b/pwnlib/elf/corefile.py index 1cb8823fa..f092153c1 100644 --- a/pwnlib/elf/corefile.py +++ b/pwnlib/elf/corefile.py @@ -1510,7 +1510,18 @@ def apport_coredump(self): # should be unique enough that we can just glob. boot_id = read('/proc/sys/kernel/random/boot_id').strip().decode() - path = self.exe.replace('/', '_') + + # Use the absolute path of the executable + # Apport uses the executable's path to determine the core dump filename + # + # Reference source: + # https://github.com/canonical/apport/blob/4bbb179b8f92989bf7c1ee3692074f35d70ef3e8/data/apport#L110 + # https://github.com/canonical/apport/blob/4bbb179b8f92989bf7c1ee3692074f35d70ef3e8/apport/fileutils.py#L599 + # + # Apport calls `get_core_path` with `options.executable_path`, which corresponds to + # the executable's pathname, as specified by the `%E` placeholder + # in the core pattern (see `man core` and `apport --help`). + path = os.path.abspath(self.exe).replace('/', '_').replace('.', '_') # Format the name corefile_name = 'core.{path}.{uid}.{boot_id}.{pid}.*'.format(