refactor: from project.verify_filename to def.py:VerifyFilename

This commit is contained in:
Dobin
2024-02-19 19:30:15 +00:00
parent 0f68a242da
commit b66c7cc6d8
6 changed files with 12 additions and 12 deletions
+3
View File
@@ -4,6 +4,9 @@ import os
class FilePath(str):
pass
# with shellcodes/createfile.bin
VerifyFilename: FilePath = r'C:\Temp\a'
# Correlated with real template files
# in plugins/
+1 -1
View File
@@ -29,7 +29,7 @@ def clean_files():
os.path.join(build_dir, "peb_lookup.h"),
#os.path.join(build_dir, "main.exe"),
project.verify_filename,
VerifyFilename,
]
for file in files_to_clean:
pathlib.Path(file).unlink(missing_ok=True)
-1
View File
@@ -66,7 +66,6 @@ class ExeInfo():
self.code_virtaddr,
self.code_size))
# iat
self.iat = pehelper.extract_iat(pe)
+3 -3
View File
@@ -81,16 +81,16 @@ def injected_fix_iat(exe_out: FilePath, exe_info: ExeInfo):
def verify_injected_exe(exefile: FilePath) -> int:
logger.info("---[ Verify infected exe: {} ".format(exefile))
# remove indicator file
pathlib.Path(project.verify_filename).unlink(missing_ok=True)
pathlib.Path(VerifyFilename).unlink(missing_ok=True)
run_process_checkret([
exefile,
], check=False)
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)")
# better to remove it immediately
os.remove(project.verify_filename)
os.remove(VerifyFilename)
return 0
else:
logger.warning("---> Verify FAIL. Infected exe does not work (no file created)")
-2
View File
@@ -36,8 +36,6 @@ class Project():
self.generate_asm_from_c: bool = True
self.generate_shc_from_asm: bool = True
self.verify_filename: FilePath = r'C:\Temp\a'
def load_payload(self):
logging.info("Load payload: {}".format(self.payload_path))
+5 -5
View File
@@ -275,21 +275,21 @@ def verify_shellcode(shc_name):
logger.info("---[ Verify shellcode: {}".format(shc_name))
# check if directory exists
if not os.path.exists(os.path.dirname(project.verify_filename)):
logger.info("Error, directory does not exist for: {}".format(project.verify_filename))
if not os.path.exists(os.path.dirname(VerifyFilename)):
logger.info("Error, directory does not exist for: {}".format(VerifyFilename))
return
# remove indicator file
pathlib.Path(project.verify_filename).unlink(missing_ok=True)
pathlib.Path(VerifyFilename).unlink(missing_ok=True)
run_process_checkret([
config.get("path_runshc"),
"{}".format(shc_name),
], check=False)
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)")
os.remove(project.verify_filename)
os.remove(VerifyFilename)
return True
else:
logger.warning("---> Verify FAIL. Shellcode doesnt work (file was not created)")