diff --git a/pe/superpe.py b/pe/superpe.py index 5f3619c..5cd81af 100644 --- a/pe/superpe.py +++ b/pe/superpe.py @@ -120,6 +120,12 @@ class SuperPe(): self.pe.set_bytes_at_offset(sect.PointerToRawData, data) + def patch_subsystem(self): + if self.pe.OPTIONAL_HEADER.Subsystem != pefile.SUBSYSTEM_TYPE['IMAGE_SUBSYSTEM_WINDOWS_GUI']: + logger.info("EXE is not a GUI application. Patching subsystem to GUI") + self.pe.OPTIONAL_HEADER.Subsystem = pefile.SUBSYSTEM_TYPE['IMAGE_SUBSYSTEM_WINDOWS_GUI'] + + ## PE Specific Information def get_base_relocs(self) -> List[PeRelocEntry]: diff --git a/phases/injector.py b/phases/injector.py index 372dbba..318f79e 100644 --- a/phases/injector.py +++ b/phases/injector.py @@ -112,6 +112,9 @@ def inject_exe( injected_fix_iat(superpe, project.carrier, project.exe_host) injected_fix_data(superpe, project.carrier, project.exe_host) + # changes from console to UI (no console window) if necessary + superpe.patch_subsystem() + # We done superpe.write_pe_to_file(exe_out)