Example #1
0
class SwfFile(VStruct):

    def __init__(self):
        VStruct.__init__(self)
        self.Header = SwfHeader()
        self.Tags = VArray()

    def vsParse(self, bytez, offset=0):
        magic = bytez[offset:offset+3]
        if magic not in ('FWS','CWS','ZWS'):
            raise Exception('Invalid Swf Magic')

        if magic == 'CWS':
            bytez = bytez[:8] + zlib.decompress(bytez[8:])

        offset = self.Header.vsParse(bytez, offset=offset)
        print(('Header Says: %d Bytes Are: %d' %  (self.Header.FileLength,len(bytez))))
        i = 0
        while offset < len(bytez):
            swftag = SwfTag()
            offset = swftag.vsParse(bytez, offset=offset)
            self.Tags.vsAddElement(swftag)
            i += 1
            if i > 3:
                break
Example #2
0
 def __init__(self,shape=1):
     VStruct.__init__(self)
     self._swf_shape = shape
     self.BitFields       = VBitField()
     self.BitFields.SpreadMode           = v_bits(2)
     self.BitFields.InterpolationMode    = v_bits(2)
     self.BitFields.NumGradients         = v_bits(4)
     self.GradientRecords = VArray()
Example #3
0
class DefineSceneAndFrameLabelData(VStruct):
    def __init__(self, size):
        VStruct.__init__(self)
        self.SceneCount         = EncodedU32()
        self.Scenes             = VArray()
        self.FrameLabelCount    = EncodedU32()
        self.Frames             = VArray()

    def pcb_SceneCount(self):
        count = self.SceneCount
        self.Scenes.vsAddElements(count, OffsetName)

    def pcb_FrameLabelCount(self):
        count = self.FrameLabelCount
        self.Scenes.vsAddElements(count, OffsetName)
Example #4
0
class GRADIENT(VStruct):
    def __init__(self,shape=1):
        VStruct.__init__(self)
        self._swf_shape = shape
        self.BitFields       = VBitField()
        self.BitFields.SpreadMode           = v_bits(2)
        self.BitFields.InterpolationMode    = v_bits(2)
        self.BitFields.NumGradients         = v_bits(4)
        self.GradientRecords = VArray()

    def pcb_BitFields(self):
        gcount = self.BitFields.NumGradients
        for i in range(gcount):
            g = GRADRECORD(shape=self._swf_shape)
            self.GradientRecords.vsAddElement(g)
Example #5
0
 def __init__(self):
     VStruct.__init__(self)
     self.a = v_uint8()
     self.b = v_uint16()
     self.c = v_uint32()
     self.d = v_uint8()
     self.e = VArray(
         (v_uint32(), v_uint32(), v_uint32(), v_uint32()))
Example #6
0
 def __init__(self, shape=1):
     VStruct.__init__(self)
     self.FillStyles     = FILLSTYLEARRAY(shape=shape)
     self.LineStyles     = LINESTYLEARRAY(shape=shape)
     self.NumBits        = VBitField()
     self.NumBits.NumFillBits    = v_bits(4)
     self.NumBits.NumLineBits    = v_bits(4)
     self.ShapeRecords           = VArray()
Example #7
0
class LINESTYLEARRAY(VStruct):
    def __init__(self,shape=1):
        VStruct.__init__(self)
        self._swf_shape = 1
        self.LineStyleCount     = v_uint8()
        self.LineStyleCountEx   = v_uint16()
        self.LineStyles         = VArray()

    def pcb_LineStyleCount(self):
        if self.LineStyleCount != 0xff:
            self.vsDelField('LineStyleCountEx')
            self.swfAddLineStyles(self.LineStyleCount)

    def pcb_LineStyleCountEx(self):
        self.swfAddLineStyles(self.LineStyleCountEx)

    def swfAddLineStyles(self, count):
        for i in range(count):
            elem = LINESTYLE(shape=self._swf_shape)
            self.LineStyles.vsAddElement(elem)
Example #8
0
File: swf.py Project: BwRy/vivisect
class FILLSTYLEARRAY(VStruct):
    def __init__(self, shape=1):
        VStruct.__init__(self)
        self._swf_shape = shape
        self.FillStyleCount     = v_uint8()
        self.FillStyleCountEx   = v_uint16()
        self.FillStyles         = VArray()

    def pcb_FillStyleCount(self):
        if self.FillStyleCount != 0xff:
            self.vsDelField('FillStyleCountEx')
            self.swfAddFillStyles(self.FillStyleCount)

    def pcb_FillStyleCountEx(self):
        self.swfAddFillStyles(self.FillStyleCountEx)

    def swfAddFillStyles(self, count):
        for i in xrange(count):
            elem = FILLSTYLE(shape=self._swf_shape)
            self.FillStyles.vsAddElement(elem)
Example #9
0
class FILLSTYLEARRAY(VStruct):
    def __init__(self, shape=1):
        VStruct.__init__(self)
        self._swf_shape = shape
        self.FillStyleCount = v_uint8()
        self.FillStyleCountEx = v_uint16()
        self.FillStyles = VArray()

    def pcb_FillStyleCount(self):
        if self.FillStyleCount != 0xff:
            self.vsDelField('FillStyleCountEx')
            self.swfAddFillStyles(self.FillStyleCount)

    def pcb_FillStyleCountEx(self):
        self.swfAddFillStyles(self.FillStyleCountEx)

    def swfAddFillStyles(self, count):
        for i in xrange(count):
            elem = FILLSTYLE(shape=self._swf_shape)
            self.FillStyles.vsAddElement(elem)
Example #10
0
 def __init__(self):
     VStruct.__init__(self)
     self.Header = SwfHeader()
     self.Tags = VArray()
Example #11
0
 def __init__(self, size):
     VStruct.__init__(self)
     self.SceneCount         = EncodedU32()
     self.Scenes             = VArray()
     self.FrameLabelCount    = EncodedU32()
     self.Frames             = VArray()
Example #12
0
 def __init__(self,shape=1):
     VStruct.__init__(self)
     self._swf_shape = 1
     self.LineStyleCount     = v_uint8()
     self.LineStyleCountEx   = v_uint16()
     self.LineStyles         = VArray()