Пример #1
0
 def createFields(self):
     yield String(self, "header_id", 4, "DataBase Header Markup (\"mhbd\")", charset="ISO-8859-1")
     yield UInt32(self, "header_length", "Header Length")
     yield UInt32(self, "entry_length", "Entry Length")
     yield UInt32(self, "unknown[]")
     yield UInt32(self, "version_number", "Version Number")
     yield UInt32(self, "child_number", "Number of Children")
     yield UInt64(self, "id", "ID for this database")
     yield UInt16(self, "unknown[]")
     yield UInt32(self, "unknown[]")
     yield UInt64(self, "unknown[]")
     yield UInt16(self, "unknown[]")
     yield UInt16(self, "hashing_scheme[]", "Algorithm used to calculate the database hash")
     yield NullBytes(self, "unknown[]", 20)
     yield String(self, "language_id", 2, "Language ID")
     yield UInt64(self, "persistent_id", "Library Persistent ID")
     yield UInt32(self, "unknown[]")
     yield UInt32(self, "unknown[]")
     yield RawBytes(self, "hash[]", 20)
     yield Int32(self, "timezone_offset[]", "Timezone offset in seconds")
     yield UInt16(self, "unknown[]")
     yield RawBytes(self, "iphone_hash[]", 45)
     size = self["header_length"].value - self.current_size / 8
     if size > 0:
         yield NullBytes(self, "padding", size)
     for i in range(self["child_number"].value):
         yield DataSet(self, "dataset[]")
     padding = self.seekByte(self["entry_length"].value, "entry padding")
     if padding:
         yield padding
Пример #2
0
    def createFields(self):
        yield Bytes(self, "jump", 3, "Intel x86 jump instruction")
        yield String(self, "name", 8)
        yield BiosParameterBlock(self, "bios", "BIOS parameters")

        yield textHandler(UInt8(self, "physical_drive", "(0x80)"), hexadecimal)
        yield NullBytes(self, "current_head", 1)
        yield textHandler(
            UInt8(self, "ext_boot_sig", "Extended boot signature (0x80)"),
            hexadecimal)
        yield NullBytes(self, "unused", 1)

        yield UInt64(self, "nb_sectors")
        yield UInt64(self, "mft_cluster", "Cluster location of MFT data")
        yield UInt64(self, "mftmirr_cluster",
                     "Cluster location of copy of MFT")
        yield UInt8(self, "cluster_per_mft", "MFT record size in clusters")
        yield NullBytes(self, "reserved[]", 3)
        yield UInt8(self, "cluster_per_index", "Index block size in clusters")
        yield NullBytes(self, "reserved[]", 3)
        yield textHandler(UInt64(self, "serial_number"), hexadecimal)
        yield textHandler(UInt32(self, "checksum", "Boot sector checksum"),
                          hexadecimal)
        yield Bytes(self, "boot_code", 426)
        yield Bytes(self, "mbr_magic", 2,
                    r"Master boot record magic number (\x55\xAA)")
Пример #3
0
 def createFields(self):
     yield NullBytes(self, "unused", 6)
     yield UInt8(self, "offsetIntSize", "Size (in bytes) of offsets in the offset table")
     yield UInt8(self, "objectRefSize", "Size (in bytes) of object numbers in object references")
     yield UInt64(self, "numObjects", "Number of objects in this file")
     yield UInt64(self, "topObject", "Top-level object reference")
     yield UInt64(self, "offsetTableOffset", "File offset to the offset table")
Пример #4
0
 def createFields(self):
     yield UInt32(self, "unknown[]", "Version number?")
     yield UInt32(self, "count", "Number of entries")
     yield UInt32(self, "entry_size", "Size of each entry")
     yield UInt32(self, "header_size", "Size of this header")
     yield UInt64(self, "uncompressed_size")
     yield UInt64(self, "compressed_size")
     yield UInt64(self, "block_size", "Block size in bytes")
     for i in range(self["count"].value):
         yield UInt64(self, "block_location[]", "location in compressed data of 1st block boundary in uncompressed data")
Пример #5
0
 def createFields(self):
     yield String(self, "segname", 16, strip="\0")
     yield textHandler(UInt64(self, "vmaddr"), hexadecimal)
     yield textHandler(UInt64(self, "vmsize"), hexadecimal)
     yield textHandler(UInt64(self, "fileoff"), hexadecimal)
     yield textHandler(UInt64(self, "filesize"), hexadecimal)
     yield UInt32(self, "maxprot")
     yield UInt32(self, "initprot")
     yield UInt32(self, "nsects")
     yield UInt32(self, "flags")
     for i in range(self['nsects'].value):
         yield MachoSection64(self, "section[]")
