ui: show some more important information and checks

This commit is contained in:
Dobin
2024-05-01 22:30:53 +01:00
parent 3e6c1e06cf
commit c372d348ce
6 changed files with 52 additions and 10 deletions
+9 -2
View File
@@ -86,10 +86,18 @@
<!-- Row 3: exe and shellcode info -->
<div class="col-2">
x64: {{ is_64 }} / Dotnet: {{ is_dotnet}} <br>
{% if is_64 %}
x64: {{ is_64 }}
{% else %}
<span class="text-danger">x64: {{ is_64 }}</span>
{% endif %}
/ Dotnet: {{ is_dotnet}} <br>
.text: {{ code_sect_size}} <br>
.rodata: {{ data_sect_size}}
(max: {{ data_sect_largest_gap_size}}) <br>
{% if not has_rodata_section %}
<span class="text-danger">No .rodata section</span> <br>
{% endif %}
{% if unresolved_dlls|length > 0 %}
<br>
@@ -129,7 +137,6 @@
</select>
</div>
</div>
</form>
+8 -2
View File
@@ -19,8 +19,14 @@ def index():
@views.route("/exes/<exe_name>")
def exe_view(exe_name):
path = "{}/{}".format(PATH_EXES, exe_name)
superpe = SuperPe(path)
# TODO
filepath = "{}{}".format(PATH_EXES, exe_name)
if not os.path.exists(filepath):
filepath = "{}{}".format(PATH_EXES_MORE, exe_name)
if not os.path.exists(filepath):
return "File not found: {}".format(exe_name)
superpe = SuperPe(filepath)
return render_template('exe.html',
superpe=superpe,
+15 -4
View File
@@ -71,15 +71,25 @@ def project(name):
# when we selected an input file
if project.settings.inject_exe_in != "" and os.path.exists(project.settings.inject_exe_in):
superpe = SuperPe(project.settings.inject_exe_in)
#if not superpe.is_64():
# # return 500
# return "Error: Binary {} is not 64bit".format(project.settings.inject_exe_in), 500
is_64 = superpe.is_64()
is_dotnet = superpe.is_dotnet()
if superpe.is_dll():
exports = superpe.get_exports_full()
code_sect_size = superpe.get_code_section().Misc_VirtualSize
data_sect_size = superpe.get_section_by_name(".rdata").virt_size
exehost = ExeHost(project.settings.inject_exe_in)
exehost.init()
data_sect_largest_gap_size = exehost.get_rdata_relocmanager().find_largest_gap()
if superpe.get_section_by_name(".rdata") != None:
data_sect_size = superpe.get_section_by_name(".rdata").virt_size
else:
logger.warn("No .rdata section found in {}".format(project.settings.inject_exe_in))
has_rodata_section = superpe.has_rodata_section()
if has_rodata_section:
exehost = ExeHost(project.settings.inject_exe_in)
exehost.init()
data_sect_largest_gap_size = exehost.get_rdata_relocmanager().find_largest_gap()
unresolved_dlls = pe.dllresolver.unresolved_dlls(superpe)
@@ -120,6 +130,7 @@ def project(name):
data_sect_largest_gap_size=data_sect_largest_gap_size,
payload_len=payload_len,
unresolved_dlls=unresolved_dlls,
has_rodata_section=has_rodata_section,
has_remote=has_remote,
)
+3 -1
View File
@@ -35,7 +35,9 @@ class ExeHost():
self.superpe = SuperPe(self.filepath)
if not self.superpe.is_64():
raise Exception("Binary is not 64bit: {}".format(self.filepath))
logger.warn("Binary is not 64bit: {}".format(self.filepath))
return
#raise Exception("Binary is not 64bit: {}".format(self.filepath))
# image base
self.image_base = self.superpe.pe.OPTIONAL_HEADER.ImageBase
+4 -1
View File
@@ -107,6 +107,10 @@ class SuperPe():
return section
return None
def has_rodata_section(self) -> bool:
return self.get_section_by_name(".rdata")
def write_code_section_data(self, data: bytes):
sect = self.get_code_section()
@@ -201,7 +205,6 @@ class SuperPe():
self.pe.set_dword_at_rva(addr + relocsSize + 4, sizeOfReloc)
logger.info(f'Adding {len(relocs)} relocations for Page RVA 0x{pageRva:X} - size of block: 0x{sizeOfReloc:X}')
i = 0
for reloc in relocs:
reloc_offset = (reloc - pageRva)
+13
View File
@@ -135,6 +135,9 @@ def start_real(settings: Settings):
# Load our input
project = Project(settings)
project.init()
# check if 64 bit
if not project.exe_host.superpe.is_64():
raise Exception("Binary is not 64bit: {}".format(project.settings.inject_exe_in))
logger.warning("--I FunctionInvokeStyle: {} Inject Mode: {} DecoderStyle: {}".format(
project.settings.source_style.value,
@@ -150,6 +153,16 @@ def start_real(settings: Settings):
c_in = settings.main_c_path,
asm_out = settings.main_asm_path,
carrier = project.carrier)
# we have the required IAT entries in carrier.iat_requests
# Check if all are available, or abort (early check)
if settings.source_style == FunctionInvokeStyle.iat_reuse:
functions = []
for iat in project.carrier.iat_requests:
if project.exe_host.get_vaddr_of_iatentry(iat.name) == None:
functions.append(iat.name)
if len(functions) > 0:
raise Exception("IAT entry not found: {}".format(", ".join(functions)))
# Assemble: Assemble .asm to .shc (ASM -> SHC)
if settings.generate_shc_from_asm: