mirror of
https://github.com/dobin/SuperMega
synced 2026-06-02 17:27:10 +00:00
refactor: make web work again (split project <-> settings)
This commit is contained in:
+1
-2
@@ -13,14 +13,13 @@ PATH_EXES_MORE = "data/binary/exes_more/"
|
||||
PATH_DLLS = "data/binary/dlls/"
|
||||
PATH_SHELLCODES = "data/binary/shellcodes/"
|
||||
PATH_CARRIER = "data/source/carrier/"
|
||||
PATH_PAYLOAD = "data/source/payload/"
|
||||
|
||||
PATH_DECODER = "data/source/decoder/"
|
||||
PATH_ANTIEMULATION = "data/source/antiemulation/"
|
||||
PATH_DECOY = "data/source/decoy/"
|
||||
PATH_GUARDRAILS = "data/source/guardrails/"
|
||||
PATH_VIRTUALPROTECT = "data/source/virtualprotect/"
|
||||
|
||||
PATH_PAYLOAD = "data/source/payload/"
|
||||
PATH_WEB_PROJECT = "projects/"
|
||||
|
||||
|
||||
|
||||
+14
-14
@@ -1,5 +1,4 @@
|
||||
import logging
|
||||
import shutil
|
||||
|
||||
from model.defs import *
|
||||
from model.payload import Payload
|
||||
@@ -9,31 +8,32 @@ from model.injectable import Injectable
|
||||
logger = logging.getLogger("Project")
|
||||
|
||||
|
||||
class WebProject():
|
||||
def __init__(self, name: str, settings: Settings):
|
||||
self.name = name
|
||||
self.settings: Settings = settings
|
||||
self.comment: str = ""
|
||||
|
||||
|
||||
class Project():
|
||||
def __init__(self, settings: Settings):
|
||||
self.name: str = ""
|
||||
self.comment: str = ""
|
||||
self.settings: Settings = settings
|
||||
self.payload: Payload = Payload(self.settings.payload_path)
|
||||
self.injectable: Injectable = Injectable(self.settings.inject_exe_in)
|
||||
|
||||
self.project_dir: str = ""
|
||||
self.project_exe: str = ""
|
||||
# Set by init()
|
||||
self.payload: Payload
|
||||
self.injectable: Injectable
|
||||
|
||||
|
||||
def init(self) -> bool:
|
||||
self.payload: Payload = Payload(self.settings.get_payload_path())
|
||||
self.injectable: Injectable = Injectable(self.settings.get_inject_exe_in())
|
||||
|
||||
if not self.payload.init():
|
||||
return False
|
||||
if not self.injectable.init():
|
||||
return False
|
||||
return True
|
||||
|
||||
|
||||
def print(self):
|
||||
logger.info("Project Name: {}".format(self.settings.project_name))
|
||||
logger.info("Comment: {}".format(self.settings.project_comment))
|
||||
logger.info("Settings: {}".format(self.settings.__dict__))
|
||||
logger.info("Payload Path: {}".format(self.payload.payload_path))
|
||||
logger.info("Injectable Path: {}".format(self.injectable.exe_filepath))
|
||||
|
||||
|
||||
def prepare_project(project_name, settings):
|
||||
|
||||
+48
-42
@@ -7,33 +7,46 @@ logger = logging.getLogger("Views")
|
||||
class Settings():
|
||||
def __init__(self, project_name: str = "default"):
|
||||
self.project_name: str = project_name
|
||||
self.payload_path: FilePath = FilePath("")
|
||||
self.project_comment: str = ""
|
||||
self.project_path: FilePath = FilePath("{}{}/".format(PATH_WEB_PROJECT, self.project_name))
|
||||
|
||||
# Settings
|
||||
# OUT: Project directories and files (based on project_path)
|
||||
self.project_c_path: FilePath = FilePath(self.project_path + "main.c")
|
||||
self.project_asm_path: FilePath = FilePath(self.project_path + "main.asm")
|
||||
self.project_exe_path: FilePath = FilePath(self.project_path + "main.exe")
|
||||
self.project_shc_path: FilePath = FilePath(self.project_path + "main.bin")
|
||||
|
||||
# IN: Injectable (like "7z.exe", in data/input/exes/)
|
||||
self.injectable_base: str = ""
|
||||
# IN: Payload / Shellcode (like "createfile.bin", in data/input/shellcodes/)
|
||||
self.payload_base: str = ""
|
||||
|
||||
# Config
|
||||
self.carrier_name: str = ""
|
||||
self.carrier_invoke_style: CarrierInvokeStyle = CarrierInvokeStyle.BackdoorCallInstr
|
||||
self.decoder_style: str = "xor_2"
|
||||
self.payload_location: PayloadLocation = PayloadLocation.DATA
|
||||
self.short_call_patching: bool = False
|
||||
self.fix_missing_iat = True
|
||||
self.patch_show_window = True
|
||||
self.dllfunc: str = "" # For DLL injection
|
||||
|
||||
self.plugin_antiemulation: str = "none"
|
||||
self.plugin_decoy: str = "none"
|
||||
# PLUGIN: Guardrail
|
||||
self.plugin_guardrail: str = "none"
|
||||
self.plugin_guardrail_data_key: str = ""
|
||||
self.plugin_guardrail_data_value: str = ""
|
||||
self.plugin_virtualprotect: str = "standard"
|
||||
self.plugin_virtualprotect_data: str = ""
|
||||
|
||||
self.dllfunc: str = "" # For DLL injection
|
||||
|
||||
# Anti-debugging
|
||||
# PLUGIN: Anti-Emulation / EDR deconditioner
|
||||
self.plugin_antiemulation: str = "none"
|
||||
self.sir_iteration_count: int = 5
|
||||
self.sir_alloc_count: int = 100
|
||||
|
||||
# Injectable
|
||||
self.carrier_invoke_style: CarrierInvokeStyle = CarrierInvokeStyle.BackdoorCallInstr
|
||||
self.inject_exe_in: FilePath = FilePath("")
|
||||
self.inject_exe_out: FilePath = FilePath("")
|
||||
# PLUGIN: Other (not widely used or important)
|
||||
self.plugin_virtualprotect: str = "standard"
|
||||
self.plugin_virtualprotect_data: str = ""
|
||||
self.plugin_decoy: str = "none"
|
||||
|
||||
# Debug
|
||||
# DEBUG: Debug stuff (for development)
|
||||
self.show_command_output: bool = False
|
||||
self.verify: bool = False
|
||||
self.try_start_final_infected_exe: bool = False
|
||||
@@ -41,33 +54,26 @@ class Settings():
|
||||
self.cleanup_files_on_exit: bool = True
|
||||
self.generate_asm_from_c: bool = True
|
||||
|
||||
# More
|
||||
self.fix_missing_iat = True
|
||||
self.patch_show_window = True
|
||||
self.payload_location: PayloadLocation = PayloadLocation.DATA
|
||||
|
||||
# directories and filenames
|
||||
self.main_dir: FilePath = FilePath("{}{}/".format(PATH_WEB_PROJECT, self.project_name))
|
||||
self.main_c_path: FilePath = FilePath(self.main_dir + "main.c")
|
||||
self.main_asm_path: FilePath = FilePath(self.main_dir + "main.asm")
|
||||
self.main_exe_path: FilePath = FilePath(self.main_dir + "main.exe")
|
||||
self.main_shc_path: FilePath = FilePath(self.main_dir + "main.bin")
|
||||
self.inject_exe_out: FilePath = FilePath("{}{}".format(
|
||||
self.main_dir, os.path.basename(self.inject_exe_in).replace(".exe", ".infected.exe")))
|
||||
|
||||
|
||||
def init_payload_injectable(self, shellcode: FilePath, injectable: FilePath, dll_func: str ):
|
||||
self.payload_path = FilePath(PATH_SHELLCODES + shellcode)
|
||||
if shellcode == "createfile.bin":
|
||||
self.verify = True
|
||||
self.try_start_final_infected_exe = False
|
||||
else:
|
||||
self.cleanup_files_on_exit = False
|
||||
|
||||
self.inject_exe_in = FilePath(PATH_EXES + injectable)
|
||||
self.inject_exe_out = FilePath("{}{}".format(
|
||||
self.main_dir,
|
||||
os.path.basename(self.inject_exe_in).replace(".exe", ".infected.exe")
|
||||
def get_payload_path(self) -> FilePath:
|
||||
if self.payload_base == "":
|
||||
return None
|
||||
return FilePath(PATH_SHELLCODES + self.payload_base)
|
||||
|
||||
def get_inject_exe_in(self) -> FilePath:
|
||||
if self.injectable_base == "":
|
||||
return None
|
||||
return FilePath(PATH_EXES + self.injectable_base)
|
||||
|
||||
def get_inject_exe_out(self) -> FilePath:
|
||||
return FilePath("{}{}".format(
|
||||
self.project_path,
|
||||
self.injectable_base.replace(".exe", ".infected.exe")
|
||||
))
|
||||
|
||||
self.dllfunc = dll_func
|
||||
def print(self):
|
||||
logger.info("Settings for project: {}".format(self.project_name))
|
||||
for attr, value in self.__dict__.items():
|
||||
if isinstance(value, FilePath):
|
||||
value = str(value)
|
||||
logger.info(" {}: {}".format(attr, value))
|
||||
logger.info("-" * 40)
|
||||
Reference in New Issue
Block a user