From 179f4b3439bb6a982bd16a264cf3f57d447fbb86 Mon Sep 17 00:00:00 2001 From: bitraid Date: Mon, 13 Apr 2020 21:38:22 +0300 Subject: [PATCH 1/2] Don't use --strip-reloc with -d Always restore the relocation section of Portable Executables on unpacking, if it exists in the compressed image. --- src/pefile.cpp | 16 ++-------------- 1 file changed, 2 insertions(+), 14 deletions(-) diff --git a/src/pefile.cpp b/src/pefile.cpp index 571c3529..1988321f 100644 --- a/src/pefile.cpp +++ b/src/pefile.cpp @@ -2693,15 +2693,7 @@ void PeFile::rebuildRelocs(upx_byte *& extrainfo, unsigned bits, } rel.finish (oxrelocs,soxrelocs); - if (opt->win32_pe.strip_relocs && !isdll) - { - obuf.clear(ODADDR(PEDIR_RELOC) - rvamin, ODSIZE(PEDIR_RELOC)); - ODADDR(PEDIR_RELOC) = 0; - soxrelocs = 0; - // FIXME: try to remove the original relocation section somehow - } - else - omemcpy(obuf + ODADDR(PEDIR_RELOC) - rvamin,oxrelocs,soxrelocs); + omemcpy(obuf + ODADDR(PEDIR_RELOC) - rvamin,oxrelocs,soxrelocs); delete [] oxrelocs; oxrelocs = NULL; wrkmem.dealloc(); @@ -2933,12 +2925,8 @@ void PeFile::unpack0(OutputFile *fo, const ht &ih, ht &oh, ft.unfilter(obuf + oh.codebase - rvamin, oh.codesize); } - //NEW: disable reloc stripping if ASLR is enabled - if(ih.dllflags & IMAGE_DLL_CHARACTERISTICS_DYNAMIC_BASE) - opt->win32_pe.strip_relocs = false; - // FIXME: ih.flags is checked here because of a bug in UPX 0.92 - if ((opt->win32_pe.strip_relocs && !isdll) || (ih.flags & RELOCS_STRIPPED)) + if (ih.flags & RELOCS_STRIPPED) { oh.flags |= RELOCS_STRIPPED; ODADDR(PEDIR_RELOC) = 0; From 78c3f58f508e6013c4707a4cc8d3cdad85f0b0cb Mon Sep 17 00:00:00 2001 From: "Markus F.X.J. Oberhumer" Date: Sat, 23 May 2020 20:07:23 +0200 Subject: [PATCH 2/2] Use "python2" instead of "python". --- src/p_lx_sh.cpp | 2 +- src/stub/Makefile | 2 +- src/stub/scripts/bin2h.py | 2 +- src/stub/scripts/brandelf.py | 2 +- src/stub/scripts/gpp_inc.py | 2 +- src/stub/scripts/xstrip.py | 2 +- src/stub/src/arch/i086/cleanasm.py | 2 +- src/stub/src/arch/i086/wdis2gas.py | 2 +- 8 files changed, 8 insertions(+), 8 deletions(-) diff --git a/src/p_lx_sh.cpp b/src/p_lx_sh.cpp index 70e6fdc3..30c60dcc 100644 --- a/src/p_lx_sh.cpp +++ b/src/p_lx_sh.cpp @@ -114,7 +114,7 @@ bool PackLinuxI386sh::getShellName(char *buf) buf[l_shname] = 0; static char const *const shname[] = { // known shells that accept "-c" arg "ash", "bash", "bsh", "csh", "ksh", "pdksh", "sh", "tcsh", "zsh", - "python", + "python", "python2", "python3", NULL }; const char *bname = strrchr(buf, '/'); diff --git a/src/stub/Makefile b/src/stub/Makefile index 0add5541..134e0b2c 100644 --- a/src/stub/Makefile +++ b/src/stub/Makefile @@ -206,7 +206,7 @@ tc_objdump_disasm_options = ECHO_e = /bin/echo -e ECHO_E = /bin/echo -E PERL = perl -PYTHON = python +PYTHON = python2 UNIX2DOS := $(PERL) -i -pe 's/$$/\r/;' # trim (strip) trailing whitespace diff --git a/src/stub/scripts/bin2h.py b/src/stub/scripts/bin2h.py index d47e73d5..b30e3c89 100644 --- a/src/stub/scripts/bin2h.py +++ b/src/stub/scripts/bin2h.py @@ -1,4 +1,4 @@ -#! /usr/bin/env python +#! /usr/bin/env python2 ## vim:set ts=4 sw=4 et: -*- coding: utf-8 -*- # # bin2h.py -- diff --git a/src/stub/scripts/brandelf.py b/src/stub/scripts/brandelf.py index 508ee5f2..bcafb111 100644 --- a/src/stub/scripts/brandelf.py +++ b/src/stub/scripts/brandelf.py @@ -1,4 +1,4 @@ -#! /usr/bin/env python +#! /usr/bin/env python2 ## vim:set ts=4 sw=4 et: -*- coding: utf-8 -*- # # brandelf.py -- diff --git a/src/stub/scripts/gpp_inc.py b/src/stub/scripts/gpp_inc.py index f183fa51..3c0a9083 100644 --- a/src/stub/scripts/gpp_inc.py +++ b/src/stub/scripts/gpp_inc.py @@ -1,4 +1,4 @@ -#! /usr/bin/env python +#! /usr/bin/env python2 ## vim:set ts=4 sw=4 et: -*- coding: utf-8 -*- # # gpp_inc.py -- Generic PreProcessor: include diff --git a/src/stub/scripts/xstrip.py b/src/stub/scripts/xstrip.py index 29d2169f..2d8c07c3 100644 --- a/src/stub/scripts/xstrip.py +++ b/src/stub/scripts/xstrip.py @@ -1,4 +1,4 @@ -#! /usr/bin/env python +#! /usr/bin/env python2 ## vim:set ts=4 sw=4 et: -*- coding: utf-8 -*- # # xstrip.py -- truncate ELF objects created by multiarch-objcopy-2.17 diff --git a/src/stub/src/arch/i086/cleanasm.py b/src/stub/src/arch/i086/cleanasm.py index c10f2f87..605b4db4 100644 --- a/src/stub/src/arch/i086/cleanasm.py +++ b/src/stub/src/arch/i086/cleanasm.py @@ -1,4 +1,4 @@ -#! /usr/bin/env python +#! /usr/bin/env python2 ## vim:set ts=4 sw=4 et: -*- coding: utf-8 -*- # # cleanasm.py -- diff --git a/src/stub/src/arch/i086/wdis2gas.py b/src/stub/src/arch/i086/wdis2gas.py index b0a377d8..e99c7530 100644 --- a/src/stub/src/arch/i086/wdis2gas.py +++ b/src/stub/src/arch/i086/wdis2gas.py @@ -1,4 +1,4 @@ -#! /usr/bin/env python +#! /usr/bin/env python2 ## vim:set ts=4 sw=4 et: -*- coding: utf-8 -*- # # wdis2gas.py --