Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import os,sys,struct,zlib
- def get_data(filename):
- totalbytes = os.path.getsize(filename)
- infile = open(filename, 'rb')
- totalfiledata = infile.read(totalbytes)
- return totalfiledata
- if __name__ == '__main__':
- filedata = get_data(sys.argv[1])
- xor = 0xAFDD92A7
- filecnt = 0
- #some unknown dword at 0x0
- #2 more umknown dwords at 0xd6 and 0xda
- #in between is table of contents I assume, 0x15 bytes for each, all crypted,
- #except first dword used as a key
- for i in range(0x4,0xd6,0x15):
- newfiledata = ''
- key = struct.unpack('<I',filedata[i:i+0x4])[0]
- key ^= xor
- if filecnt == 0: #done
- for a in xrange(0xde,0xde+0x6048,0x4):
- newfiledata += struct.pack('<I',struct.unpack('<I',filedata[a:a+0x4])[0] ^ key)
- newfiledata += filedata[0xde+0x6048:0xde+0x604b]
- elif filecnt == 1: #done
- for a in xrange(0x6129,0x6129+0x4c8,0x4):
- newfiledata += struct.pack('<I',struct.unpack('<I',filedata[a:a+0x4])[0] ^ key)
- elif filecnt == 2: #done
- for a in xrange(0x65f1,0x65f1+0xc,0x4):
- newfiledata += struct.pack('<I',struct.unpack('<I',filedata[a:a+0x4])[0] ^ key)
- elif filecnt == 3: #done
- for a in xrange(0x65fd,0x65fd+0x1324,0x4):
- newfiledata += struct.pack('<I',struct.unpack('<I',filedata[a:a+0x4])[0] ^ key)
- newfiledata += filedata[0x65fd+0x1324:0x65fd+0x1326]
- elif filecnt == 4: #done
- for a in xrange(0x7923,0x7923+0x2008,0x4):
- newfiledata += struct.pack('<I',struct.unpack('<I',filedata[a:a+0x4])[0] ^ key)
- newfiledata += filedata[0x7923+0x2008:0x7923+0x2009]
- elif filecnt == 5: #done
- for a in xrange(0x992c,0x992c+0x170,0x4):
- newfiledata += struct.pack('<I',struct.unpack('<I',filedata[a:a+0x4])[0] ^ key)
- newfiledata += filedata[0x992c+0x170:0x992c+0x171]
- elif filecnt == 6: #done
- for a in xrange(0x9a9d,0x9a9d+0x2618,0x4):
- newfiledata += struct.pack('<I',struct.unpack('<I',filedata[a:a+0x4])[0] ^ key)
- newfiledata += filedata[0x992c+0x170:0x992c+0x171]
- elif filecnt == 7: #done
- for a in xrange(0xc0b5,0xc0b5+0x276C,0x4):
- newfiledata += struct.pack('<I',struct.unpack('<I',filedata[a:a+0x4])[0] ^ key)
- newfiledata += filedata[0xc0b5+0x276C:0xc0b5+0x276D]
- elif filecnt == 8: #done
- for a in xrange(0xe822,0xe822+0x228C,0x4):
- newfiledata += struct.pack('<I',struct.unpack('<I',filedata[a:a+0x4])[0] ^ key)
- newfiledata += filedata[0xe822+0x228C:0xe822+0x228f]
- elif filecnt == 9: #done
- for a in xrange(0x10ab1,0x10ab1+0x184,0x4):
- newfiledata += struct.pack('<I',struct.unpack('<I',filedata[a:a+0x4])[0] ^ key)
- else:
- print 'unknown file key: %x' % struct.unpack('<I',filedata[i:i+0x4])[0]
- sys.exit()
- print 'File %d key %x' % (filecnt,struct.unpack('<I',filedata[i:i+0x4])[0])
- newfiledata = zlib.decompress(newfiledata)
- outfile = open('File_%d.txt' % filecnt,'wb')
- outfile.write(newfiledata)
- outfile.close()
- filecnt += 1
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement