First i thought about simple gunzip packed files, but looking into the files i found out that there were used ASCII strings and no binary format.
00000000: 30 32 47 4d 65 4a 7a 74 76 57 6c 33 34 7a 69 53 02GMeJztvWl34ziS
00000010: 4b 50 72 5a 2b 53 73 34 76 75 65 38 71 5a 70 58 KPrZ+Ss4vue8qZpX
00000020: 61 56 6d 62 5a 64 63 34 50 53 65 39 5a 57 56 50 aVmbZdc4PSe9ZWVP
00000030: 4f 74 4e 6a 4f 32 75 5a 4c 7a 6f 51 43 55 6b 73 OtNjO2uZLzoQCUks
...
Looking into the characters i gave BASE64 i try and decoded it. Finally i got a binary file. But i still couldn't decompress it with gunzip. There must be something else. So i read about compressions in Flash applications and found that flash uses zlib. Hmm, but zlib also didn't the way. By playing around we found out that the first bytes are some kind of header. After removing the first bytes we could easily decompress it.
So our final decompressing algorithmus was
- Remove magic header "02GM" from the string
- BASE64 decode it
- zlib decompress it
Our Python code for decompressing the .xml.gz files, which you can download from here.
import zlib
import base64
import urllib
import sys
def entpacken( b64string ):
decoded_data = base64.b64decode( b64string[4:] )
return zlib.decompress( decoded_data )
def main():
file = urllib.urlopen(sys.argv[1]).read()
print entpacken(file)
if __name__=="__main__":
main()
Running it as follows
python decompress.py http://static-facebook.farmville.com/v39886/items.xml.gz > items.xml
Our Python code for compressing the .xml files, which you can download from here.
import zlib
import base64
import urllib
import sys
def packen( xml ):
zlibbed_str = zlib.compress( xml )
return "02GM" + base64.b64encode( zlibbed_str )
def main():
file = open(sys.argv[1], 'r').read()
print packen(file)
if __name__=="__main__":
main()
Running it as follows
python compress.py items.xml > items.xml.gz
Now we could look into this files and change the content :) Farmville is updating this files with future items like the ufo (see picture). So you can see the pictures and get the itemname before release.
You can get decompressed XML Files version 39886 from here, if needed.
Update: We added compiled .exe version of compress.exe and decompress.exe for the Windows user. Then you don't need the Python files anymore. Usage is the same. Open "cmd.exe" and run it as described above. Download the Runtime Files else it won't run on your computer. If other files are need, please leave a comment.
can you better explain how to run this?
ReplyDeleteafter some time looking around, I opened python shell and then went to file > open > decompress.py and then I pressed F5 to run it, but it says invalid syntax and points to print entpacken(file) (the word entpacken is highlighted red)
hi anna,
ReplyDeleteyou have to run it with arguments.
i don't know what kind of IDE you have, but you can start it from commandline.
In Windows just open Start->Run and type "cmd.exe" and then switch to your python folder for example with "cd c:\Python"
and than run it with "python decompress.py http://urlyouneedfor.xml.gz"
This should work.
We added now .exe version of the tools, you can also use them if needed.
great
ReplyDeletehello,could u kindly enough to explain it step by step,im really3x confused ><..what should i do 1st n what should i install 1st?Thank you for the explanation :)
ReplyDeleteI have this .. :((
ReplyDeletenot valid zlib compressed
Traceback (most recent call last):
File "fvinternals.py", line 340, in
NameError: name 'rawXml' is not defined