Showing posts with label gameSettings.xml.gz unreleased farmville items 02GM. Show all posts
Showing posts with label gameSettings.xml.gz unreleased farmville items 02GM. Show all posts

Saturday, August 14, 2010

gameSettings.xml.gz items.xml.gz and other .xml.gz files in Farmville

Looking into the communication between the Farmville game and the server, i recognized that there are some files called:
 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
  1. Remove magic header "02GM" from the string
  2. BASE64 decode it
  3. zlib decompress it
We wrote a small tool in Python, you can download it from http://www.python.org/download/.

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.