From 865cfb5247646d1be50106494ebd541e511d59ca Mon Sep 17 00:00:00 2001 From: Dobin Date: Thu, 8 Feb 2024 10:55:14 +0000 Subject: [PATCH] refactor: make inject mode configurable --- helper.py | 1 + phases/shctoexe.py | 4 ++-- supermega.py | 13 +++++++++++-- 3 files changed, 14 insertions(+), 4 deletions(-) diff --git a/helper.py b/helper.py index 8c3880a..3bff2cd 100644 --- a/helper.py +++ b/helper.py @@ -32,6 +32,7 @@ def clean_files(): os.path.join(build_dir, "main.asm"), os.path.join(build_dir, "main.bin"), os.path.join(build_dir, "main.c"), + os.path.join(build_dir, "peb_lookup.h"), #os.path.join(build_dir, "main.exe"), verify_filename, diff --git a/phases/shctoexe.py b/phases/shctoexe.py index 4d3853d..3a6d72c 100644 --- a/phases/shctoexe.py +++ b/phases/shctoexe.py @@ -2,7 +2,7 @@ from helper import * import shutil -def inject_exe(shc_file, exe_in, exe_out): +def inject_exe(shc_file, exe_in, exe_out, mode): print("--[ Injecting: {} into: {} -> {} ]".format( shc_file, exe_in, exe_out )) @@ -12,7 +12,7 @@ def inject_exe(shc_file, exe_in, exe_out): subprocess.run([ "python3.exe", "redbackdoorer.py", - "1,1", + mode, shc_file, exe_out ], check=True, stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL) diff --git a/supermega.py b/supermega.py index 4bcc4b6..90d5258 100644 --- a/supermega.py +++ b/supermega.py @@ -35,6 +35,12 @@ options_default = { "copy_style": CopyStyle.SIMPLE, "dataref_style": DataRefStyle.APPEND, + # injecting into exe + "inject_exe": True, + "inject_mode": "1,1", + "inject_exe_in": "exes/procexp64.exe", + "inject_exe_out": "out/procexp64-a.exe", + "try_start_loader_shellcode": False, # without payload (Debugging) "try_start_final_shellcode": False, # with payload (should work) "try_start_final_infected_exe": True, # with payload (should work) @@ -75,6 +81,7 @@ options_verify = { # injecting into exe "inject_exe": True, + "inject_mode": "1,1", "inject_exe_in": "exes/procexp64.exe", "inject_exe_out": "out/procexp64-a.exe", @@ -84,13 +91,15 @@ options_verify = { # cleanup "cleanup_files_on_start": True, - "cleanup_files_on_exit": False, # all is just in out/ + "cleanup_files_on_exit": True, # all is just in out/ # doesnt work "obfuscate_shc_loader": False, "test_obfuscated_shc": False, } + + options = None main_c_file = os.path.join(build_dir, "main.c") @@ -201,7 +210,7 @@ def main(): if options["inject_exe"]: debug_data["original_exe"] = file_readall_binary(options["inject_exe_in"]) - inject_exe(main_shc_file, options["inject_exe_in"], options["inject_exe_out"]) + inject_exe(main_shc_file, options["inject_exe_in"], options["inject_exe_out"], options["inject_mode"]) if options["verify"]: print("--[ Verify final exe ]") if verify_injected_exe(options["inject_exe_out"]):