ducky.mm.binary module¶
-
class
ducky.mm.binary.
File
(logger, stream)[source]¶ Bases:
ducky.util.BinaryFile
-
MAGIC
= 57005¶
-
VERSION
= 3¶
-
header
¶
-
sections
¶
-
string_table
¶
-
-
class
ducky.mm.binary.
FileFlags
[source]¶ Bases:
ducky.util.Flags
-
_encoding
¶ alias of
FileFlagsEncoding
-
_flags
= ['reserved']¶
-
_labels
= 'M'¶
-
field
= ('reserved', <class 'ctypes.c_ushort'>, 1)¶
-
-
class
ducky.mm.binary.
FileFlagsEncoding
[source]¶ Bases:
_ctypes.Structure
-
_fields_
= [('reserved', <class 'ctypes.c_ushort'>, 1)]¶
-
reserved
¶ Structure/Union member
-
-
class
ducky.mm.binary.
FileHeader
[source]¶ Bases:
_ctypes.Structure
-
_fields_
= [('magic', <class 'ctypes.c_ushort'>), ('version', <class 'ctypes.c_ushort'>), ('flags', <class 'ducky.mm.binary.FileFlagsEncoding'>), ('sections', <class 'ctypes.c_ushort'>)]¶
-
_pack_
= 0¶
-
flags
¶ Structure/Union member
-
magic
¶ Structure/Union member
-
sections
¶ Structure/Union member
-
version
¶ Structure/Union member
-
-
class
ducky.mm.binary.
RelocEntry
[source]¶ Bases:
_ctypes.Structure
-
_fields_
= [('flags', <class 'ducky.mm.binary.RelocFlagsEncoding'>), ('name', <class 'ctypes.c_uint'>), ('patch_add', <class 'ctypes.c_uint'>), ('patch_address', <class 'ctypes.c_uint'>), ('patch_section', <class 'ctypes.c_ubyte'>), ('patch_offset', <class 'ctypes.c_ubyte'>), ('patch_size', <class 'ctypes.c_ubyte'>)]¶
-
_pack_
= 0¶
-
flags
¶ Structure/Union member
-
name
¶ Structure/Union member
-
patch_add
¶ Structure/Union member
-
patch_address
¶ Structure/Union member
-
patch_offset
¶ Structure/Union member
-
patch_section
¶ Structure/Union member
-
patch_size
¶ Structure/Union member
-
-
class
ducky.mm.binary.
RelocFlags
[source]¶ Bases:
ducky.util.Flags
-
_encoding
¶ alias of
RelocFlagsEncoding
-
_flags
= ['relative', 'inst_aligned']¶
-
_labels
= 'RI'¶
-
field
= ('inst_aligned', <class 'ctypes.c_ushort'>, 1)¶
-
-
class
ducky.mm.binary.
RelocFlagsEncoding
[source]¶ Bases:
_ctypes.Structure
-
_fields_
= [('relative', <class 'ctypes.c_ushort'>, 1), ('inst_aligned', <class 'ctypes.c_ushort'>, 1)]¶
-
inst_aligned
¶ Structure/Union member
-
relative
¶ Structure/Union member
-
-
class
ducky.mm.binary.
Section
(parent, index, name=None, header=None, payload=None)[source]¶ Bases:
object
-
header
¶
-
name
¶
-
payload
¶
-
-
class
ducky.mm.binary.
SectionFlags
[source]¶ Bases:
ducky.util.Flags
-
_encoding
¶ alias of
SectionFlagsEncoding
-
_flags
= ['readable', 'writable', 'executable', 'loadable', 'bss', 'globally_visible']¶
-
_labels
= 'RWXLBG'¶
-
field
= ('globally_visible', <class 'ctypes.c_ubyte'>, 1)¶
-
-
class
ducky.mm.binary.
SectionFlagsEncoding
[source]¶ Bases:
_ctypes.Structure
-
_fields_
= [('readable', <class 'ctypes.c_ubyte'>, 1), ('writable', <class 'ctypes.c_ubyte'>, 1), ('executable', <class 'ctypes.c_ubyte'>, 1), ('loadable', <class 'ctypes.c_ubyte'>, 1), ('bss', <class 'ctypes.c_ubyte'>, 1), ('globally_visible', <class 'ctypes.c_ubyte'>, 1)]¶
-
bss
¶ Structure/Union member
-
executable
¶ Structure/Union member
-
globally_visible
¶ Structure/Union member
-
loadable
¶ Structure/Union member
-
readable
¶ Structure/Union member
-
writable
¶ Structure/Union member
-
-
class
ducky.mm.binary.
SectionHeader
[source]¶ Bases:
_ctypes.Structure
-
_fields_
= [('index', <class 'ctypes.c_ubyte'>), ('name', <class 'ctypes.c_uint'>), ('type', <class 'ctypes.c_ubyte'>), ('flags', <class 'ducky.mm.binary.SectionFlagsEncoding'>), ('padding', <class 'ctypes.c_ubyte'>), ('base', <class 'ctypes.c_uint'>), ('data_size', <class 'ctypes.c_uint'>), ('file_size', <class 'ctypes.c_uint'>), ('offset', <class 'ctypes.c_uint'>)]¶
-
_pack_
= 0¶
-
base
¶ Structure/Union member
-
data_size
¶ Structure/Union member
-
file_size
¶ Structure/Union member
-
flags
¶ Structure/Union member
-
index
¶ Structure/Union member
-
name
¶ Structure/Union member
-
offset
¶ Structure/Union member
-
padding
¶ Structure/Union member
-
type
¶ Structure/Union member
-
-
class
ducky.mm.binary.
SectionTypes
[source]¶ Bases:
enum.IntEnum
-
PROGBITS
= 1¶
-
RELOC
= 4¶
-
STRINGS
= 3¶
-
SYMBOLS
= 2¶
-
UNKNOWN
= 0¶
-
_member_map_
= OrderedDict([('UNKNOWN', <SectionTypes.UNKNOWN: 0>), ('PROGBITS', <SectionTypes.PROGBITS: 1>), ('SYMBOLS', <SectionTypes.SYMBOLS: 2>), ('STRINGS', <SectionTypes.STRINGS: 3>), ('RELOC', <SectionTypes.RELOC: 4>)])¶
-
_member_names_
= ['UNKNOWN', 'PROGBITS', 'SYMBOLS', 'STRINGS', 'RELOC']¶
-
_member_type_
¶ alias of
int
-
_value2member_map_
= {0: <SectionTypes.UNKNOWN: 0>, 1: <SectionTypes.PROGBITS: 1>, 2: <SectionTypes.SYMBOLS: 2>, 3: <SectionTypes.STRINGS: 3>, 4: <SectionTypes.RELOC: 4>}¶
-
-
class
ducky.mm.binary.
SymbolDataTypes
[source]¶ Bases:
enum.IntEnum
-
ASCII
= 5¶
-
BYTE
= 3¶
-
CHAR
= 2¶
-
FUNCTION
= 6¶
-
INT
= 0¶
-
SHORT
= 1¶
-
STRING
= 4¶
-
UNKNOWN
= 7¶
-
_member_map_
= OrderedDict([('INT', <SymbolDataTypes.INT: 0>), ('SHORT', <SymbolDataTypes.SHORT: 1>), ('CHAR', <SymbolDataTypes.CHAR: 2>), ('BYTE', <SymbolDataTypes.BYTE: 3>), ('STRING', <SymbolDataTypes.STRING: 4>), ('ASCII', <SymbolDataTypes.ASCII: 5>), ('FUNCTION', <SymbolDataTypes.FUNCTION: 6>), ('UNKNOWN', <SymbolDataTypes.UNKNOWN: 7>)])¶
-
_member_names_
= ['INT', 'SHORT', 'CHAR', 'BYTE', 'STRING', 'ASCII', 'FUNCTION', 'UNKNOWN']¶
-
_member_type_
¶ alias of
int
-
_value2member_map_
= {0: <SymbolDataTypes.INT: 0>, 1: <SymbolDataTypes.SHORT: 1>, 2: <SymbolDataTypes.CHAR: 2>, 3: <SymbolDataTypes.BYTE: 3>, 4: <SymbolDataTypes.STRING: 4>, 5: <SymbolDataTypes.ASCII: 5>, 6: <SymbolDataTypes.FUNCTION: 6>, 7: <SymbolDataTypes.UNKNOWN: 7>}¶
-
-
class
ducky.mm.binary.
SymbolEntry
[source]¶ Bases:
_ctypes.Structure
-
_fields_
= [('flags', <class 'ducky.mm.binary.SymbolFlagsEncoding'>), ('name', <class 'ctypes.c_uint'>), ('address', <class 'ctypes.c_uint'>), ('size', <class 'ctypes.c_uint'>), ('section', <class 'ctypes.c_ubyte'>), ('type', <class 'ctypes.c_ubyte'>), ('filename', <class 'ctypes.c_uint'>), ('lineno', <class 'ctypes.c_uint'>)]¶
-
_pack_
= 0¶
-
address
¶ Structure/Union member
-
filename
¶ Structure/Union member
-
flags
¶ Structure/Union member
-
lineno
¶ Structure/Union member
-
name
¶ Structure/Union member
-
section
¶ Structure/Union member
-
size
¶ Structure/Union member
-
type
¶ Structure/Union member
-
-
class
ducky.mm.binary.
SymbolFlags
[source]¶ Bases:
ducky.util.Flags
-
_encoding
¶ alias of
SymbolFlagsEncoding
-
_flags
= ['globally_visible']¶
-
_labels
= 'G'¶
-
field
= ('globally_visible', <class 'ctypes.c_ushort'>, 1)¶
-