Пример #6
0
 def parseStandardInfo(self):
     yield TimestampWin64(self, "ctime", "File Creation")
     yield TimestampWin64(self, "atime", "File Altered")
     yield TimestampWin64(self, "mtime", "MFT Changed")
     yield TimestampWin64(self, "rtime", "File Read")
     yield MSDOSFileAttr32(self, "file_attr", "DOS File Permissions")
     yield UInt32(self, "max_version", "Maximum Number of Versions")
     yield UInt32(self, "version", "Version Number")
     yield UInt32(self, "class_id")
     yield UInt32(self, "owner_id")
     yield UInt32(self, "security_id")
     yield filesizeHandler(UInt64(self, "quota_charged", "Quota Charged"))
     yield UInt64(self, "usn", "Update Sequence Number (USN)")
Пример #7
0
 def createFields(self):
     yield String(self, "sectname", 16, strip="\0")
     yield String(self, "segname", 16, strip="\0")
     yield textHandler(UInt64(self, "addr"), hexadecimal)
     yield textHandler(UInt64(self, "size"), hexadecimal)
     yield textHandler(UInt32(self, "offset"), hexadecimal)
     yield textHandler(UInt32(self, "align"), hexadecimal)
     yield textHandler(UInt32(self, "reloff"), hexadecimal)
     yield UInt32(self, "nreloc")
     yield UInt32(self, "flags")
     yield UInt32(self, "reserved1")
     yield UInt32(self, "reserved2")
     yield RawBytes(self, "padding", 4)
Пример #8
0
def parseVideoHeader(parent):
    yield NullBytes(parent, "padding[]", 2)
    yield String(parent, "fourcc", 4)
    yield UInt32(parent, "size")
    yield textHandler(UInt64(parent, "time_unit", "Frame duration"),
                      formatTimeUnit)
    yield UInt64(parent, "sample_per_unit")
    yield UInt32(parent, "default_len")
    yield UInt32(parent, "buffer_size")
    yield UInt16(parent, "bits_per_sample")
    yield NullBytes(parent, "padding[]", 2)
    yield UInt32(parent, "width")
    yield UInt32(parent, "height")
    yield NullBytes(parent, "padding[]", 4)
Пример #9
0
    def createFields(self):
        yield Bytes(self, "signature", 4, "Usually the magic is 'FILE'")
        yield UInt16(self, "usa_offset", "Update Sequence Array offset")
        yield UInt16(self, "usa_count", "Update Sequence Array count")
        yield UInt64(self, "lsn", "$LogFile sequence number for this record")
        yield UInt16(self, "sequence_number",
                     "Number of times this mft record has been reused")
        yield UInt16(self, "link_count", "Number of hard links")
        yield UInt16(self, "attrs_offset",
                     "Byte offset to the first attribute")
        yield MFT_Flags(self, "flags")
        yield UInt32(self, "bytes_in_use",
                     "Number of bytes used in this record")
        yield UInt32(self, "bytes_allocated",
                     "Number of bytes allocated for this record")
        yield UInt64(self, "base_mft_record")
        yield UInt16(self, "next_attr_instance")

        # The below fields are specific to NTFS 3.1+ (Windows XP and above)
        yield NullBytes(self, "reserved", 2)
        yield UInt32(self, "mft_record_number", "Number of this mft record")

        if self["usa_offset"].value:
            padding = self.seekByte(self["usa_offset"].value, relative=True)
            if padding:
                yield padding

            yield UInt16(self, "usa_number")
            for i in range(self["usa_count"].value):
                yield UInt16(self, "usa_value[]")

        padding = self.seekByte(self["attrs_offset"].value, relative=True)
        if padding:
            yield padding

        while not self.eof:
            addr = self.absolute_address + self.current_size
            if self.stream.readBytes(addr, 4) == b"\xFF\xFF\xFF\xFF":
                yield Bytes(self, "attr_end_marker", 8)
                break
            yield Attribute(self, "attr[]")

        size = self["bytes_in_use"].value - self.current_size // 8
        if size:
            yield RawBytes(self, "end_rawdata", size)

        size = (self.size - self.current_size) // 8
        if size:
            yield RawBytes(self, "end_padding", size,
                           "Unused but allocated bytes")
Пример #10
0
 def createFields(self):
     yield GUID(self, "guid")
     yield filesizeHandler(UInt64(self, "file_size"))
     yield TimestampWin64(self, "creation_date")
     yield UInt64(self, "pckt_count")
     yield TimedeltaWin64(self, "play_duration")
     yield TimedeltaWin64(self, "send_duration")
     yield TimedeltaMillisWin64(self, "preroll")
     yield Bit(self, "broadcast", "Is broadcast?")
     yield Bit(self, "seekable", "Seekable stream?")
     yield PaddingBits(self, "reserved[]", 30)
     yield filesizeHandler(UInt32(self, "min_pckt_size"))
     yield filesizeHandler(UInt32(self, "max_pckt_size"))
     yield displayHandler(UInt32(self, "max_bitrate"), humanBitRate)
Пример #11
0
    def createFields(self):
        yield String(self, "file_magic", 20)
        yield UInt32(self, "header_size")
        yield UInt32(self, "file_version")
        yield UInt64(self, "file_size")
        yield UInt64(self, "creation_date")
        yield Int32(self, "min_lat")
        yield Int32(self, "min_lon")
        yield Int32(self, "max_lat")
        yield Int32(self, "max_lon")
        yield UInt16(self, "tile_size")
        yield VbeString(self, "projection")

        # flags
        yield Bit(self, "have_debug")
        yield Bit(self, "have_map_start")
        yield Bit(self, "have_start_zoom")
        yield Bit(self, "have_language_preference")
        yield Bit(self, "have_comment")
        yield Bit(self, "have_created_by")
        yield Bits(self, "reserved[]", 2)

        if self["have_map_start"].value:
            yield UInt32(self, "start_lat")
            yield UInt32(self, "start_lon")
        if self["have_start_zoom"].value:
            yield UInt8(self, "start_zoom")
        if self["have_language_preference"].value:
            yield VbeString(self, "language_preference")
        if self["have_comment"].value:
            yield VbeString(self, "comment")
        if self["have_created_by"].value:
            yield VbeString(self, "created_by")

        yield TagStringList(self, "poi_tags")
        yield TagStringList(self, "way_tags")

        yield UInt8(self, "num_zoom_intervals")
        for i in range(self["num_zoom_intervals"].value):
            yield ZoomIntervalCfg(self, "zoom_interval_cfg[]")

        for i in range(self["num_zoom_intervals"].value):
            zoomIntervalCfg = self["zoom_interval_cfg[%d]" % i]
            self.seekByte(zoomIntervalCfg["subfile_start"].value,
                          relative=False)
            yield ZoomSubFile(self,
                              "subfile[]",
                              size=zoomIntervalCfg["subfile_size"].value * 8,
                              zoomIntervalCfg=zoomIntervalCfg)
Пример #12
0
 def createFields(self):
     yield String(self, "magic", 4, "ITSF", charset="ASCII")
     yield UInt32(self, "version")
     yield UInt32(self, "header_size", "Total header length (in bytes)")
     yield UInt32(self, "one")
     yield UInt32(self, "last_modified", "Lower 32 bits of the time expressed in units of 0.1 us")
     yield Enum(UInt32(self, "lang_id", "Windows Language ID"), LANGUAGE_ID)
     yield GUID(self, "dir_uuid", "{7C01FD10-7BAA-11D0-9E0C-00A0-C922-E6EC}")
     yield GUID(self, "stream_uuid", "{7C01FD11-7BAA-11D0-9E0C-00A0-C922-E6EC}")
     yield UInt64(self, "filesize_offset")
     yield filesizeHandler(UInt64(self, "filesize_len"))
     yield UInt64(self, "dir_offset")
     yield filesizeHandler(UInt64(self, "dir_len"))
     if 3 <= self["version"].value:
         yield UInt64(self, "data_offset")
Пример #13
0
    def createFields(self):
        # Header
        yield NullBytes(self, "zero_vector", 16)
        yield GUID(self, "fs_guid")
        yield UInt64(self, "volume_len")
        yield String(self, "signature", 4)
        yield UInt32(self, "attributes")
        yield UInt16(self, "header_len")
        yield UInt16(self, "checksum")
        yield UInt16(self, "ext_header_offset")
        yield UInt8(self, "reserved")
        yield UInt8(self, "revision")
        while True:
            bm = BlockMap(self, "block_map[]")
            yield bm
            if bm['num_blocks'].value == 0 and bm['len'].value == 0:
                break
        # TODO must handle extended header

        # Content
        while not self.eof:
            padding = paddingSize(self.current_size // 8, 8)
            if padding:
                yield PaddingBytes(self, "padding[]", padding)
            yield File(self, "file[]")
Пример #14
0
 def createFields(self):
     bytes = self.stream.readBytes(self.absolute_address, 4)
     if bytes == b"\0R\0\0":
         charset = "UTF-16-BE"
     else:
         charset = "UTF-16-LE"
     yield String(self, "name", 64, charset=charset, truncate="\0")
     yield UInt16(self, "namelen", "Length of the name")
     yield Enum(UInt8(self, "type", "Property type"), self.TYPE_NAME)
     yield Enum(UInt8(self, "decorator", "Decorator"), self.DECORATOR_NAME)
     yield SECT(self, "left")
     yield SECT(self, "right")
     yield SECT(self, "child",
                "Child node (valid for storage and root types)")
     yield GUID(self, "clsid",
                "CLSID of this storage (valid for storage and root types)")
     yield NullBytes(self, "flags", 4, "User flags")
     yield TimestampWin64(
         self, "creation",
         "Creation timestamp(valid for storage and root types)")
     yield TimestampWin64(
         self, "lastmod",
         "Modify timestamp (valid for storage and root types)")
     yield SECT(
         self, "start",
         "Starting SECT of the stream (valid for stream and root types)")
     if self["/header/bb_shift"].value == 9:
         yield filesizeHandler(
             UInt32(self, "size",
                    "Size in bytes (valid for stream and root types)"))
         yield NullBytes(self, "padding", 4)
     else:
         yield filesizeHandler(
             UInt64(self, "size",
                    "Size in bytes (valid for stream and root types)"))
Пример #15
0
    def createFields(self):
        yield String(self, "header_id", 4, "Playlist Header Markup (\"mhyp\")", charset="ISO-8859-1")
        yield UInt32(self, "header_length", "Header Length")
        yield UInt32(self, "entry_length", "Entry Length")
        yield UInt32(self, "data_object_child_count", "Number of Child Data Objects")
        yield UInt32(self, "playlist_count", "Number of Playlist Items")
        yield Enum(UInt8(self, "type", "Normal or master playlist?"), self.is_master_pl_name)
        yield UInt8(self, "XXX1", "XXX1")
        yield UInt8(self, "XXX2", "XXX2")
        yield UInt8(self, "XXX3", "XXX3")
        yield TimestampMac32(self, "creation_date", "Date when the playlist was created")
        yield UInt64(self, "playlistid", "Persistent Playlist ID")
        yield UInt32(self, "unk3", "unk3")
        yield UInt16(self, "string_mhod_count", "Number of string MHODs for this playlist")
        yield Enum(UInt16(self, "is_podcast", "Playlist or Podcast List?"), self.is_podcast_name)
        yield Enum(UInt32(self, "sort_order", "Playlist Sort Order"), self.list_sort_order_name)

        padding = self.seekByte(self["header_length"].value, "entry padding")
        if padding:
            yield padding

        for i in range(self["data_object_child_count"].value):
            yield DataObject(self, "mhod[]")

        for i in range(self["playlist_count"].value):
            yield PlaylistItem(self, "playlist_item[]")
Пример #16
0
 def parseFilename(self):
     yield UInt64(self, "ref", "File reference to the parent directory")
     yield TimestampWin64(self, "ctime", "File Creation")
     yield TimestampWin64(self, "atime", "File Altered")
     yield TimestampWin64(self, "mtime", "MFT Changed")
     yield TimestampWin64(self, "rtime", "File Read")
     yield filesizeHandler(
         UInt64(self, "alloc_size", "Allocated size of the file"))
     yield filesizeHandler(
         UInt64(self, "real_size", "Real size of the file"))
     yield UInt32(self, "file_flags")
     yield UInt32(self, "file_flags2", "Used by EAs and Reparse")
     yield UInt8(self, "filename_length", "Filename length in characters")
     yield Enum(UInt8(self, "filename_namespace"), self.FILENAME_NAMESPACE)
     size = self["filename_length"].value * 2
     if size:
         yield String(self, "filename", size, charset="UTF-16-LE")
Пример #17
0
 def createFields(self):
     yield UInt64(self, "zip64_end_size",
                  "Size of zip64 end of central directory record")
     yield ZipVersion(self, "version_made_by", "Version made by")
     yield ZipVersion(self, "version_needed", "Version needed to extract")
     yield UInt32(self, "number_disk", "Number of this disk")
     yield UInt32(self, "number_disk2",
                  "Number of the disk with the start of the central directory")
     yield UInt64(self, "number_entries",
                  "Total number of entries in the central directory on this disk")
     yield UInt64(self, "number_entries2",
                  "Total number of entries in the central directory")
     yield UInt64(self, "size", "Size of the central directory")
     yield UInt64(self, "offset", "Offset of start of central directory")
     if 0 < self["zip64_end_size"].value:
         yield RawBytes(self, "data_sector", self["zip64_end_size"].value,
                        "zip64 extensible data sector")
Пример #18
0
    def createFields(self):
        yield GUID(self, "guid")
        yield filesizeHandler(UInt64(self, "size"))

        size = self["size"].value - self.current_size // 8
        if 0 < size:
            if self.handler:
                yield self.handler(self, "content", size=size * 8)
            else:
                yield RawBytes(self, "content", size)
Пример #19
0
 def createFields(self):
     yield SymbolStringTableOffset(
         self, "name",
         "Section name (index into section header string table)")
     yield Enum(
         textHandler(UInt32(self, "type", "Section type"), hexadecimal),
         self.TYPE_NAME)
     yield SectionFlags(self, "flags", "Section flags")
     yield textHandler(UInt64(self, "VMA", "Virtual memory address"),
                       hexadecimal)
     yield textHandler(
         UInt64(self, "LMA", "Logical memory address (offset in file)"),
         hexadecimal)
     yield textHandler(UInt64(self, "size", "Section size (bytes)"),
                       hexadecimal)
     yield UInt32(self, "link", "Index of a related section")
     yield UInt32(self, "info", "Type-dependent information")
     yield UInt64(self, "addr_align", "Address alignment (bytes)")
     yield UInt64(self, "entry_size", "Size of each entry in section")
Пример #20
0
 def createFields(self):
     yield textHandler(UInt64(self, "id"), hexadecimal)
     if self["id"].value == 0xe7ffdeffe7ffdeff:  # indicates that secure area is decrypted
         yield Bytes(self, "fixed[]", 6)  # always \xff\xde\xff\xe7\xff\xde
         yield Crc16(
             self, "header_crc16",
             self.stream.readBytes(self.absolute_address + (16 * 8),
                                   2048 - 16))
         yield RawBytes(self, "unknown[]", 2048 - 16 - 2)
         yield Bytes(self, "fixed[]", 2)  # always \0\0
     else:
         yield RawBytes(self, "encrypted[]", 2048 - 8)
Пример #21
0
 def createFields(self):
     yield PascalString16(self, "name", "Name", charset="UTF-16-LE", strip="\0")
     yield Enum(UInt16(self, "type"), self.TYPE_NAME)
     yield UInt16(self, "value_length")
     type = self["type"].value
     size = self["value_length"].value
     name = "value"
     if type == 0 and (size % 2) == 0:
         yield String(self, name, size, charset="UTF-16-LE", strip="\0")
     elif type in (2, 3):
         yield UInt32(self, name)
     elif type == 4:
         yield UInt64(self, name)
     else:
         yield RawBytes(self, name, size)
Пример #22
0
 def createFields(self):
     yield Enum(UInt32(self, "type", "Segment type"),
                ProgramHeader32.TYPE_NAME)
     yield ProgramFlags(self, "flags")
     yield UInt64(self, "offset", "Offset")
     yield textHandler(UInt64(self, "vaddr", "V. address"), hexadecimal)
     yield textHandler(UInt64(self, "paddr", "P. address"), hexadecimal)
     yield UInt64(self, "file_size", "File size")
     yield UInt64(self, "mem_size", "Memory size")
     yield UInt64(self, "align", "Alignment padding")
Пример #23
0
 def createFields(self):
     yield String(self, 'capture_pattern', 4, charset="ASCII")
     if self['capture_pattern'].value != "OggS":
         self.warning(
             'Invalid signature. An Ogg page must start with "OggS".')
     yield UInt8(self, 'stream_structure_version')
     yield Bit(self, 'continued_packet')
     yield Bit(self, 'first_page')
     yield Bit(self, 'last_page')
     yield NullBits(self, 'unused', 5)
     yield UInt64(self, 'abs_granule_pos')
     yield textHandler(UInt32(self, 'serial'), hexadecimal)
     yield UInt32(self, 'page')
     yield textHandler(UInt32(self, 'checksum'), hexadecimal)
     yield UInt8(self, 'lacing_size')
     if self.lacing_size:
         yield Lacing(self, "lacing", size=self.lacing_size * 8)
         yield Segments(self,
                        "segments",
                        size=self._size - self._current_size)
Пример #24
0
    def createFields(self):
        yield ITSF(self, "itsf")
        yield Filesize_Header(self, "file_size", size=self["itsf/filesize_len"].value * 8)

        self.seekByte(self["itsf/dir_offset"].value)
        directory = Directory(self, "dir", size=self["itsf/dir_len"].value * 8)
        yield directory

        otherentries = {}
        for pmgl in directory.array("pmgl"):
            for entry in pmgl.array("entry"):
                if entry["section"].value != 0:
                    otherentries.setdefault(
                        entry["section"].value, []).append(entry)
                    continue
                if entry["length"].value == 0:
                    continue
                self.seekByte(
                    self["itsf/data_offset"].value + entry["start"].value)
                name = entry["name"].value
                if name == "::DataSpace/NameList":
                    yield NameList(self, "name_list")
                elif name.startswith('::DataSpace/Storage/'):
                    sectname = str(name.split('/')[2])
                    if name.endswith('/SpanInfo'):
                        yield UInt64(self, "%s_spaninfo" % sectname, "Size of uncompressed data in the %s section" % sectname)
                    elif name.endswith('/ControlData'):
                        yield ControlData(self, "%s_controldata" % sectname, "Data about the compression scheme", size=entry["length"].value * 8)
                    elif name.endswith('/Transform/List'):
                        yield String(self, "%s_transform_list" % sectname, 38, description="Transform/List element", charset="UTF-16-LE")
                    elif name.endswith('/Transform/{7FC28940-9D31-11D0-9B27-00A0C91E9C7C}/InstanceData/ResetTable'):
                        yield ResetTable(self, "%s_reset_table" % sectname, "LZX Reset Table", size=entry["length"].value * 8)
                    elif name.endswith('/Content'):
                        # eventually, a LZX wrapper will appear here, we hope!
                        yield RawBytes(self, "%s_content" % sectname, entry["length"].value, "Content for the %s section" % sectname)
                    else:
                        yield RawBytes(self, "entry_data[]", entry["length"].value, name)
                elif name == "/#SYSTEM":
                    yield SystemFile(self, "system_file", size=entry["length"].value * 8)
                else:
                    yield RawBytes(self, "entry_data[]", entry["length"].value, name)
Пример #25
0
 def createFields(self):
     yield GUID(self, "type")
     yield GUID(self, "error_correction")
     yield UInt64(self, "time_offset")
     yield UInt32(self, "data_len")
     yield UInt32(self, "error_correct_len")
     yield Bits(self, "stream_index", 7)
     yield Bits(self, "reserved[]", 8)
     yield Bit(self, "encrypted", "Content is encrypted?")
     yield UInt32(self, "reserved[]")
     size = self["data_len"].value
     if size:
         tag = self["type"].value
         if tag in Object.TAG_INFO:
             name, parser = Object.TAG_INFO[tag][0:2]
             yield parser(self, name, size=size * 8)
         else:
             yield RawBytes(self, "data", size)
     size = self["error_correct_len"].value
     if size:
         yield RawBytes(self, "error_correct", size)
Пример #26
0
def specialHeader(s, is_file):
    yield filesizeHandler(
        UInt32(s, "compressed_size", "Compressed size (bytes)"))
    yield filesizeHandler(
        UInt32(s, "uncompressed_size", "Uncompressed size (bytes)"))
    yield Enum(UInt8(s, "host_os", "Operating system used for archiving"),
               OS_NAME)
    yield textHandler(UInt32(s, "crc32", "File CRC32"), hexadecimal)
    yield TimeDateMSDOS32(s, "ftime", "Date and time (MS DOS format)")
    yield textHandler(
        UInt8(s, "version", "RAR version needed to extract file"),
        formatRARVersion)
    yield Enum(UInt8(s, "method", "Packing method"), COMPRESSION_NAME)
    yield filesizeHandler(UInt16(s, "filename_length", "File name size"))
    if s["host_os"].value in (OS_MSDOS, OS_WIN32):
        yield MSDOSFileAttr32(s, "file_attr", "File attributes")
    else:
        yield textHandler(UInt32(s, "file_attr", "File attributes"),
                          hexadecimal)

    # Start additional field from unrar
    if s["flags/is_large"].value:
        yield filesizeHandler(
            UInt64(s, "large_size", "Extended 64bits filesize"))

    # End additional field
    size = s["filename_length"].value
    if size > 0:
        if s["flags/is_unicode"].value:
            charset = "UTF-8"
        else:
            charset = "ISO-8859-15"
        yield String(s, "filename", size, "Filename", charset=charset)
    # Start additional fields from unrar - file only
    if is_file:
        if s["flags/has_salt"].value:
            yield textHandler(UInt8(s, "salt", "Salt"), hexadecimal)
        if s["flags/has_ext_time"].value:
            yield ExtTime(s, "extra_time", "Extra time info")
Пример #27
0
    def createFields(self):
        yield String(self, "header_id", 4, "Track Item Header Markup (\"mhit\")", charset="ISO-8859-1")
        yield UInt32(self, "header_length", "Header Length")
        yield UInt32(self, "entry_length", "Entry Length")
        yield UInt32(self, "string_number", "Number of Strings")
        yield UInt32(self, "unique_id", "Unique ID")
        yield UInt32(self, "visible_tag", "Visible Tag")
        yield String(self, "file_type", 4, "File Type")
        yield Enum(UInt8(self, "x1_type", "Extended Type 1"), self.x1_type_name)
        yield Enum(UInt8(self, "x2_type", "Extended type 2"), self.x2_type_name)
        yield UInt8(self, "compilation_flag", "Compilation Flag")
        yield UInt8(self, "rating", "Rating")
        yield TimestampMac32(self, "last_modified", "Time of the last modification of the track")
        yield filesizeHandler(UInt32(self, "size", "Track size in bytes"))
        yield displayHandler(UInt32(self, "length", "Track length in milliseconds"), humanDuration)
        yield UInt32(self, "track_number", "Number of this track")
        yield UInt32(self, "total_track", "Total number of tracks")
        yield UInt32(self, "year", "Year of the track")
        yield UInt32(self, "bitrate", "Bitrate")
        yield UInt32(self, "samplerate", "Sample Rate")
        yield UInt32(self, "volume", "volume")
        yield UInt32(self, "start_time", "Start playing at, in milliseconds")
        yield UInt32(self, "stop_time", "Stop playing at,  in milliseconds")
        yield UInt32(self, "soundcheck", "SoundCheck preamp")
        yield UInt32(self, "playcount_1", "Play count of the track")
        yield UInt32(self, "playcount_2", "Play count of the track when last synced")
        yield TimestampMac32(self, "last_played_time", "Time the song was last played")
        yield UInt32(self, "disc_number", "disc number in multi disc sets")
        yield UInt32(self, "total_discs", "Total number of discs in the disc set")
        yield UInt32(self, "userid", "User ID in the DRM scheme")
        yield TimestampMac32(self, "added_date", "Date when the item was added")
        yield UInt32(self, "bookmark_time", "Bookmark time for AudioBook")
        yield UInt64(self, "dbid", "Unique DataBase ID for the song (identical in mhit and in mhii)")
        yield UInt8(self, "checked", "song is checked")
        yield UInt8(self, "application_rating", "Last Rating before change")
        yield UInt16(self, "BPM", "BPM of the track")
        yield UInt16(self, "artwork_count", "number of artworks for this item")
        yield UInt16(self, "unknown[]")
        yield UInt32(self, "artwork_size", "Total size of artworks in bytes")
        yield UInt32(self, "unknown[]")
        yield Float32(self, "sample_rate_2", "Sample Rate express in float")
        yield UInt32(self, "released_date", "Date of release in Music Store or in Podcast")
        yield UInt16(self, "unknown[]")
        yield UInt16(self, "explicit_flag[]", "Explicit flag")
        yield UInt32(self, "unknown[]")
        yield UInt32(self, "unknown[]")
        yield UInt32(self, "skip_count[]", "Skip Count")
        yield TimestampMac32(self, "last_skipped", "Date when the item was last skipped")
        yield UInt8(self, "has_artwork", "0x01 for track with artwork, 0x02 otherwise")
        yield UInt8(self, "skip_wen_shuffling", "Skip that track when shuffling")
        yield UInt8(self, "remember_playback_position", "Remember playback position")
        yield UInt8(self, "flag4", "Flag 4")
        yield UInt64(self, "dbid2", "Unique DataBase ID for the song (identical as above)")
        yield UInt8(self, "lyrics_flag", "Lyrics Flag")
        yield UInt8(self, "movie_file_flag", "Movie File Flag")
        yield UInt8(self, "played_mark", "Track has been played")
        yield UInt8(self, "unknown[]")
        yield UInt32(self, "unknown[]")
        yield UInt32(self, "pregap[]", "Number of samples of silence before the song starts")
        yield UInt64(self, "sample_count", "Number of samples in the song (only for WAV and AAC files)")
        yield UInt32(self, "unknown[]")
        yield UInt32(self, "postgap[]", "Number of samples of silence at the end of the song")
        yield UInt32(self, "unknown[]")
        yield Enum(UInt32(self, "media_type", "Media Type for video iPod"), self.media_type_name)
        yield UInt32(self, "season_number", "Season Number")
        yield UInt32(self, "episode_number", "Episode Number")
        yield UInt32(self, "unknown[]")
        yield UInt32(self, "unknown[]")
        yield UInt32(self, "unknown[]")
        yield UInt32(self, "unknown[]")
        yield UInt32(self, "unknown[]")
        yield UInt32(self, "unknown[]")
        yield UInt32(self, "unknown[]")
        yield UInt32(self, "gapless_data[]", "The size in bytes from first Sync Frame until the 8th before the last frame.")
        yield UInt32(self, "unknown[]")
        yield UInt16(self, "gaplessTrackFlag[]", "1 if track has gapless data")
        yield UInt16(self, "gaplessAlbumFlag[]", "1 if track uses crossfading in iTunes")
        yield RawBytes(self, "unknown[]", 20)
        yield UInt32(self, "unknown[]")
        yield UInt32(self, "unknown[]")
        yield UInt32(self, "unknown[]")
        yield UInt32(self, "unknown[]")
        yield UInt16(self, "unknown[]")
        yield UInt16(self, "album_id[]", "Album ID (used to link tracks with MHIAs)")
        yield RawBytes(self, "unknown[]", 52)
        yield UInt32(self, "mhii_link[]", "Artwork ID (used to link tracks with MHIIs)")
        padding = self.seekByte(self["header_length"].value, "header padding")
        if padding:
            yield padding

        # while ((self.stream.readBytes(0, 4) == b'mhod') and
        # ((self.current_size//8) < self["entry_length"].value)):
        for i in range(self["string_number"].value):
            yield DataObject(self, "data[]")
        padding = self.seekBit(self._size, "entry padding")
        if padding:
            yield padding
Пример #28
0
 def createFields(self):
     yield NullBytes(self, "unused[]", 1)
     yield String(self, "system_id", 32, "System identifier", strip=" ")
     yield String(self, "volume_id", 32, "Volume identifier", strip=" ")
     yield NullBytes(self, "unused[]", 8)
     yield UInt64(self, "space_size", "Volume space size")
     yield NullBytes(self, "unused[]", 32)
     yield UInt32(self, "set_size", "Volume set size")
     yield UInt32(self, "seq_num", "Sequence number")
     yield UInt32(self, "block_size", "Block size")
     yield UInt64(self, "path_table_size", "Path table size")
     yield UInt32(self, "occu_lpath",
                  "Location of Occurrence of Type L Path Table")
     yield UInt32(self, "opt_lpath",
                  "Location of Optional of Type L Path Table")
     yield UInt32(self, "occu_mpath",
                  "Location of Occurrence of Type M Path Table")
     yield UInt32(self, "opt_mpath",
                  "Location of Optional of Type M Path Table")
     yield RawBytes(self, "root", 34, "Directory Record for Root Directory")
     yield String(self,
                  "vol_set_id",
                  128,
                  "Volume set identifier",
                  strip=" ")
     yield String(self, "publisher", 128, "Publisher identifier", strip=" ")
     yield String(self,
                  "data_preparer",
                  128,
                  "Data preparer identifier",
                  strip=" ")
     yield String(self,
                  "application",
                  128,
                  "Application identifier",
                  strip=" ")
     yield String(self,
                  "copyright",
                  37,
                  "Copyright file identifier",
                  strip=" ")
     yield String(self,
                  "abstract",
                  37,
                  "Abstract file identifier",
                  strip=" ")
     yield String(self,
                  "biographic",
                  37,
                  "Biographic file identifier",
                  strip=" ")
     yield String(self,
                  "creation_ts",
                  17,
                  "Creation date and time",
                  strip=" ")
     yield String(self,
                  "modification_ts",
                  17,
                  "Modification date and time",
                  strip=" ")
     yield String(self,
                  "expiration_ts",
                  17,
                  "Expiration date and time",
                  strip=" ")
     yield String(self,
                  "effective_ts",
                  17,
                  "Effective date and time",
                  strip=" ")
     yield UInt8(self, "struct_ver", "Structure version")
     yield NullBytes(self, "unused[]", 1)
     yield String(self, "app_use", 512, "Application use", strip=" \0")
     yield NullBytes(self, "unused[]", 653)
Пример #29
0
 def createFields(self):
     yield UInt8(self, "base_zoom_level")
     yield UInt8(self, "min_zoom_level")
     yield UInt8(self, "max_zoom_level")
     yield UInt64(self, "subfile_start")
     yield UInt64(self, "subfile_size")
Пример #30
0
 def createFields(self):
     yield GUID(self, "file_id")
     yield UInt64(self, "packet_count")
     yield PaddingBytes(self, "reserved", 2)
     size = (self.size - self.current_size) // 8
     yield RawBytes(self, "data", size)