fix: support large payload (payload len)

This commit is contained in:
Dobin
2024-02-18 19:42:28 +00:00
parent 64c03d86a8
commit 92e9b51409
4 changed files with 12 additions and 1 deletions
+4
View File
@@ -23,6 +23,7 @@ def create_c_from_template(
alloc_style: AllocStyle,
exec_style: ExecStyle,
decoder_style: DecoderStyle,
payload_len: int,
):
plugin_allocator = ""
plugin_decoder = ""
@@ -31,6 +32,9 @@ def create_c_from_template(
filepath = "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)
with open(filepath, "r", encoding='utf-8') as file:
+1 -1
View File
@@ -1 +1 @@
char *dest = VirtualAlloc(NULL, 4096, 0x3000, 0x40);
char *dest = VirtualAlloc(NULL, {{PAYLOAD_LEN}}, 0x3000, 0x40);
+5
View File
@@ -19,6 +19,11 @@ def r2_disas(data: bytes):
f.write(data)
code_len = len(data)
if code_len > 0x2000:
ret['text'] = "Code too long for r2: {}".format(code_len)
ret['color'] = "Code too long for r2: {}".format(code_len)
return ret
r2 = r2pipe.open(filename, flags=['-2'])
r2.cmd('aaa')
+2
View File
@@ -125,6 +125,7 @@ def start():
alloc_style = project.alloc_style,
exec_style = project.exec_style,
decoder_style= project.decoder_style,
payload_len = len(project.payload_data),
)
# Compile: IAT_REUSE loader C -> ASM
if project.generate_asm_from_c:
@@ -153,6 +154,7 @@ def start():
alloc_style = project.alloc_style,
exec_style = project.exec_style,
decoder_style= project.decoder_style,
payload_len = len(project.payload_data),
)
# Compile: PEB_WALK C -> ASM
if project.generate_asm_from_c: