Ejemplo n.º 1
0
    def createFields(self):
        yield UInt16(self, "size", "Node size (in bytes)")
        yield UInt16(self, "data_size")
        yield Enum(UInt16(self, "type"), self.TYPE_NAME)
        yield CString(self, "name", charset="UTF-16-LE")

        size = paddingSize(self.current_size//8, 4)
        if size:
            yield NullBytes(self, "padding[]", size)
        size = self["data_size"].value
        if size:
            if self["type"].value == self.TYPE_STRING:
                if self.is_32bit:
                    size *= 2
                yield String(self, "value", size, charset="UTF-16-LE", truncate="\0")
            elif self["name"].value == "VS_VERSION_INFO":
                yield VersionInfoBinary(self, "value", size=size*8)
                if self["value/file_flags_mask"].value == 0:
                    self.is_32bit = False
            else:
                yield RawBytes(self, "value", size)
        while 12 <= (self.size - self.current_size) // 8:
            yield VersionInfoNode(self, "node[]", self.is_32bit)
        size = (self.size - self.current_size) // 8
        if size:
            yield NullBytes(self, "padding[]", size)
Ejemplo n.º 2
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[]")
Ejemplo n.º 3
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[]")
Ejemplo n.º 4
0
    def createFields(self):
        yield UInt16(self, "length", "Length of Item ID Entry")
        if not self["length"].value:
            return

        yield Enum(UInt8(self, "type"),self.ITEM_TYPE)
        entrytype=self["type"].value
        if entrytype in (0x1F, 0x2E, 0x70):
            # GUID
            yield RawBytes(self, "dummy", 1, "should be 0x50")
            yield GUID(self, "guid")

        elif entrytype in (0x23, 0x25, 0x29, 0x2F):
            # Drive
            yield String(self, "drive", self["length"].value-3, strip="\0")

        elif entrytype in (0x30, 0x31, 0x32):
            yield RawBytes(self, "dummy", 1, "should be 0x00")
            yield UInt32(self, "size", "size of file; 0 for folders")
            yield DateTimeMSDOS32(self, "date_time", "File/folder date and time")
            yield MSDOSFileAttr16(self, "attribs", "File/folder attributes")
            yield CString(self, "name", "File/folder name")
            if self.root.hasUnicodeNames():
                # Align to 2-bytes
                n = paddingSize(self.current_size//8, 2)
                if n:
                    yield PaddingBytes(self, "pad", n)

                yield UInt16(self, "length_w", "Length of wide struct member")
                yield RawBytes(self, "unknown[]", 6)
                yield DateTimeMSDOS32(self, "creation_date_time", "File/folder creation date and time")
                yield DateTimeMSDOS32(self, "access_date_time", "File/folder last access date and time")
                yield RawBytes(self, "unknown[]", 4)
                yield CString(self, "unicode_name", "File/folder name", charset="UTF-16-LE")
                yield RawBytes(self, "unknown[]", 2)
            else:
                yield CString(self, "name_short", "File/folder short name")

        elif entrytype in (0x41, 0x42, 0x46):
            yield RawBytes(self, "unknown[]", 2)
            yield CString(self, "name")
            yield CString(self, "protocol")
            yield RawBytes(self, "unknown[]", 2)

        elif entrytype == 0x47:
            # Whole Network
            yield RawBytes(self, "unknown[]", 2)
            yield CString(self, "name")

        elif entrytype == 0xC3:
            # Network Share
            yield RawBytes(self, "unknown[]", 2)
            yield CString(self, "name")
            yield CString(self, "protocol")
            yield CString(self, "description")
            yield RawBytes(self, "unknown[]", 2)

        else:
            yield RawBytes(self, "raw", self["length"].value-3)
Ejemplo n.º 5
0
 def createFields(self):
     yield RawBytes(self, "md5", 16)
     while True:
         size = (self.size - self.current_size) // 8
         if size < 77:
             break
         yield EncryptedItem(self, "item[]")
     size = paddingSize(self.current_size // 8, 16)
     if size:
         yield NullBytes(self, "padding_align", size)
Ejemplo n.º 6
0
 def createFields(self):
     yield RawBytes(self, "md5", 16)
     while True:
         size = (self.size - self.current_size) // 8
         if size < 77:
             break
         yield EncryptedItem(self, "item[]")
     size = paddingSize(self.current_size // 8, 16)
     if size:
         yield NullBytes(self, "padding_align", size)
Ejemplo n.º 7
0
 def createFields(self):
     yield Bits(self, "nbits", 5)
     nbits = self["nbits"].value
     if not nbits:
         raise ParserError("SWF parser: Invalid RECT field size (0)")
     yield Bits(self, "xmin", nbits, "X minimum in twips")
     yield Bits(self, "xmax", nbits, "X maximum in twips")
     yield Bits(self, "ymin", nbits, "Y minimum in twips")
     yield Bits(self, "ymax", nbits, "Y maximum in twips")
     size = paddingSize(self.current_size, 8)
     if size:
         yield NullBits(self, "padding", size)
Ejemplo n.º 8
0
 def createFields(self):
     yield Bits(self, "nbits", 5)
     nbits = self["nbits"].value
     if not nbits:
         raise ParserError("SWF parser: Invalid RECT field size (0)")
     yield Bits(self, "xmin", nbits, "X minimum in twips")
     yield Bits(self, "xmax", nbits, "X maximum in twips")
     yield Bits(self, "ymin", nbits, "Y minimum in twips")
     yield Bits(self, "ymax", nbits, "Y maximum in twips")
     size = paddingSize(self.current_size, 8)
     if size:
         yield NullBits(self, "padding", size)
Ejemplo n.º 9
0
    def createFields(self):
        yield UInt16(self, "size", "Node size (in bytes)")
        yield UInt16(self, "data_size")
        yield CString(self, "name", charset="ISO-8859-1")

        size = paddingSize(self.current_size//8, 4)
        if size:
            yield NullBytes(self, "padding[]", size)
        size = self["data_size"].value
        if size:
            if self["name"].value == "VS_VERSION_INFO":
                yield VersionInfoBinary(self, "value", size=size*8)
            else:
                yield String(self, "value", size, charset="ISO-8859-1")
        while 12 <= (self.size - self.current_size) // 8:
            yield NE_VersionInfoNode(self, "node[]")
        size = (self.size - self.current_size) // 8
        if size:
            yield NullBytes(self, "padding[]", size)
Ejemplo n.º 10
0
 def createFields(self):
     yield PropertiesFormat(self, "format")
     yield UInt32(self, "nb_prop")
     properties = []
     for index in xrange(self["nb_prop"].value):
         property = Property(self, "property[]")
         yield property
         properties.append(property)
     padding = paddingSize(self.current_size // 8, 4)
     if padding:
         yield NullBytes(self, "padding", padding)
     yield UInt32(self, "total_str_length")
     properties.sort(key=lambda entry: entry["name_offset"].value)
     offset0 = self.current_size // 8
     for property in properties:
         padding = self.seekByte(offset0 + property["name_offset"].value)
         if padding:
             yield padding
         yield CString(self, "name[]", "Name of %s" % property.name)
         if property["is_string"].value:
             yield CString(self, "value[]", "Value of %s" % property.name)
     padding = (self.size - self.current_size) // 8
     if padding:
         yield NullBytes(self, "end_padding", padding)
Ejemplo n.º 11
0
    def createFields(self):
        yield String(self, "name", 100, "Name", strip="\0", charset="ISO-8859-1")
        yield String(self, "mode", 8, "Mode", strip=" \0", charset="ASCII")
        yield String(self, "uid", 8, "User ID", strip=" \0", charset="ASCII")
        yield String(self, "gid", 8, "Group ID", strip=" \0", charset="ASCII")
        yield String(self, "size", 12, "Size", strip=" \0", charset="ASCII")
        yield String(self, "mtime", 12, "Modification time", strip=" \0", charset="ASCII")
        yield String(self, "check_sum", 8, "Check sum", strip=" \0", charset="ASCII")
        yield Enum(UInt8(self, "type", "Type"), self.type_name)
        yield String(self, "lname", 100, "Link name", strip=" \0", charset="ISO-8859-1")
        yield String(self, "magic", 8, "Magic", strip=" \0", charset="ASCII")
        yield String(self, "uname", 32, "User name", strip=" \0", charset="ISO-8859-1")
        yield String(self, "gname", 32, "Group name", strip=" \0", charset="ISO-8859-1")
        yield String(self, "devmajor", 8, "Dev major", strip=" \0", charset="ASCII")
        yield String(self, "devminor", 8, "Dev minor", strip=" \0", charset="ASCII")
        yield NullBytes(self, "padding", 167, "Padding (zero)")

        filesize = self.getOctal("size")
        if filesize:
            yield SubFile(self, "content", filesize, filename=self["name"].value)

        size = paddingSize(self.current_size//8, 512)
        if size:
            yield NullBytes(self, "padding_end", size, "Padding (512 align)")
Ejemplo n.º 12
0
 def createFields(self):
     yield PropertiesFormat(self, "format")
     yield UInt32(self, "nb_prop")
     properties = []
     for index in xrange(self["nb_prop"].value):
         property = Property(self, "property[]")
         yield property
         properties.append(property)
     padding = paddingSize(self.current_size//8, 4)
     if padding:
         yield NullBytes(self, "padding", padding)
     yield UInt32(self, "total_str_length")
     properties.sort(key=lambda entry: entry["name_offset"].value)
     offset0 = self.current_size // 8
     for property in properties:
         padding = self.seekByte(offset0+property["name_offset"].value)
         if padding:
             yield padding
         yield CString(self, "name[]", "Name of %s" % property.name)
         if property["is_string"].value:
             yield CString(self, "value[]", "Value of %s" % property.name)
     padding = (self.size - self.current_size) // 8
     if padding:
         yield NullBytes(self, "end_padding", padding)
Ejemplo n.º 13
0
    def createFields(self):
        yield UInt16(self, "length", "Length of Item ID Entry")
        if not self["length"].value:
            return

        yield Enum(UInt8(self, "type"), self.ITEM_TYPE)
        entrytype = self["type"].value
        if entrytype in (0x1F, 0x2E, 0x70):
            # GUID
            yield RawBytes(self, "dummy", 1, "should be 0x50")
            yield GUID(self, "guid")

        elif entrytype in (0x23, 0x25, 0x29, 0x2F):
            # Drive
            yield String(self, "drive", self["length"].value - 3, strip="\0")

        elif entrytype in (0x30, 0x31, 0x32):
            yield RawBytes(self, "dummy", 1, "should be 0x00")
            yield UInt32(self, "size", "size of file; 0 for folders")
            yield DateTimeMSDOS32(self, "date_time",
                                  "File/folder date and time")
            yield MSDOSFileAttr16(self, "attribs", "File/folder attributes")
            yield CString(self, "name", "File/folder name")
            if self.root.hasUnicodeNames():
                # Align to 2-bytes
                n = paddingSize(self.current_size // 8, 2)
                if n:
                    yield PaddingBytes(self, "pad", n)

                yield UInt16(self, "length_w", "Length of wide struct member")
                yield RawBytes(self, "unknown[]", 6)
                yield DateTimeMSDOS32(self, "creation_date_time",
                                      "File/folder creation date and time")
                yield DateTimeMSDOS32(self, "access_date_time",
                                      "File/folder last access date and time")
                yield RawBytes(self, "unknown[]", 4)
                yield CString(self,
                              "unicode_name",
                              "File/folder name",
                              charset="UTF-16-LE")
                yield RawBytes(self, "unknown[]", 2)
            else:
                yield CString(self, "name_short", "File/folder short name")

        elif entrytype in (0x41, 0x42, 0x46):
            yield RawBytes(self, "unknown[]", 2)
            yield CString(self, "name")
            yield CString(self, "protocol")
            yield RawBytes(self, "unknown[]", 2)

        elif entrytype == 0x47:
            # Whole Network
            yield RawBytes(self, "unknown[]", 2)
            yield CString(self, "name")

        elif entrytype == 0xC3:
            # Network Share
            yield RawBytes(self, "unknown[]", 2)
            yield CString(self, "name")
            yield CString(self, "protocol")
            yield CString(self, "description")
            yield RawBytes(self, "unknown[]", 2)

        else:
            yield RawBytes(self, "raw", self["length"].value - 3)
Ejemplo n.º 14
0
    def createFields(self):
        yield String(self,
                     "name",
                     100,
                     "Name",
                     strip="\0",
                     charset="ISO-8859-1")
        yield String(self, "mode", 8, "Mode", strip=" \0", charset="ASCII")
        yield String(self, "uid", 8, "User ID", strip=" \0", charset="ASCII")
        yield String(self, "gid", 8, "Group ID", strip=" \0", charset="ASCII")
        yield String(self, "size", 12, "Size", strip=" \0", charset="ASCII")
        yield String(self,
                     "mtime",
                     12,
                     "Modification time",
                     strip=" \0",
                     charset="ASCII")
        yield String(self,
                     "check_sum",
                     8,
                     "Check sum",
                     strip=" \0",
                     charset="ASCII")
        yield Enum(UInt8(self, "type", "Type"), self.type_name)
        yield String(self,
                     "lname",
                     100,
                     "Link name",
                     strip=" \0",
                     charset="ISO-8859-1")
        yield String(self, "magic", 8, "Magic", strip=" \0", charset="ASCII")
        yield String(self,
                     "uname",
                     32,
                     "User name",
                     strip=" \0",
                     charset="ISO-8859-1")
        yield String(self,
                     "gname",
                     32,
                     "Group name",
                     strip=" \0",
                     charset="ISO-8859-1")
        yield String(self,
                     "devmajor",
                     8,
                     "Dev major",
                     strip=" \0",
                     charset="ASCII")
        yield String(self,
                     "devminor",
                     8,
                     "Dev minor",
                     strip=" \0",
                     charset="ASCII")
        yield NullBytes(self, "padding", 167, "Padding (zero)")

        filesize = self.getOctal("size")
        if filesize:
            yield SubFile(self,
                          "content",
                          filesize,
                          filename=self["name"].value)

        size = paddingSize(self.current_size // 8, 512)
        if size:
            yield NullBytes(self, "padding_end", size, "Padding (512 align)")