mirror of
https://github.com/dobin/SuperMega
synced 2026-06-03 01:27:11 +00:00
refactor: nicer output
This commit is contained in:
+7
-6
@@ -7,13 +7,14 @@ from helper import *
|
||||
from config import config
|
||||
from observer import observer
|
||||
from project import project
|
||||
from helper import *
|
||||
|
||||
logger = logging.getLogger("Assembler")
|
||||
|
||||
def make_shc_from_asm(asm_file, exe_file, shc_file):
|
||||
logger.info("--[ Assemble to exe: {} -> {} -> {} ]".format(asm_file, exe_file, shc_file))
|
||||
logger.info("--[ Assemble to exe: {} -> {} -> {}".format(asm_file, exe_file, shc_file))
|
||||
|
||||
logger.info("---[ Assemble ASM to EXE: {} -> {} ]".format(asm_file, exe_file))
|
||||
logger.info("---[ Assemble ASM to EXE: {} -> {}".format(asm_file, exe_file))
|
||||
run_process_checkret([
|
||||
config.get("path_ml64"),
|
||||
asm_file,
|
||||
@@ -25,17 +26,17 @@ def make_shc_from_asm(asm_file, exe_file, shc_file):
|
||||
logger.error("Error")
|
||||
return
|
||||
|
||||
logger.info("---[ EXE to SHC: {} -> {} ]".format(exe_file, shc_file))
|
||||
logger.info("---[ EXE to SHC: {} -> {} ".format(exe_file, shc_file))
|
||||
code = get_code_section_data(exe_file)
|
||||
with open(shc_file, 'wb') as f:
|
||||
f.write(code)
|
||||
|
||||
return code
|
||||
#logger.info("---[ Shellcode from {} written to: {} (size: {}) ]".format(exe_file, shc_file, len(code)))
|
||||
#logger.info("---[ Shellcode from {} written to: {} (size: {}) ".format(exe_file, shc_file, len(code)))
|
||||
|
||||
|
||||
def merge_loader_payload(main_shc_file):
|
||||
logger.info("--[ Merge stager: {} + {} -> {} ] ".format(
|
||||
logger.info("--[ Merge stager: {} + {} -> {}".format(
|
||||
main_shc_file, project.payload, main_shc_file))
|
||||
with open(main_shc_file, 'rb') as input1:
|
||||
data_stager = input1.read()
|
||||
@@ -49,7 +50,7 @@ def merge_loader_payload(main_shc_file):
|
||||
logger.info("---[ XOR payload with key 0x{:x}".format(xor_key))
|
||||
data_payload = bytes([byte ^ xor_key for byte in data_payload])
|
||||
|
||||
logger.info("---[ Size: Stager: {} and Payload: {} Sum: {} ]".format(
|
||||
logger.info("---[ Size: Stager: {} and Payload: {} Sum: {} ".format(
|
||||
len(data_stager), len(data_payload), len(data_stager)+len(data_payload)))
|
||||
|
||||
with open(main_shc_file, 'wb') as output:
|
||||
|
||||
+4
-4
@@ -13,7 +13,7 @@ use_templates = True
|
||||
|
||||
|
||||
def make_c_to_asm(c_file, asm_file, payload_len, capabilities: ExeCapabilities):
|
||||
logger.info("--[ C to ASM: {} -> {} ]".format(c_file, asm_file))
|
||||
logger.info("--[ C to ASM: {} -> {} ".format(c_file, asm_file))
|
||||
|
||||
asm = {
|
||||
"initial": "",
|
||||
@@ -23,7 +23,7 @@ def make_c_to_asm(c_file, asm_file, payload_len, capabilities: ExeCapabilities):
|
||||
}
|
||||
|
||||
# Phase 1: C To Assembly
|
||||
logger.info("---[ Make ASM from C: {} ]".format(c_file))
|
||||
logger.info("---[ Make ASM from C: {} ".format(c_file))
|
||||
run_process_checkret([
|
||||
config.get("path_cl"),
|
||||
"/c",
|
||||
@@ -38,7 +38,7 @@ def make_c_to_asm(c_file, asm_file, payload_len, capabilities: ExeCapabilities):
|
||||
asm["initial"] = file_readall_text(asm_file)
|
||||
|
||||
# Phase 1.2: Assembly fixup
|
||||
logger.info("---[ Fixup : {} ]".format(asm_file))
|
||||
logger.info("---[ Fixup : {} ".format(asm_file))
|
||||
if not fixup_asm_file(asm_file, payload_len, capabilities):
|
||||
logger.error("Error: Fixup failed")
|
||||
return
|
||||
@@ -47,7 +47,7 @@ def make_c_to_asm(c_file, asm_file, payload_len, capabilities: ExeCapabilities):
|
||||
|
||||
# Phase 1.1: Assembly cleanup
|
||||
asm_clean_file = asm_file + ".clean"
|
||||
logger.info("---[ Cleanup: {} ]".format(asm_file))
|
||||
logger.info("---[ Cleanup: {} ".format(asm_file))
|
||||
run_process_checkret([
|
||||
config.get("path_masmshc"),
|
||||
asm_file,
|
||||
|
||||
+2
-2
@@ -15,7 +15,7 @@ def inject_exe(shc_file: FilePath):
|
||||
exe_out: FilePath = project.inject_exe_out
|
||||
exe_capabilities: ExeCapabilities = project.exe_capabilities
|
||||
|
||||
logger.info("--[ Injecting: {} into: {} -> {} ]".format(
|
||||
logger.info("--[ Injecting: {} into: {} -> {} ".format(
|
||||
shc_file, exe_in, exe_out
|
||||
))
|
||||
|
||||
@@ -56,7 +56,7 @@ def inject_exe(shc_file: FilePath):
|
||||
|
||||
|
||||
def verify_injected_exe(exefile):
|
||||
logger.info("---[ Verify infected exe: {} ]".format(exefile))
|
||||
logger.info("---[ Verify infected exe: {} ".format(exefile))
|
||||
# remove indicator file
|
||||
pathlib.Path(verify_filename).unlink(missing_ok=True)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user