mirror of
https://github.com/dobin/SuperMega
synced 2026-06-02 17:27:10 +00:00
feature: inject into dll basic support
This commit is contained in:
+11
-5
@@ -45,8 +45,16 @@ Shellcode size : {len(self.shellcodeData)}
|
||||
Code section size : {sect_size}
|
||||
''')
|
||||
|
||||
offset = int((sect_size - len(self.shellcodeData)) / 2)
|
||||
logger.info(f'Inserting shellcode into 0x{offset:X} offset.')
|
||||
if self.superpe.is_dll():
|
||||
offset = self.getExportEntryPoint("BZ2_blockSort")
|
||||
logger.info("Inserting shellcode into DLL at 0x{:X} (sizes: sect {} shellcode {})".format(
|
||||
offset, sect_size, len(self.shellcodeData)
|
||||
))
|
||||
else:
|
||||
offset = int((sect_size - len(self.shellcodeData)) / 2)
|
||||
logger.info("Inserting shellcode into EXE at 0x{:X} (sizes: sect {} shellcode {})".format(
|
||||
offset, sect_size, len(self.shellcodeData)
|
||||
))
|
||||
|
||||
self.superpe.pe.set_bytes_at_offset(offset, self.shellcodeData)
|
||||
self.shellcodeOffset = offset
|
||||
@@ -92,11 +100,9 @@ Trailing {sect_name} bytes:
|
||||
return False
|
||||
|
||||
|
||||
def getExportEntryPoint(self):
|
||||
def getExportEntryPoint(self, exportName):
|
||||
dec = lambda x: '???' if x is None else x.decode()
|
||||
|
||||
#exportName = self.options.get('export', '')
|
||||
exportName = ""
|
||||
if len(exportName) == 0:
|
||||
logger.critical('Export name not specified! Specify DLL Exported function name to hijack with -e/--export')
|
||||
|
||||
|
||||
@@ -34,6 +34,7 @@ class SuperPe():
|
||||
|
||||
|
||||
def __init__(self, infile: str):
|
||||
self.filepath: str = infile
|
||||
self.pe_sections: List[PeSection] = []
|
||||
self.pe = pefile.PE(infile, fast_load=False)
|
||||
for section in self.pe.sections:
|
||||
@@ -47,6 +48,10 @@ class SuperPe():
|
||||
self.ptrSize = 8
|
||||
|
||||
|
||||
def is_dll(self):
|
||||
return self.filepath.endswith(".dll")
|
||||
|
||||
|
||||
def is_64(self) -> bool:
|
||||
return self.arch == 'x64'
|
||||
|
||||
|
||||
Reference in New Issue
Block a user