refactor: reorganize files into data/

This commit is contained in:
Dobin
2024-03-01 17:07:01 +00:00
parent 9e551d9a19
commit 6175875ea1
31 changed files with 42 additions and 123 deletions
+14 -14
View File
@@ -12,8 +12,8 @@ logger = logging.getLogger("Assembler")
# INPUT:
# plugins/
# source/
# data/plugins/
# data/source/
#
# Output:
# build/main.c
@@ -34,14 +34,14 @@ def create_c_from_template(
source_style.value, alloc_style.value, decoder_style.value, exec_style.value
))
filepath = "plugins/allocator/{}.c".format(alloc_style.value)
filepath = "data/plugins/allocator/{}.c".format(alloc_style.value)
with open(filepath, "r", encoding='utf-8') as file:
plugin_allocator = file.read()
plugin_allocator = Template(plugin_allocator).render({
'PAYLOAD_LEN': payload_len,
})
filepath = "plugins/decoder/{}.c".format(decoder_style.value)
filepath = "data/plugins/decoder/{}.c".format(decoder_style.value)
with open(filepath, "r", encoding='utf-8') as file:
plugin_decoder = file.read()
plugin_decoder = Template(plugin_decoder).render({
@@ -49,8 +49,8 @@ def create_c_from_template(
'XOR_KEY': config.xor_key,
})
filepath = "plugins/executor/{}.c".format(exec_style.value)
with open("plugins/executor/direct_1.c", "r", encoding='utf-8') as file:
filepath = "data/plugins/executor/{}.c".format(exec_style.value)
with open("data/plugins/executor/direct_1.c", "r", encoding='utf-8') as file:
plugin_executor = file.read()
plugin_executor = Template(plugin_executor).render({
'PAYLOAD_LEN': payload_len,
@@ -58,7 +58,7 @@ def create_c_from_template(
if source_style == SourceStyle.peb_walk:
if use_templates:
with open("source/peb_walk/template.c", 'r', encoding='utf-8') as file:
with open("data/source/peb_walk/template.c", 'r', encoding='utf-8') as file:
template_content = file.read()
observer.add_text("main_c_template", template_content)
@@ -74,16 +74,16 @@ def create_c_from_template(
observer.add_text("main_c_rendered", rendered_template)
# TODO PEB
shutil.copy("source/peb_walk/peb_lookup.h", "build/peb_lookup.h")
shutil.copy("data/source/peb_walk/peb_lookup.h", "build/peb_lookup.h")
else:
observer.add_text("main_c", file_readall_text("source/peb_walk/main.c"))
shutil.copy("source/peb_walk/main.c", main_c_file)
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("source/peb_walk/peb_lookup.h", "build/peb_lookup.h")
shutil.copy("data/source/peb_walk/peb_lookup.h", "build/peb_lookup.h")
elif source_style == SourceStyle.iat_reuse:
if use_templates:
with open("source/iat_reuse/template.c", 'r', encoding='utf-8') as file:
with open("data/source/iat_reuse/template.c", 'r', encoding='utf-8') as file:
template_content = file.read()
observer.add_text("main_c_template", template_content)
template = Template(template_content)
@@ -97,5 +97,5 @@ def create_c_from_template(
file.write(rendered_template)
observer.add_text("main_c_rendered", rendered_template)
else:
observer.add_text("main_c", file_readall_text("source/iat_reuse/main.c"))
shutil.copy("source/iat_reuse/main.c", main_c_file)
observer.add_text("main_c", file_readall_text("data/source/iat_reuse/main.c"))
shutil.copy("data/source/iat_reuse/main.c", main_c_file)