mirror of
https://github.com/dobin/SuperMega
synced 2026-06-03 01:27:11 +00:00
feature: log.txt with all stdout/stderr
This commit is contained in:
@@ -98,18 +98,32 @@ def clean_files():
|
||||
pathlib.Path(file).unlink(missing_ok=True)
|
||||
|
||||
|
||||
def run_process_checkret(args):
|
||||
ret = None
|
||||
ret = subprocess.run(args, capture_output=True, text=True)
|
||||
if ret.returncode != 0:
|
||||
def run_process_checkret(args, check=True):
|
||||
ret = subprocess.run(args,
|
||||
capture_output=True)
|
||||
|
||||
with open("logs/log.txt", "ab") as f:
|
||||
cmd = "------------------------------------\n"
|
||||
cmd += "--- " + " ".join(args)
|
||||
f.write(cmd.encode('utf-8'))
|
||||
if ret.stdout != None:
|
||||
f.write(ret.stdout)
|
||||
if ret.stderr != None:
|
||||
f.write(ret.stderr)
|
||||
if ret.returncode != 0 and check:
|
||||
print("----! FAILED Command: {}".format(" ".join(args)))
|
||||
print(ret.stdout)
|
||||
print(ret.stderr)
|
||||
raise Exception("Command failed")
|
||||
if ret.stdout != None:
|
||||
print(ret.stdout.decode('utf-8'))
|
||||
if ret.stderr != None:
|
||||
print(ret.stderr.decode('utf-8'))
|
||||
raise Exception("Command failed: " + " ".join(args))
|
||||
if project.show_command_output:
|
||||
print("> " + " ".join(args))
|
||||
print(ret.stdout)
|
||||
print(ret.stderr)
|
||||
if ret.stdout != None:
|
||||
print(ret.stdout.decode('utf-8'))
|
||||
if ret.stderr != None:
|
||||
print(ret.stderr.decode('utf-8'))
|
||||
|
||||
|
||||
def try_start_shellcode(shc_file):
|
||||
print("--[ Blindly execute shellcode: {} ]".format(shc_file))
|
||||
|
||||
+2
-2
@@ -57,9 +57,9 @@ def verify_injected_exe(exefile):
|
||||
# remove indicator file
|
||||
pathlib.Path(verify_filename).unlink(missing_ok=True)
|
||||
|
||||
subprocess.run([
|
||||
run_process_checkret([
|
||||
exefile,
|
||||
], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL) # , check=True
|
||||
], check=False)
|
||||
time.sleep(SHC_VERIFY_SLEEP)
|
||||
if os.path.isfile(verify_filename):
|
||||
print("---> Verify OK. Infected exe works (file was created)")
|
||||
|
||||
+6
-6
@@ -178,9 +178,9 @@ def start():
|
||||
|
||||
if project.try_start_final_infected_exe:
|
||||
print("--[ Start infected exe ]")
|
||||
subprocess.run([
|
||||
run_process_checkret([
|
||||
project.inject_exe_out,
|
||||
], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL)
|
||||
], check=False)
|
||||
|
||||
# dump the info i gathered
|
||||
#file = open('latest.pickle', 'wb')
|
||||
@@ -196,7 +196,7 @@ def obfuscate_shc_loader(file_shc_in, file_shc_out):
|
||||
print("--[ Convert with SGN ]")
|
||||
if True:
|
||||
path_sgn = r'C:\tools\sgn2.0\sgn.exe'
|
||||
subprocess.run([
|
||||
run_process_checkret([
|
||||
path_sgn,
|
||||
"-a", "64",
|
||||
"{}".format(file_shc_in),
|
||||
@@ -204,7 +204,7 @@ def obfuscate_shc_loader(file_shc_in, file_shc_out):
|
||||
#shutil.copy(file_shc_in + ".sgn", file_shc_out)
|
||||
else:
|
||||
path_sgn = r'C:\training\tools\sgn\sgn.exe'
|
||||
subprocess.run([
|
||||
run_process_checkret([
|
||||
path_sgn,
|
||||
"--arch=64",
|
||||
"-i", "{}".format(file_shc_in),
|
||||
@@ -229,10 +229,10 @@ def verify_shellcode(shc_name):
|
||||
# remove indicator file
|
||||
pathlib.Path(verify_filename).unlink(missing_ok=True)
|
||||
|
||||
subprocess.run([
|
||||
run_process_checkret([
|
||||
config.get("path_runshc"),
|
||||
"{}".format(shc_name),
|
||||
], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL) # , check=True
|
||||
], check=False)
|
||||
time.sleep(SHC_VERIFY_SLEEP)
|
||||
if os.path.isfile(verify_filename):
|
||||
print("---> Verify OK. Shellcode works (file was created)")
|
||||
|
||||
Reference in New Issue
Block a user