refactor: cleanup

This commit is contained in:
Dobin Rutishauser
2025-06-09 15:40:17 +02:00
parent 99ad23d69d
commit f55596f4a8
3 changed files with 21 additions and 28 deletions
+4 -5
View File
@@ -89,7 +89,7 @@ def project(name):
has_rodata_section = superpe.has_rodata_section() has_rodata_section = superpe.has_rodata_section()
if has_rodata_section: if has_rodata_section:
superpe.get_rdata_rangemanager().find_largest_gap() data_sect_largest_gap_size = superpe.get_rdata_rangemanager().find_largest_gap()
unresolved_dlls = pe.dllresolver.unresolved_dlls(superpe) unresolved_dlls = pe.dllresolver.unresolved_dlls(superpe)
project_dir = os.path.dirname(os.getcwd() + "\\" + project.settings.main_dir) project_dir = os.path.dirname(os.getcwd() + "\\" + project.settings.main_dir)
@@ -108,7 +108,6 @@ def project(name):
virtualprotect_styles = list_files(PATH_VIRTUALPROTECT) virtualprotect_styles = list_files(PATH_VIRTUALPROTECT)
decoder_styles = list_files(PATH_DECODER) decoder_styles = list_files(PATH_DECODER)
return render_template('project.html', return render_template('project.html',
project_name = name, project_name = name,
project=project, project=project,
@@ -197,8 +196,8 @@ def add_project():
# update project # update project
else: else:
settings.init_payload_injectable( settings.init_payload_injectable(
request.form['shellcode'], FilePath(request.form['shellcode']),
request.form['exe'], FilePath(request.form['exe']),
request.form.get('dllfunc', "") request.form.get('dllfunc', "")
) )
@@ -213,7 +212,7 @@ def add_project():
payload_location = request.form['payload_location'] payload_location = request.form['payload_location']
settings.payload_location = PayloadLocation[payload_location] settings.payload_location = PayloadLocation[payload_location]
settings.plugin_guardrail_data = request.form.get('guardrail_data', settings.plugin_guardrail_data) settings.plugin_guardrail_data = request.form.get('guardrail_data', settings.plugin_guardrail_data)
settings.plugin_virtualprotect = request.form.get('virtualprotect') settings.plugin_virtualprotect = request.form.get('virtualprotect', "standard")
# overwrite project # overwrite project
project = storage.get_project(project_name) project = storage.get_project(project_name)
+1 -21
View File
@@ -36,9 +36,7 @@ def main():
parser.add_argument('--antiemulation', type=str, help='anti-emulation: data/source/antiemulation/* (sirallocalot, timeraw, none, ...)', default="sirallocalot") parser.add_argument('--antiemulation', type=str, help='anti-emulation: data/source/antiemulation/* (sirallocalot, timeraw, none, ...)', default="sirallocalot")
parser.add_argument('--fix-iat', action='store_true', help='Fix missing IAT entries in the infectable executable', default=True) parser.add_argument('--fix-iat', action='store_true', help='Fix missing IAT entries in the infectable executable', default=True)
parser.add_argument('--carrier_invoke', type=str, help='how carrier is started: \"backdoor\" to rewrite call instruction, \"eop\" for entry point', choices=["eop", "backdoor"], default="backdoor") parser.add_argument('--carrier_invoke', type=str, help='how carrier is started: \"backdoor\" to rewrite call instruction, \"eop\" for entry point', choices=["eop", "backdoor"], default="backdoor")
parser.add_argument('--start-injected', action='store_true', help='Dev: Start the generated infected executable at the end') parser.add_argument('--start', action='store_true', help='Start the infected executable at the end for testing')
parser.add_argument('--start-loader-shellcode', action='store_true', help='Dev: Start the loader shellcode (without payload)')
parser.add_argument('--start-final-shellcode', action='store_true', help='Debug: Start the final shellcode (loader + payload)')
parser.add_argument('--short-call-patching', action='store_true', help='Debug: Make short calls long. You will know when you need it.') parser.add_argument('--short-call-patching', action='store_true', help='Debug: Make short calls long. You will know when you need it.')
parser.add_argument('--no-clean-at-start', action='store_true', help='Debug: Dont remove any temporary files at start') parser.add_argument('--no-clean-at-start', action='store_true', help='Debug: Dont remove any temporary files at start')
parser.add_argument('--no-clean-at-exit', action='store_true', help='Debug: Dont remove any temporary files at exit') parser.add_argument('--no-clean-at-exit', action='store_true', help='Debug: Dont remove any temporary files at exit')
@@ -271,23 +269,5 @@ def verify_shellcode(shc_name):
return False return False
def command_exists(cmd):
try:
# Use the "where" command to check if the command is in the PATH
result = subprocess.run(
["where", cmd],
stdout=subprocess.DEVNULL,
stderr=subprocess.DEVNULL,
shell=True
)
return result.returncode == 0
except Exception:
return False
if __name__ == "__main__": if __name__ == "__main__":
if not command_exists("cl.exe"):
logger.error("cl.exe not found in PATH. Please install Visual Studio Build Tools.")
logger.error("And start this in Developer Command prompt.")
exit(1)
main() main()
+16 -2
View File
@@ -15,16 +15,30 @@ def check_deps():
cl = config.get("path_cl") cl = config.get("path_cl")
if shutil.which(cl) == None: if shutil.which(cl) == None:
logger.error("Missing dependency: " + cl) logger.error("Missing dependency: " + cl)
logger.error("Start in x64 Native Tools Command Prompt for VS 2022") logger.error("See README for fix")
exit(1) exit(1)
ml = config.get("path_ml64") ml = config.get("path_ml64")
if shutil.which(ml) == None: if shutil.which(ml) == None:
logger.error("Missing dependency: " + ml) logger.error("Missing dependency: " + ml)
logger.error("Start in x64 Native Tools Command Prompt for VS 2022") logger.error("See README for fix")
exit(1) exit(1)
def command_exists(cmd):
try:
# Use the "where" command to check if the command is in the PATH
result = subprocess.run(
["where", cmd],
stdout=subprocess.DEVNULL,
stderr=subprocess.DEVNULL,
shell=True
)
return result.returncode == 0
except Exception:
return False
def delete_all_files_in_directory(directory_path): def delete_all_files_in_directory(directory_path):
files = glob.glob(os.path.join(directory_path, '*')) files = glob.glob(os.path.join(directory_path, '*'))
for file_path in files: for file_path in files: