From e137ea36880da67e19a9830658d4222e47861f25 Mon Sep 17 00:00:00 2001 From: Winslow <33692631+senzee1984@users.noreply.github.com> Date: Thu, 11 Apr 2024 01:28:07 -0400 Subject: [PATCH] Update InflativeLoading.py --- InflativeLoading.py | 62 ++++++++++++++++++++++++++++++++++++--------- 1 file changed, 50 insertions(+), 12 deletions(-) diff --git a/InflativeLoading.py b/InflativeLoading.py index 325169a..90da7b7 100644 --- a/InflativeLoading.py +++ b/InflativeLoading.py @@ -3,6 +3,10 @@ from keystone import * import argparse import random + + + + def print_banner(): banner=""" ██╗███╗ ██╗███████╗██╗ █████╗ ████████╗██╗██╗ ██╗███████╗ @@ -119,6 +123,30 @@ def obfuscate_header(pe_header_array, segments): return obfuscated_header +def modify_pe_signatures(segments): + print("[!] Dynamically generated instructions to obfuscate remained PE signatures:") + instructions = [] + for segment in segments: + offset, size = next(iter(segment.items())) + # for segment, size in segments.items(): + if size == 2: # For WORD + random_value = random.getrandbits(16) + instruction = f" mov word ptr [rbx+{offset:#x}], {random_value:#04x};" + elif size == 4: # For DWORD + random_value = random.getrandbits(32) + instruction = f" mov dword ptr [rbx+{offset:#x}], {random_value:#08x};" + elif size == 8: # For QWORD + random_value1 = random.getrandbits(32) + random_value2 = random.getrandbits(32) + instruction = f" mov dword ptr [rbx+{offset:#x}], {random_value:#08x};\n mov dword ptr [rbx+{offset+4:#x}], {random_value2:#08x};" + else: + raise ValueError("Unsupported size for segment.") + instructions.append(instruction) + return "\n".join(instructions) + + + + if __name__ == "__main__": print_banner() parser = argparse.ArgumentParser(description='Dynamically generate shellcode stub to append to the dump file') @@ -133,7 +161,6 @@ if __name__ == "__main__": output = args.output sc_exec = args.sc_exec pe_array = read_dump_file(bin) - update_cmdline_asm = generate_asm_by_cmdline(cmdline) # Generate shellcode that used to update command line @@ -220,10 +247,30 @@ f"{update_cmdline_asm}" ) + + + + + + ks = Ks(KS_ARCH_X86, KS_MODE_64) encoding, count = ks.asm(CODE) CODE_LEN = len(encoding) + 25 CODE_OFFSET = 4096 - CODE_LEN + e_lfanew, = struct.unpack('