refactor: move stuff to working/

This commit is contained in:
Dobin
2024-03-01 19:04:05 +00:00
parent 6175875ea1
commit 115c654429
10 changed files with 16 additions and 11 deletions
+2 -2
View File
@@ -90,12 +90,12 @@ def project():
id = 0
asm_a = "" # for diff
asm_b = ""
for file in os.listdir("logs"):
for file in os.listdir(f"{logs_dir}/"):
if file.startswith("."):
continue
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"):
continue
data = f.read()
View File
+1 -1
View File
@@ -49,7 +49,7 @@ def run_process_checkret(args, check=True):
logger.warn(f"An error occurred: {e}")
# Handle other exceptions
with open("logs/cmdoutput.log", "ab") as f:
with open(f"{logs_dir}/cmdoutput.log", "ab") as f:
cmd = "------------------------------------\n"
cmd += "--- " + " ".join(args) + "\n"
f.write(cmd.encode('utf-8'))
+3 -1
View File
@@ -1,5 +1,7 @@
import logging
from model.defs import *
log_messages = []
@@ -46,7 +48,7 @@ class ListHandler(logging.Handler):
def writelog():
# 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:
f.write(line + "\n")
View File
+3 -1
View File
@@ -37,7 +37,9 @@ class SourceStyle(Enum):
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_asm_file = os.path.join(build_dir, "main.asm")
+4 -3
View File
@@ -5,6 +5,7 @@ from capstone import Cs, CS_ARCH_X86, CS_MODE_64
from model import *
from peparser.r2helper import r2_disas
from helper import delete_all_files_in_directory
from model.defs import *
class Observer():
@@ -32,16 +33,16 @@ class Observer():
def write_to_file(self, filename, data):
if not self.active:
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)
def write_to_file_bin(self, filename, data):
if not self.active:
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)
def clean_files(self):
delete_all_files_in_directory("logs/")
delete_all_files_in_directory(f"{logs_dir}/")
self.idx = 0
self.logs = []
BIN
View File
Binary file not shown.
+2 -2
View File
@@ -74,12 +74,12 @@ def create_c_from_template(
observer.add_text("main_c_rendered", rendered_template)
# 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:
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)
# 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:
if use_templates:
+1 -1
View File
@@ -137,7 +137,7 @@ def start(settings: Settings):
# Delete: all old files
if settings.cleanup_files_on_start:
clean_files()
delete_all_files_in_directory("logs/")
delete_all_files_in_directory(f"{logs_dir}/")
exit_code = 0 # 0 = success
# Load our input