mirror of
https://github.com/dobin/SuperMega
synced 2026-06-02 17:27:10 +00:00
refactor: syntax, types, logging, cleanup
This commit is contained in:
+7
-2
@@ -46,8 +46,13 @@ class Injectable():
|
||||
self.exe_filepath: str = exe_file
|
||||
self.superpe: SuperPe = None
|
||||
|
||||
def init(self):
|
||||
def init(self) -> bool:
|
||||
# check if file exists
|
||||
if not os.path.exists(self.exe_filepath):
|
||||
logger.error("Injectable file does not exist: {}".format(self.exe_filepath))
|
||||
return False
|
||||
self.superpe = SuperPe(self.exe_filepath)
|
||||
return True
|
||||
|
||||
|
||||
# IAT
|
||||
@@ -77,7 +82,7 @@ class Injectable():
|
||||
# Data Reuse
|
||||
|
||||
def add_datareuse_fixup(self, fixup: DataReuseEntry):
|
||||
logger.info("---( Add datareuse: {}".format(fixup.string_ref))
|
||||
logger.debug("---( Add datareuse: {}".format(fixup.string_ref))
|
||||
self.reusedata_fixups.append(fixup)
|
||||
|
||||
def get_all_reusedata_fixups(self) -> List[DataReuseEntry]:
|
||||
|
||||
+7
-2
@@ -12,8 +12,13 @@ class Payload():
|
||||
self.payload_data: bytes = b""
|
||||
|
||||
|
||||
def init(self):
|
||||
logging.info("--( Load payload: {}".format(self.payload_path))
|
||||
def init(self) -> bool:
|
||||
logging.info("-( Load payload: {}".format(self.payload_path))
|
||||
if not os.path.exists(self.payload_path):
|
||||
logger.error("Payload file does not exist: {}".format(self.payload_path))
|
||||
return False
|
||||
|
||||
with open(self.payload_path, 'rb') as f:
|
||||
self.payload_data = f.read()
|
||||
return True
|
||||
|
||||
|
||||
+6
-3
@@ -28,9 +28,12 @@ class Project():
|
||||
self.project_exe: str = ""
|
||||
|
||||
|
||||
def init(self):
|
||||
self.payload.init()
|
||||
self.injectable.init()
|
||||
def init(self) -> bool:
|
||||
if not self.payload.init():
|
||||
return False
|
||||
if not self.injectable.init():
|
||||
return False
|
||||
return True
|
||||
|
||||
|
||||
def prepare_project(project_name, settings):
|
||||
|
||||
+2
-2
@@ -62,8 +62,8 @@ class Settings():
|
||||
self.try_start_final_infected_exe = False
|
||||
else:
|
||||
self.cleanup_files_on_exit = False
|
||||
|
||||
self.inject_exe_in = injectable
|
||||
|
||||
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")
|
||||
|
||||
Reference in New Issue
Block a user