From 2c9a20d8228f50900a9f5f2a57ace905fa99f792 Mon Sep 17 00:00:00 2001 From: Dobin Date: Sun, 5 May 2024 13:38:08 +0100 Subject: [PATCH] feature: make exe to UI --- pe/superpe.py | 6 ++++++ phases/injector.py | 3 +++ 2 files changed, 9 insertions(+) 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)