mirror of
https://github.com/dobin/SuperMega
synced 2026-06-03 01:27:11 +00:00
feature: rwx execution
This commit is contained in:
+2
-1
@@ -6,6 +6,7 @@ from helper import *
|
||||
from config import config
|
||||
from observer import observer
|
||||
from project import project
|
||||
from pehelper import *
|
||||
|
||||
|
||||
def make_shc_from_asm(asm_file, exe_file, shc_file):
|
||||
@@ -24,7 +25,7 @@ def make_shc_from_asm(asm_file, exe_file, shc_file):
|
||||
return
|
||||
|
||||
print("---[ EXE to SHC: {} -> {} ]".format(exe_file, shc_file))
|
||||
code = get_code_section(exe_file)
|
||||
code = get_code_section_data(exe_file)
|
||||
with open(shc_file, 'wb') as f:
|
||||
f.write(code)
|
||||
|
||||
|
||||
@@ -45,6 +45,7 @@ def create_c_from_template():
|
||||
with open("build/main.c", "w", encoding='utf-8') as file:
|
||||
file.write(rendered_template)
|
||||
observer.add_text("main_c_rendered", rendered_template)
|
||||
shutil.copy("source/peb_walk/peb_lookup.h", "build/peb_lookup.h")
|
||||
|
||||
else:
|
||||
observer.add_text("main_c", file_readall_text("source/peb_walk/main.c"))
|
||||
|
||||
+19
-19
@@ -29,27 +29,27 @@ def inject_exe(shc_file: FilePath):
|
||||
exe_out
|
||||
])
|
||||
|
||||
# get code section of exe_out
|
||||
code = get_code_section(exe_out)
|
||||
|
||||
# replace IAT in shellcode in code
|
||||
# and re-implant it
|
||||
for cap in exe_capabilities.get_all().values():
|
||||
if not cap.id in code:
|
||||
print("Capability ID {} not found, abort".format(cap.id))
|
||||
raise Exception()
|
||||
|
||||
off = code.index(cap.id)
|
||||
current_address = off + exe_capabilities.image_base + exe_capabilities.text_virtaddr
|
||||
destination_address = cap.addr
|
||||
print(" Replace at 0x{:x} with call to 0x{:x}".format(
|
||||
current_address, destination_address
|
||||
))
|
||||
jmp = assemble_and_disassemble_jump(
|
||||
current_address, destination_address
|
||||
)
|
||||
code = code.replace(cap.id, jmp)
|
||||
write_code_section(exe_out, code)
|
||||
if project.source_style == SourceStyle.iat_reuse:
|
||||
# get code section of exe_out
|
||||
code = get_code_section_data(exe_out)
|
||||
for cap in exe_capabilities.get_all().values():
|
||||
if not cap.id in code:
|
||||
print("Capability ID {} not found, abort".format(cap.id))
|
||||
raise Exception()
|
||||
|
||||
off = code.index(cap.id)
|
||||
current_address = off + exe_capabilities.image_base + exe_capabilities.text_virtaddr
|
||||
destination_address = cap.addr
|
||||
print(" Replace at 0x{:x} with call to 0x{:x}".format(
|
||||
current_address, destination_address
|
||||
))
|
||||
jmp = assemble_and_disassemble_jump(
|
||||
current_address, destination_address
|
||||
)
|
||||
code = code.replace(cap.id, jmp)
|
||||
write_code_section(exe_out, code)
|
||||
|
||||
|
||||
def verify_injected_exe(exefile):
|
||||
|
||||
Reference in New Issue
Block a user