mirror of
https://github.com/dobin/SuperMega
synced 2026-06-03 01:27:11 +00:00
refactor: move stuff to working/
This commit is contained in:
+2
-2
@@ -90,12 +90,12 @@ def project():
|
|||||||
id = 0
|
id = 0
|
||||||
asm_a = "" # for diff
|
asm_a = "" # for diff
|
||||||
asm_b = ""
|
asm_b = ""
|
||||||
for file in os.listdir("logs"):
|
for file in os.listdir(f"{logs_dir}/"):
|
||||||
if file.startswith("."):
|
if file.startswith("."):
|
||||||
continue
|
continue
|
||||||
print("Handle: ", file)
|
print("Handle: ", file)
|
||||||
|
|
||||||
with open(os.path.join("logs", file), "r") as f:
|
with open(os.path.join(f"{logs_dir}/", file), "r") as f:
|
||||||
if file.endswith(".bin"):
|
if file.endswith(".bin"):
|
||||||
continue
|
continue
|
||||||
data = f.read()
|
data = f.read()
|
||||||
|
|||||||
@@ -49,7 +49,7 @@ def run_process_checkret(args, check=True):
|
|||||||
logger.warn(f"An error occurred: {e}")
|
logger.warn(f"An error occurred: {e}")
|
||||||
# Handle other exceptions
|
# Handle other exceptions
|
||||||
|
|
||||||
with open("logs/cmdoutput.log", "ab") as f:
|
with open(f"{logs_dir}/cmdoutput.log", "ab") as f:
|
||||||
cmd = "------------------------------------\n"
|
cmd = "------------------------------------\n"
|
||||||
cmd += "--- " + " ".join(args) + "\n"
|
cmd += "--- " + " ".join(args) + "\n"
|
||||||
f.write(cmd.encode('utf-8'))
|
f.write(cmd.encode('utf-8'))
|
||||||
|
|||||||
@@ -1,5 +1,7 @@
|
|||||||
import logging
|
import logging
|
||||||
|
|
||||||
|
from model.defs import *
|
||||||
|
|
||||||
log_messages = []
|
log_messages = []
|
||||||
|
|
||||||
|
|
||||||
@@ -46,7 +48,7 @@ class ListHandler(logging.Handler):
|
|||||||
|
|
||||||
def writelog():
|
def writelog():
|
||||||
# write log to file
|
# write log to file
|
||||||
with open("logs/supermega.log", "w") as f:
|
with open(f"{logs_dir}/supermega.log", "w") as f:
|
||||||
for line in log_messages:
|
for line in log_messages:
|
||||||
f.write(line + "\n")
|
f.write(line + "\n")
|
||||||
|
|
||||||
|
|||||||
+3
-1
@@ -37,7 +37,9 @@ class SourceStyle(Enum):
|
|||||||
iat_reuse = "iat_reuse"
|
iat_reuse = "iat_reuse"
|
||||||
|
|
||||||
|
|
||||||
build_dir = "build"
|
# no slash at end
|
||||||
|
build_dir = "working/build"
|
||||||
|
logs_dir = "working/logs"
|
||||||
|
|
||||||
main_c_file = os.path.join(build_dir, "main.c")
|
main_c_file = os.path.join(build_dir, "main.c")
|
||||||
main_asm_file = os.path.join(build_dir, "main.asm")
|
main_asm_file = os.path.join(build_dir, "main.asm")
|
||||||
|
|||||||
+4
-3
@@ -5,6 +5,7 @@ from capstone import Cs, CS_ARCH_X86, CS_MODE_64
|
|||||||
from model import *
|
from model import *
|
||||||
from peparser.r2helper import r2_disas
|
from peparser.r2helper import r2_disas
|
||||||
from helper import delete_all_files_in_directory
|
from helper import delete_all_files_in_directory
|
||||||
|
from model.defs import *
|
||||||
|
|
||||||
|
|
||||||
class Observer():
|
class Observer():
|
||||||
@@ -32,16 +33,16 @@ class Observer():
|
|||||||
def write_to_file(self, filename, data):
|
def write_to_file(self, filename, data):
|
||||||
if not self.active:
|
if not self.active:
|
||||||
return
|
return
|
||||||
with open("logs/{}-{}".format(self.idx, filename), "w") as f:
|
with open("{}/{}-{}".format(logs_dir, self.idx, filename), "w") as f:
|
||||||
f.write(data)
|
f.write(data)
|
||||||
def write_to_file_bin(self, filename, data):
|
def write_to_file_bin(self, filename, data):
|
||||||
if not self.active:
|
if not self.active:
|
||||||
return
|
return
|
||||||
with open("logs/{}-{}".format(self.idx, filename), "wb") as f:
|
with open("{}/{}-{}".format(logs_dir, self.idx, filename), "wb") as f:
|
||||||
f.write(data)
|
f.write(data)
|
||||||
|
|
||||||
def clean_files(self):
|
def clean_files(self):
|
||||||
delete_all_files_in_directory("logs/")
|
delete_all_files_in_directory(f"{logs_dir}/")
|
||||||
self.idx = 0
|
self.idx = 0
|
||||||
self.logs = []
|
self.logs = []
|
||||||
|
|
||||||
|
|||||||
Binary file not shown.
+2
-2
@@ -74,12 +74,12 @@ def create_c_from_template(
|
|||||||
observer.add_text("main_c_rendered", rendered_template)
|
observer.add_text("main_c_rendered", rendered_template)
|
||||||
|
|
||||||
# TODO PEB
|
# TODO PEB
|
||||||
shutil.copy("data/source/peb_walk/peb_lookup.h", "build/peb_lookup.h")
|
shutil.copy("data/source/peb_walk/peb_lookup.h", f"{build_dir}/peb_lookup.h")
|
||||||
else:
|
else:
|
||||||
observer.add_text("main_c", file_readall_text("data/source/peb_walk/main.c"))
|
observer.add_text("main_c", file_readall_text("data/source/peb_walk/main.c"))
|
||||||
shutil.copy("data/source/peb_walk/main.c", main_c_file)
|
shutil.copy("data/source/peb_walk/main.c", main_c_file)
|
||||||
# TODO PEB
|
# TODO PEB
|
||||||
shutil.copy("data/source/peb_walk/peb_lookup.h", "build/peb_lookup.h")
|
shutil.copy("data/source/peb_walk/peb_lookup.h", f"{build_dir}/peb_lookup.h")
|
||||||
|
|
||||||
elif source_style == SourceStyle.iat_reuse:
|
elif source_style == SourceStyle.iat_reuse:
|
||||||
if use_templates:
|
if use_templates:
|
||||||
|
|||||||
+1
-1
@@ -137,7 +137,7 @@ def start(settings: Settings):
|
|||||||
# Delete: all old files
|
# Delete: all old files
|
||||||
if settings.cleanup_files_on_start:
|
if settings.cleanup_files_on_start:
|
||||||
clean_files()
|
clean_files()
|
||||||
delete_all_files_in_directory("logs/")
|
delete_all_files_in_directory(f"{logs_dir}/")
|
||||||
exit_code = 0 # 0 = success
|
exit_code = 0 # 0 = success
|
||||||
|
|
||||||
# Load our input
|
# Load our input
|
||||||
|
|||||||
Reference in New Issue
Block a user