How to read SWF

  • Published on
    07-Jul-2015

  • View
    14.893

  • Download
    12

Embed Size (px)

DESCRIPTION

SWF

Transcript

  • 1. 2012925()

2. T SWF ( Flash Lite) PHP SWF ( ) http://sourceforge.jp/projects/swfed/ http://openpear.org/package/IO_SWF 3. SWF SWF SWF SWF Little Endian (Byte) , MSB (Bit) , tag_and_lengthByte Alignment , 8 bit FlagsLength Dependency Optional Field , 0 TerminateOffset to foobaa , Offset Table. 4. SWF Flash Lite 100KB SWF SWF SWF (SWF) Flash Player iOS Flash Player JavaScript SWF Android 4.1 Flash Player Flash Player 5. Flash Lite SWF version Flash Flash Lite SWF version MacromediaFlash MX Flash 4 Flash 5Flash 6 Flash 7Flash 8 Flash Lite 1.xFlash Lite 2.xFlash Lite 3.x Flash Lite 1.1 Flash Lite 2.0 Flash ) http://www.adobe.com/jp/devnet/devices/articles/develop_in_japan.html 6. SWF http://www.adobe.com/devnet/swf.html () Flash Player 2000 ( Flash 4 ) Macromedia Flash ActionScript 7. SWF 8. SWF Header Tag SWFHeaderTagTag TagTag TagTag (type:9 SetBackgroundColor) [Red:0, Green:0, Blue:0] (Black) HeaderTag (type:21 DefineBitsJPEG2)XminXmax Frame[CharacterID:1,RateYminImageData: ] Frame CountTag (type:22 DefineShape2)[CharacterID:2,BitmapID:1,Ymax ,ShapeRecords:] Tag (type:26 PlaceObject2) [CharatorID:2,1 0 60, Matrix: 0 1 800 ] 9. SWF Header () SWF Header () 10. SWF Header Header Little EndianHeaderXminXmax FrameRateYmin Signature: FWS Version: 0x04 Flash 4FrameCount FileLength: 0x00000a90 2,704byte FrameSize: ()Ymax FrameRate: 0x08.00 8 frames/sec FrameSize: 0x0028 40 framesHeader(Rectangle)Signature VersionFileLengthFrameSize FrameRate FrameCount 3 bytes 1 byte 4 bytes2 bytes 2 bytes FrameSize 11. SWF Header FrameSize Header bit packingHeader Xmin Xmax7 00 00 96 00 00 09 6 0 0 01110000 00000000 00001001 01100000 00000000 00000000 10010110 00000000Ymin 5 bits 14 bits14 bits14 bits14 bitsNbits: 01110 14bits 3bits YmaxXmin: 000 00000000 000 0 twips 0 pixel byteXmax: 01001 01100000 0 4800 twips 240 pixelYmin: 0000000 0000000 0 twips 0 pixel alignment (Rectangle)FrameSize Ymax: 0 10010110 00000 4800 twips 240 pixel 20 twips = 1 pixel FrameSize (Rectangle)NbitsXminXmax Ymin Ymax 5 bits Nbits bits Nbits bits Nbits bits Nbits bits 12. SWF Tag example Tag SWFHeaderTagTag TagTag Tag Tag Tag (type:9 SetBackgroundColor) DisplayList[Red:0, Green:0, Blue:0] (Black)Depth:1 Tag (type:0 End)Tag (type:21 DefineBitsJPEG2) [CharacterID: 1,ImageData: ] Tag (type:1 ShowFrame)Tag (type:22 DefineShape2) Tag (type:26 PlaceObject2)[CharacterID:2,BitmapID:1, [CharatorID: 2, 1 0 60 ,ShapeRecords:]Depth:1, Matrix:0 1 800 , ] 13. SWF Tag type SWF Tag type ( appendix B) Tag type 14. SWF Tag Categories SWF Tag type CategoriesDefinition tags Control tagsTag (type:21)Tag (type:0)DefineBitsJPEG2End Tag (type:22) Tag (type:1) DefineShape2ShowFrameTag (type:33) Tag (type:9)DefineButton2 SetBackgroundColor Tag (type:10)Tag (type:26) DefineFontPlaceObject2 Tag (type:39) Tag (type:12) DefineSpriteDoAction 15. SWF Tag format () SWF Tag format () 16. SWF Tag format (short) len0x3e SWF Tag format (short)Tag Tag and LengthPayload2 bytesLength bytesTagCodeAndLength 1st byte2nd byte4302Little EndianRECORDHEADER 0100 0011 0000 01000~0x3e (short)2nd byte 1st byte 024 3 10 bits6 bits0000 0010 0100 0011Length:3 tag codetype:9length0000001001 000011 DefineBits 00 00 00Tag type 0x3f long #000000 RECORDHEADERTag (type:9)(black)(long) SetBackgroundColor () 17. SWF Tag format (long) len 0x3f SWF Tag format (long)TagTag and Length Payload6 bytesLength bytesbf001011 1111 0000 0000TagCodeAndLength0~0xffffffff 00bf 1st byte 2nd byteLength0000 0000 101 111110x3f Type:2Little Endian4 bytes 0000000010 1111112nd byte1st byte4bytes RECORDHEADER33 00 00 0010 bits 6 bits Tag (type:2) (long)Little Endian tag codelengthDefineShape 00 00 00 33 111111 = 0x3f Tag typeLength:0x33(=51) 18. ShowFrame, End ShowFrame, End ( payload ) Tag (ShowFrame) Tag & Length400000002 bytes0100 0000 0000 0000 0000 0000 0000 0000 type:100040 0000 0000 0100 00000000 0000000001 000000 0000 0000 0000 0000 Tag (End)Tag & Length 0000000000 0000002 bytes type:00 19. SetBackgroundColor () SetBackgroundColor ()Tag (SetBackgroundColor) Tag & Length BackgroundColor2 bytes 3 bytes3 type:94302BackgroundColor0100 0011 0000 0100 Red Green Blue1 byte 1 byte 1 byte0243 0000 0010 0100 0011type:9 0000001001 000011Length:3 00 00 00 #000000 (black) 20. DefineBitsJPEG (JPEG) DefineBitsJPEG2 (JPEG) (length) bytesTag (DefineBitsJPEG3)Charater Tag & LengthJPEG DataID6 bytes 2 bytestype:35 JPEG ( chunk ) http://labs.gree.jp/blog/2010/09/782/ SWF (JPEG) 21. DefineBitsJPEG (JPEG) DefineBitsJPEG3 ( JPEG)(length) bytesTag (DefineBitsJPEG3)Charater (zlib compressed) Tag & Length ID OffsetToAlpha JPEG Data BitmapAlphaData6 bytes 2 bytes 4 bytes(OffsetToAlpha) bytestype:35 (width) byteswidth BitmapAlphaData height(height)bytes ) http://labs.gree.jp/blog/2010/09/782/ SWF (JPEG) 22. DefineBitsLossless () DefineBitsLossless2 ( PNG/GIF ) Format:3 () (length) bytes Tag (DefineBitsLossless2)(zlib compressed)Tag &CharaterColor ColorTable &Length IDFormatWidth Height TableSizeColormapPixelData6 bytes2 bytes1 byte2 bytes 2 bytes 1 bytezlib infrate type:363 ColorTable & ColormapPixelDataColorTableColormapPixelData bytes(4 x ColorTableSize) bytes ColorTable(Width) bytes(Color AlphaRed GreenBlue ColormapPixelDataTableSize)bytesAlphaRed GreenBlue (Height) AlphaRed GreenBlue bytes 23. DefineBitsLossless (RGBA) DefineBitsLossless2 ( PNG/GIF ) Format: 5 (RGBA, DirectColor) (length) bytesTag (DefineBitsLossless2) Tag &CharaterColor (zlib compressed) Length IDFormatWidthHeight TableSizeBitmapPixelData 6 bytes2 bytes1 byte 2 bytes 2 bytes 1 byte type:36 5zlib infrate x(Width) bytesBitmapPixelData Red GreenBlue Alpha (Height)Red GreenBlue Alphabytes ) http://labs.gree.jp/blog/2010/12/1902/ SWF (PNG) 24. DefineShape (:) DefineShape SWF (Shape) http://labs.gree.jp/blog/2011/04/2328/ 25. PlaceObject (or) PlaceFlag PlaceObject2HasClipActionsHasClipDepthHasName Tag (PlaceObject2)HasRatio1 byteTag & LengthPlaceFlag DepthHasColorTransform 2 bytes1 byte 2 bytesHasMatrix Type:260000 000X HasCharactorMove PlaceObject2 ()Tag (PlaceObject2)PlaceCharacterColor ClipClip Tag & LengthDepthID Matrix TransformRatio Name Depth ActionsFlag2 bytes 1 byte 2 bytes 2 bytes2 bytes2 bytes 1111 111XMATRIX, ColorTransformClipActions() SWF5 () 26. MATRIX () MATRIX () 0000 000XMATRIXHas Has Ntranslate Scale RotateBitsScale Rotate Translate1 0 0 XSkew0 X1 bit 1 bit5 bit0 1 0(= 0) (= 0)(= 0)Rorate Scale TranslateSkew1YY MATRIX ()MATRIX Scale Scale Rotate Rotate Ntranslate Translate Translate Has NScale Has NRotateXYRotate Bits Skew0 Skew1 Bits XXScaleBits1 bit1 bit 5 bits (Nscale (Nscale5 bits (NRotate (NRotate 5 bits (NTranslate (NTranslate(= 1) Bits)bits Bits) bits (= 1) Bits)bits Bits) bitsBits)bits Bits)bits2 0 0LT 0 1 0 27. CXFORM () CXFORM ()00XX XXXXMATRIXHas HasAddTerm MultiTerm 1 bit1 bit () (= 0)(= 0) RedMultiTerm > 256or CXFORM () RedAddTerm > 0MATRIXHas HasRedGreenBlueRed Green BlueNBitsAddTerm MultiTermMultiTerm MultiTerm MultiTerm AddTermAddTermAddTerm1 bit 1 bit 4 bits (Nbits) (Nbits)(Nbits)(Nbits) (Nbits) (Nbits)(= 1) (= 1) bitsbits bits bitsbitsbits11XX XXXX 28. m(_ _)m 29. DoAction (ActionScript) DoAction Tag (DoAction) ActionTag & Length ActionsEndFlag Type:122 or 6 bytes 1 byte=0 Action 0x7F ActionCodeAction 0x80 ActionCodeLengthPayload (operand)1 byte 2 bytes (Length) byte ) http://labs.gree.jp/blog/2011/07/3259/ SWF (Action AS2 Bytecode)1 byte =0 30. DefineButton () DefineButtonTag (DefineButton) Button Character ActionTag & Length Characters ActionsEndFlag Id EndFlag2 or 6 bytes2 bytes1 byte1 byte=0=0 Type:7Character (BUTTONRECORD) Chacater Chacater DoAction Character (BUTTONRECORD) ButtonStateCharacterID PlaceDepthPlaceMatrix ButtonState PlaceObject HitTestStateDown /StateOverStateUp 31. DefineSprite () DefineSprite (length) bytes Tag (DefineSprite) SpriteFrame Tag & LengthCountControlTagsID 2 or 6 bytes 2 bytes2 bytes type:39 ControlTagsTag (PlaceObject2)Tag (ShowFrame) Tag (End) Definition Tags 32. 16bits, 32bits LittleEndian bit OK ( MSB) tag_and_lenght 16bits LittleEndian (1 bit)Tag Tag (Matrix) Byte Alignment (bytebit) Matrix () alignment 33. (1/3) Flash Lite 1.1 SWF C PHP () SWFEditor for PHP http://sourceforge.jp/projects/swfed/ IO_SWF http://openpear.org/package/IO_SWF 34. (2/3) Bitstream http://openpear.org/package/IO_Bit IO_Bit ) http://www.slideshare.net/yoyayoya1/php-10133775 PHP 35. (3/3) IO_SWF dump 36.