Guest User

Last Ranker Script Dump

a guest
Jun 2nd, 2016
112
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.14 KB | None | 0 0
  1. import binascii, struct, os, gzip, pdb
  2.  
  3. def text_encode(s):
  4.     s1 = ''
  5.     flag = False
  6.     for char in s:
  7.         if ord(char) < 0x20 and ord(char) != 0xA:
  8.             if not flag:
  9.                 flag = True
  10.                 s1 += '{'
  11.             s1 += '{:0>2x}'.format(ord(char))
  12.         else:
  13.             if flag:
  14.                 flag = False
  15.                 s1 += '}'
  16.             s1 += char
  17.     return s1
  18.  
  19. filename = 'MAP_T_KAN_00.BIN'
  20. size = os.path.getsize(filename)
  21. with open(filename, 'rb') as f:
  22.     filedata = gzip.decompress(f.read())
  23. offset = struct.unpack('<I', filedata[0xC:0x10])[0]
  24. size = struct.unpack('<I', filedata[offset+0x24:offset+0x28])[0]
  25. filedata = filedata[offset:offset+size]
  26. string_num = struct.unpack('<I', filedata[0x30:0x34])[0]
  27. start = struct.unpack('<I', filedata[0x34:0x38])[0]
  28. end = struct.unpack('<I', filedata[0x3C:0x40])[0]
  29. print(start, end)
  30. s = filedata[start:end].split(b'\x00')[:string_num]
  31. with open('output.txt', 'w', encoding='utf-8') as f:
  32.     for i, x in enumerate(s):
  33.         f.write(str(i) + '\t')
  34.         x = x.decode('utf-8')
  35.         f.write(text_encode(x).replace('\n', '\n\t') + '\n')
Add Comment
Please, Sign In to add comment