Advertisement
Jhynjhiruu

Decode from passcode

Mar 31st, 2018
707
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 5.20 KB | None | 0 0
  1. import base64
  2. import sys
  3.  
  4. password = str(input("Please type in a Phoenotopia 1 password:\n"))
  5.  
  6. def UsedPassCode(param1):
  7.     global decoded_passcode
  8.     decoded_passcode = None
  9.     global new_game_data
  10.     new_game_data = [None]
  11.     pass_code = param1
  12.     stripped_pass_code = _StripPassCode(pass_code)
  13.     try:
  14.         decoded_passcode = str(base64.b64decode(stripped_pass_code)).strip("b''")
  15.         new_game_data = _StringToGameDataArray(decoded_passcode)
  16.     except ValueError as e:
  17.         return "Bad Password! Details: " + str(e)
  18.     return "SUCCESS!"
  19.  
  20. def _StripPassCode(param1):
  21.     _loc2_ = param1.split("_")
  22.     global fileName
  23.     fileName = _loc2_[0]
  24.     _loc3_ = int(0)
  25.     while _loc3_ < len(_loc2_):
  26.         if len(str(_loc2_[_loc3_])) > 200:
  27.             return str(_loc2_[_loc3_])
  28.         _loc3_ = _loc3_ + 1
  29.     raise ValueError("Bad Password!")
  30.  
  31. def _StringToGameDataArray(param1):
  32.     _loc2_ = []
  33.     _loc3_ = str(param1).split(",")
  34.     _loc2_.append(_loc3_[0])
  35.     _loc2_.append(int(_loc3_[1]))
  36.     _loc2_.append(int(_loc3_[2]))
  37.     _loc2_.append(int(_loc3_[3]))
  38.     _loc2_.append(int(_loc3_[4]))
  39.     _loc2_.append(int(_loc3_[5]))
  40.     _loc2_.append(int(_loc3_[6]))
  41.     _loc2_.append(int(_loc3_[7]))    
  42.     _loc2_.append(_ParseItemString(_loc3_[8]))
  43.     _loc2_.append(_ParseSaveIndexString(_loc3_[9]))
  44.     _loc2_.append(_ParseKeyString(_loc3_[10]))
  45.     _loc2_.append(int(_loc3_[11]))
  46.     _loc4_ = int(_loc3_[12])
  47.     if _loc4_ < 3840:
  48.         _loc4_ = 3840
  49.     _loc2_.append(_loc4_)
  50.     _loc2_.append(int(_loc3_[13]))
  51.     _loc2_.append(int(_loc3_[14]))
  52.     _loc2_.append(int(_loc3_[15]))
  53.     _loc2_.append(int(_loc3_[16]))
  54.     _loc2_.append(int(_loc3_[17]))
  55.     _loc2_.append(int(_loc3_[18]))
  56.     _loc2_.append(int(_loc3_[19]))
  57.     _loc2_.append(int(_loc3_[20]))
  58.     _loc2_.append(int(_loc3_[21]))
  59.     _loc2_.append(int(_loc3_[22]))
  60.     _loc2_.append(int(_loc3_[23]))
  61.     _loc2_.append(int(_loc3_[24]))
  62.     _loc2_.append(int(_loc3_[25]))
  63.     _loc2_.append(int(_loc3_[26]))
  64.     _loc2_.append(int(_loc3_[27]))
  65.     _loc2_.append(int(_loc3_[28]))
  66.     _loc2_.append(int(_loc3_[29]))
  67.     _loc2_.append(int(_loc3_[30]))
  68.     _loc2_.append(int(_loc3_[31]))
  69.     _loc2_.append(int(_loc3_[32]))
  70.     _loc2_.append(int(_loc3_[33]))
  71.     _loc2_.append(int(_loc3_[34]))
  72.     return _loc2_
  73.  
  74. def _ParseKeyString(param1):
  75.     _loc2_ = param1.split("_")
  76.     _loc3_ = []
  77.     _loc7_ = int(0)
  78.     while _loc7_ < len(_loc2_):
  79.         if _loc2_[_loc7_] == "-1":
  80.             _loc3_.append(False)
  81.         elif _loc2_[_loc7_] != "":
  82.             _loc3_.append(_loc2_[_loc7_])
  83.         _loc7_ = _loc7_ + 1
  84.     return _loc3_
  85.  
  86. def _ParseSaveIndexString(param1):
  87.     _loc2_ = []
  88.     _loc5_ = int(0)
  89.     _loc6_ = int(0)
  90.     _loc7_ = int(0)
  91.     while _loc7_ < len(param1):
  92.         if param1[_loc7_] == "ABCDEFGHIJKLM01234"[_loc5_]:
  93.             _loc2_.append(True)
  94.             _loc5_ = (_loc5_ + 1) % len("ABCDEFGHIJKLM01234")
  95.         elif param1[_loc7_] == "NOPQRSTUVWXYZ56789"[_loc6_]:
  96.             _loc2_.append(False)
  97.             _loc6_ = (_loc6_ + 1) % len("NOPQRSTUVWXYZ56789")
  98.         else:
  99.             raise ValueError("Bad Password")
  100.         _loc7_ = _loc7_ + 1
  101.     return _loc2_
  102.  
  103. def _ParseItemString(param1):
  104.     _loc2_ = param1.split("_")
  105.     _loc3_ = []
  106.     _loc4_ = []
  107.     _loc5_ = []
  108.     _loc6_ = int(0)
  109.     while _loc6_ < len(_loc2_):
  110.         if _loc6_ < 9:
  111.             _loc3_.append(int(_loc2_[_loc6_]))
  112.         elif _loc6_ < 18:
  113.             _loc4_.append(int(_loc2_[_loc6_]))
  114.         elif _loc6_ < 27:
  115.             _loc5_.append(int(_loc2_[_loc6_]))            
  116.         _loc6_ = _loc6_ + 1
  117.     return [_loc3_,_loc4_,_loc5_]
  118.  
  119. returnValue = UsedPassCode(password)
  120. print(returnValue)
  121. if returnValue != "SUCCESS!":
  122.     sys.exit()
  123. section_array = new_game_data
  124.  
  125. section_names = ["game_room","game_time","player_maxhp","player_hp","player_x","player_y","coins","equipped_club","inventory","general","keys","times_died","accumulated_time_played","space_rocks","tool_equipped","coins_collected_total","boxes_broken_count","good_food_consumed","bad_food_consumed","Key.JUMP","Key.ACTION","Key.TOOL","Key.MENU"]
  126.  
  127. print("---------------------\nDecoded, split password:\n---------------------")
  128. output = ""
  129. for i in range(len(section_names)):
  130.     if i in range(19, 23):
  131.         output = output + section_names[i] + ": " + chr(section_array[i]) + "\n"
  132.         print(section_names[i] + ":", chr(section_array[i]))
  133.     else:
  134.         print(section_names[i] + ":", section_array[i])
  135.         output = output + section_names[i] + ": " + str(section_array[i]) + "\n"
  136.    
  137. print("---------------------\nFormatted decoded password:\n---------------------")
  138. print(new_game_data)
  139.  
  140. print("---------------------\nRaw decoded password:\n---------------------")
  141. print(decoded_passcode)
  142.  
  143. with open(fileName.replace(":", ".").rstrip("-") + ".pts", "w") as f:
  144.     f.write(password + "\n---------------------\nDecoded, split password:\n---------------------\n" + output + "---------------------\nFormatted decoded password:\n---------------------\n" + str(new_game_data) + "\n---------------------\nRaw decoded password:\n---------------------\n" + decoded_passcode)
  145. f.close()
  146.  
  147. input("Press enter to exit...")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement