From cd0c34a6ed8a92ff0f83b0d4cbae8ea0f8f8af4a Mon Sep 17 00:00:00 2001 From: Florian Kothmeier <79159689+FlorianKothmeier@users.noreply.github.com> Date: Sat, 30 Dec 2023 19:35:29 +0100 Subject: [PATCH] Make pwn template always set context.binary (#2279) * Make pwn template always set context.binary * Update CHANGELOG.md * Allow args.EXE override in all templates * Fall back to old behavior for remote only challenges --------- Co-authored-by: peace-maker --- CHANGELOG.md | 2 ++ pwnlib/data/templates/pwnup.mako | 6 +----- 2 files changed, 3 insertions(+), 5 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index b60a9a9dc..06d16837c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -78,6 +78,7 @@ The table below shows which release corresponds to each branch, and what date th - [#2307][2307] Fix `pwn libcdb file` crashing if "/bin/sh" string was not found - [#2309][2309] Detect challenge binary and libc in `pwn template` - [#2308][2308] Fix WinExec shellcraft to make sure it's 16 byte aligned +- [#2279][2279] Make `pwn template` always set context.binary [2242]: https://github.com/Gallopsled/pwntools/pull/2242 [2277]: https://github.com/Gallopsled/pwntools/pull/2277 @@ -87,6 +88,7 @@ The table below shows which release corresponds to each branch, and what date th [2307]: https://github.com/Gallopsled/pwntools/pull/2307 [2309]: https://github.com/Gallopsled/pwntools/pull/2309 [2308]: https://github.com/Gallopsled/pwntools/pull/2308 +[2279]: https://github.com/Gallopsled/pwntools/pull/2279 ## 4.12.0 (`beta`) diff --git a/pwnlib/data/templates/pwnup.mako b/pwnlib/data/templates/pwnup.mako index e47217036..28c670869 100644 --- a/pwnlib/data/templates/pwnup.mako +++ b/pwnlib/data/templates/pwnup.mako @@ -44,7 +44,7 @@ from pwn import * %if not quiet: # Set up pwntools for the correct architecture %endif -%if ctx.binary: +%if ctx.binary or not host: exe = context.binary = ELF(args.EXE or ${binary_repr}) <% binary_repr = 'exe.path' %> %else: @@ -99,11 +99,7 @@ else: %endif library_path = libcdb.download_libraries(${libc_repr}) if library_path: - %if ctx.binary: exe = context.binary = ELF.patch_custom_libraries(${binary_repr}, library_path) - %else: - exe = ELF.patch_custom_libraries(exe, library_path) - %endif libc = exe.libc else: libc = ELF(${libc_repr})