Advertisement
Fireboyd78

String Decryptor for RDR2 Companion App

Oct 31st, 2018
286
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 2.35 KB | None | 0 0
  1. ###
  2. ### RDR2 Companion App "Super String Decryptor PRO ((ULTIMATE EDITION)) v1.2" Script Utility (IDA Pro)
  3. ### © 2018 Fireboyd78
  4. ###
  5. ### If this script helps you in any way, please give credit where it's due ;)
  6. ###
  7.  
  8. def get_decrypt_key(ea):
  9.     name = Name(ea)
  10.    
  11.     if not name.startswith("_ZTS"):
  12.         print("**** Can't get decrypt key! ****")
  13.         return
  14.    
  15.     str = name[4:]
  16.     buffer = [ord(c) for c in str] + [0]
  17.    
  18.     index = 0
  19.     count = len(buffer)
  20.    
  21.     #print('"%s"(%02d):' % (str, count))
  22.    
  23.     key = []
  24.    
  25.     while index < count:
  26.         b = Byte(ea + index)
  27.         v = buffer[index]
  28.         k = (b ^ v)
  29.        
  30.         key.append(k)
  31.        
  32.         #print('%02x\t\t%02x\t\t^%02x' % (v, b, k))
  33.        
  34.         index += 1
  35.    
  36.     #print(''.join(["%02x " % k for k in key]))
  37.    
  38.     return key
  39.  
  40. # 82 characters!
  41. # TODO: Find the actual key
  42. DECRYPT_KEY = get_decrypt_key(0x2A91C10)
  43.  
  44. def get_decrypt_buffer(ea):
  45.     index = 0
  46.     buffer = []
  47.     while index < 256:
  48.         b = Byte(ea + index)
  49.         buffer.append(b)
  50.        
  51.         index += 1
  52.     return buffer
  53.  
  54. # TODO: Wrong key?!
  55. # uses 's_FromBase64LUT' buffer
  56. # (sorry folks, not posting the key here)
  57. #DECRYPT_KEY = get_decrypt_buffer(0x2B18C68)
  58.  
  59. def decrypt_string(ea, makeCmt = True):
  60.     index = 0
  61.     max_len = len(DECRYPT_KEY)
  62.    
  63.     buffer = []
  64.     eos = False
  65.    
  66.     while index < max_len:
  67.         b = Byte(ea + index)
  68.         k = DECRYPT_KEY[index]
  69.         v = (b ^ k)
  70.        
  71.         # read up until null-terminator
  72.         if v == 0:
  73.             eos = True
  74.             break
  75.        
  76.         buffer.append(v)
  77.        
  78.         index += 1
  79.    
  80.     str = ''.join([chr(b) for b in buffer])
  81.    
  82.     # string longer than decryption buffer?
  83.     if not eos:
  84.         print("**** Couldn't decrypt entire string (only up to %d bytes) ****" % max_len)
  85.    
  86.     if makeCmt:
  87.         MakeRptCmt(ea, 'decrypted: "%s"' % str)
  88.    
  89.     return str
  90.    
  91. def decrypt_string_ptr(ea, makeCmt = True):
  92.     ptr = Qword(ea)
  93.     return decrypt_string(ptr, makeCmt)
  94.    
  95. def decrypt_string_ptr_list(ea, count = 1, makeCmt = True):
  96.     index = 0
  97.     list = []
  98.     while index < count:
  99.         str = decrypt_string_ptr(ea + (index * 8), makeCmt)
  100.         list.append(str)
  101.        
  102.         index += 1
  103.     return list
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement