mirror of
https://github.com/dobin/SuperMega
synced 2026-06-03 01:27:11 +00:00
refactor: from project.verify_filename to def.py:VerifyFilename
This commit is contained in:
@@ -4,6 +4,9 @@ import os
|
|||||||
class FilePath(str):
|
class FilePath(str):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
# with shellcodes/createfile.bin
|
||||||
|
VerifyFilename: FilePath = r'C:\Temp\a'
|
||||||
|
|
||||||
|
|
||||||
# Correlated with real template files
|
# Correlated with real template files
|
||||||
# in plugins/
|
# in plugins/
|
||||||
|
|||||||
@@ -29,7 +29,7 @@ def clean_files():
|
|||||||
os.path.join(build_dir, "peb_lookup.h"),
|
os.path.join(build_dir, "peb_lookup.h"),
|
||||||
#os.path.join(build_dir, "main.exe"),
|
#os.path.join(build_dir, "main.exe"),
|
||||||
|
|
||||||
project.verify_filename,
|
VerifyFilename,
|
||||||
]
|
]
|
||||||
for file in files_to_clean:
|
for file in files_to_clean:
|
||||||
pathlib.Path(file).unlink(missing_ok=True)
|
pathlib.Path(file).unlink(missing_ok=True)
|
||||||
|
|||||||
@@ -66,7 +66,6 @@ class ExeInfo():
|
|||||||
self.code_virtaddr,
|
self.code_virtaddr,
|
||||||
self.code_size))
|
self.code_size))
|
||||||
|
|
||||||
|
|
||||||
# iat
|
# iat
|
||||||
self.iat = pehelper.extract_iat(pe)
|
self.iat = pehelper.extract_iat(pe)
|
||||||
|
|
||||||
|
|||||||
+3
-3
@@ -81,16 +81,16 @@ def injected_fix_iat(exe_out: FilePath, exe_info: ExeInfo):
|
|||||||
def verify_injected_exe(exefile: FilePath) -> int:
|
def verify_injected_exe(exefile: FilePath) -> int:
|
||||||
logger.info("---[ Verify infected exe: {} ".format(exefile))
|
logger.info("---[ Verify infected exe: {} ".format(exefile))
|
||||||
# remove indicator file
|
# remove indicator file
|
||||||
pathlib.Path(project.verify_filename).unlink(missing_ok=True)
|
pathlib.Path(VerifyFilename).unlink(missing_ok=True)
|
||||||
|
|
||||||
run_process_checkret([
|
run_process_checkret([
|
||||||
exefile,
|
exefile,
|
||||||
], check=False)
|
], check=False)
|
||||||
time.sleep(SHC_VERIFY_SLEEP)
|
time.sleep(SHC_VERIFY_SLEEP)
|
||||||
if os.path.isfile(project.verify_filename):
|
if os.path.isfile(VerifyFilename):
|
||||||
logger.info("---> Verify OK. Infected exe works (file was created)")
|
logger.info("---> Verify OK. Infected exe works (file was created)")
|
||||||
# better to remove it immediately
|
# better to remove it immediately
|
||||||
os.remove(project.verify_filename)
|
os.remove(VerifyFilename)
|
||||||
return 0
|
return 0
|
||||||
else:
|
else:
|
||||||
logger.warning("---> Verify FAIL. Infected exe does not work (no file created)")
|
logger.warning("---> Verify FAIL. Infected exe does not work (no file created)")
|
||||||
|
|||||||
@@ -36,8 +36,6 @@ class Project():
|
|||||||
self.generate_asm_from_c: bool = True
|
self.generate_asm_from_c: bool = True
|
||||||
self.generate_shc_from_asm: bool = True
|
self.generate_shc_from_asm: bool = True
|
||||||
|
|
||||||
self.verify_filename: FilePath = r'C:\Temp\a'
|
|
||||||
|
|
||||||
|
|
||||||
def load_payload(self):
|
def load_payload(self):
|
||||||
logging.info("Load payload: {}".format(self.payload_path))
|
logging.info("Load payload: {}".format(self.payload_path))
|
||||||
|
|||||||
+5
-5
@@ -275,21 +275,21 @@ def verify_shellcode(shc_name):
|
|||||||
logger.info("---[ Verify shellcode: {}".format(shc_name))
|
logger.info("---[ Verify shellcode: {}".format(shc_name))
|
||||||
|
|
||||||
# check if directory exists
|
# check if directory exists
|
||||||
if not os.path.exists(os.path.dirname(project.verify_filename)):
|
if not os.path.exists(os.path.dirname(VerifyFilename)):
|
||||||
logger.info("Error, directory does not exist for: {}".format(project.verify_filename))
|
logger.info("Error, directory does not exist for: {}".format(VerifyFilename))
|
||||||
return
|
return
|
||||||
|
|
||||||
# remove indicator file
|
# remove indicator file
|
||||||
pathlib.Path(project.verify_filename).unlink(missing_ok=True)
|
pathlib.Path(VerifyFilename).unlink(missing_ok=True)
|
||||||
|
|
||||||
run_process_checkret([
|
run_process_checkret([
|
||||||
config.get("path_runshc"),
|
config.get("path_runshc"),
|
||||||
"{}".format(shc_name),
|
"{}".format(shc_name),
|
||||||
], check=False)
|
], check=False)
|
||||||
time.sleep(SHC_VERIFY_SLEEP)
|
time.sleep(SHC_VERIFY_SLEEP)
|
||||||
if os.path.isfile(project.verify_filename):
|
if os.path.isfile(VerifyFilename):
|
||||||
logger.info("---> Verify OK. Shellcode works (file was created)")
|
logger.info("---> Verify OK. Shellcode works (file was created)")
|
||||||
os.remove(project.verify_filename)
|
os.remove(VerifyFilename)
|
||||||
return True
|
return True
|
||||||
else:
|
else:
|
||||||
logger.warning("---> Verify FAIL. Shellcode doesnt work (file was not created)")
|
logger.warning("---> Verify FAIL. Shellcode doesnt work (file was not created)")
|
||||||
|
|||||||
Reference in New Issue
Block a user