Decompressing A SWF With Java

This example reads a swf file into a byte array and decompresses / inflates all of the bytes of the swf except for the the first 8 bytes which are always uncompressed. As most swf files have zlib compression applied, file decompression is necessary if you wish to fully parse the swf. As with the previous post on swf compression, this is a very raw example–no file signature or compression checking is performed before attempting to inflate the file.

SWFDecompressor.java

7 Comments

  1. sherm
    Posted August 11, 2006 at 1:59 am | Permalink

    look dude, this makes no sense at all.

  2. Posted August 11, 2006 at 2:09 am | Permalink

    Heh, heh–you should read the file format specification….you know you’re in trouble when it starts to make sense to you.

  3. Posted October 7, 2006 at 6:49 pm | Permalink

    What type of compression is used for an SWF file? Gzip? zip? bzip? tar?

  4. Brooks
    Posted October 15, 2006 at 4:52 am | Permalink

    Hey Mark,

    The swf file format uses zlib compression.

  5. Posted January 21, 2008 at 11:35 am | Permalink

    hey there, first comment after 2 year!!!

    thank you for the code
    I’m using it in my own project and I’ve found a bug related to inflater: sometimes finished() is read as false when in fact should be true… workaround is use also count!=0 in while loop.

    cheers

  6. Posted May 22, 2008 at 9:17 pm | Permalink

    hi, it’s me again ;) , the project I was talking about in the last post had become a quite structured one… it is called JavaSWF9 , if you or someone in the audience interested in contributing drop a message at http://www.stefanocottafavi.com

    cheers

  7. Posted April 15, 2009 at 8:52 pm | Permalink

    This can be done with a Perl one-liner instead of 115 lines of Java ;-),

    perl -MCompress::Zlib -0777 -e \
    ‘print uncompress substr , 8;’ flash.swf > flash

One Trackback

  1. By Daniel on November 6, 2006 at 7:26 am

    Yep…

    Yes, I’ve heard of “decaf.” What’s your point?

Post a Comment

Your email is never published nor shared. Required fields are marked *

*
*