Skip to content

Commit

Permalink
Only print checksec output of ELF.libc when it was printed for th…
Browse files Browse the repository at this point in the history
…e `ELF` already (Gallopsled#2483)

* Only print `checksec` output of `ELF.libc` when it was printed for the `ELF` already

* Update CHANGELOG
  • Loading branch information
peace-maker committed Oct 26, 2024
1 parent 5196296 commit 2d3ce8e
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@ The table below shows which release corresponds to each branch, and what date th
- [#2413][2413] libcdb: improve the search speed of `search_by_symbol_offsets` in local libc-database
- [#2470][2470] Fix waiting for gdb under WSL2
- [#2479][2479] Support extracting libraries from Docker image in `pwn template`
- [#2483][2483] Only print `checksec` output of `ELF.libc` when it was printed for the `ELF` already

[2471]: https://github.com/Gallopsled/pwntools/pull/2471
[2358]: https://github.com/Gallopsled/pwntools/pull/2358
Expand All @@ -88,6 +89,7 @@ The table below shows which release corresponds to each branch, and what date th
[2413]: https://github.com/Gallopsled/pwntools/pull/2413
[2470]: https://github.com/Gallopsled/pwntools/pull/2470
[2479]: https://github.com/Gallopsled/pwntools/pull/2479
[2483]: https://github.com/Gallopsled/pwntools/pull/2483

## 4.14.0 (`beta`)

Expand Down
4 changes: 3 additions & 1 deletion pwnlib/elf/elf.py
Original file line number Diff line number Diff line change
Expand Up @@ -358,6 +358,7 @@ def __init__(self, path, checksec=True):
self._populate_functions()
self._populate_kernel_version()

self._print_checksec = checksec
if checksec:
self._describe()

Expand Down Expand Up @@ -730,12 +731,13 @@ def libc(self):
""":class:`.ELF`: If this :class:`.ELF` imports any libraries which contain ``'libc[.-]``,
and we can determine the appropriate path to it on the local
system, returns a new :class:`.ELF` object pertaining to that library.
Prints the `checksec` output of the library if it was printed for the original ELF too.
If not found, the value will be :const:`None`.
"""
for lib in self.libs:
if '/libc.' in lib or '/libc-' in lib:
return ELF(lib)
return ELF(lib, self._print_checksec)

def _populate_libraries(self):
"""
Expand Down

0 comments on commit 2d3ce8e

Please sign in to comment.