Advertisement
Silicaly

trophyPather.py

Feb 6th, 2018
225
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.22 KB | None | 0 0
  1. import Tkinter
  2. import tkFileDialog
  3. import tkMessageBox
  4. import shutil
  5. import sys
  6. import os
  7. import zipfile
  8.  
  9. import binascii
  10.  
  11.  
  12. def zip(src, dst): #Stolen from PSVIMGTOOLS-FRONTEND (which probably stole it from StackOverflow)
  13. zf = zipfile.ZipFile("%s" % (dst), "w", zipfile.ZIP_DEFLATED,allowZip64 = True)
  14. abs_src = os.path.abspath(src)
  15. for dirname, subdirs, files in os.walk(src):
  16. for filename in files:
  17. absname = os.path.abspath(os.path.join(dirname, filename))
  18. arcname = absname[len(abs_src) + 1:]
  19. print 'Writing %s To VPK' % (os.path.join(dirname, filename))
  20. zf.write(absname, arcname)
  21. print 'Removing '+os.path.join(dirname, filename)
  22. os.remove(os.path.join(dirname, filename))
  23. zf.close()
  24.  
  25. window = Tkinter.Tk()
  26. window.wm_withdraw()
  27. tkMessageBox.showinfo(title="NPWR FOLDER",message="Please select the incompadible game's NPWR Folder\n(trophy/data/NPWRXXXX)")
  28. trophyFolder = tkFileDialog.askdirectory(title="Trophy Folder")
  29. tkMessageBox.showinfo(title=".TRP",message="Please select the incompadbile games DECRYPTED .TRP file\n(use vitashell, or mai/vitamin.)\n(sce_sys/trophy/TROPHY.TRP)")
  30. trophyTRP = tkFileDialog.askopenfilename(title="TRP File",filetypes=[('Trophy Data Files', '*.TRP')])
  31. tkMessageBox.showinfo(title=".VPK",message="Please select where you would like the patched game's (.vpk) to be saved.")
  32. trophyVPK = tkFileDialog.asksaveasfilename(title="VPK File",filetypes=[('Vita Package', '*.vpk')])
  33.  
  34. if trophyVPK.endswith("\\") or trophyVPK.endswith("/"):
  35. trophyVPK = trophyVPK[:-1]
  36.  
  37.  
  38. if sys.platform.__contains__("win"):
  39. os.system('"'+os.path.dirname(os.path.realpath(__file__))+'/psvpfsparser.exe" --title_id_src="'+trophyFolder+'" --title_id_dst="'+trophyFolder+'_decrypted" --f00d_url=cma.henkaku.xyz')
  40. else:
  41. os.system('"'+os.path.dirname(os.path.realpath(__file__))+'/psvpfsparser" --title_id_src="'+trophyFolder+'" --title_id_dst="'+trophyFolder+'_decrypted" --f00d_url=cma.henkaku.xyz')
  42.  
  43. trpData = open(trophyFolder+"_decrypted/TRPTRANS.DAT","rb").read()
  44. npCommSign = trpData[400:560]
  45. npCommId = trpData[0x170:0x170 + 0x0C]
  46.  
  47. gameNpCommSign = binascii.unhexlify("b9dde13b01000000000000003cc3f8965e6643e6c9dcfa5615cadd856f6d064ba62ec13ff0fc79cd6b7d02c230939eb7fec017e84d43c47567ad592d27907cdf2b37c2a8b71ecc616465988113b7a6e6b8ea16bdd08af63cc27c449a91821f8a6a27e597db162cc5fd9b4052ae8f6de6b5341814da2d9004fc4ea4174bfbc0fa3f433d1c6126197389c07ac407988e9cde77edcc3e61c5cc04799602573459fc")
  48. gameNpCommId = "NPWR07688"
  49.  
  50. shutil.copytree(os.path.dirname(os.path.realpath(__file__))+'/toMod',trophyVPK+"_temp")
  51.  
  52. gameEboot = open(os.path.dirname(os.path.realpath(__file__))+'/toMod/eboot.bin',"rb").read()
  53. gameEboot = gameEboot.replace(gameNpCommId,npCommId[:-3])
  54. gameEboot = gameEboot.replace(gameNpCommSign,npCommSign)
  55.  
  56. open(trophyVPK+"_temp/eboot.bin","wb").write(gameEboot)
  57. os.mkdir(trophyVPK+"_temp/sce_sys/trophy/"+npCommId)
  58. shutil.copy(trophyTRP,trophyVPK+"_temp/sce_sys/trophy/"+npCommId+"/TROPHY.TRP")
  59.  
  60. zip(trophyVPK+"_temp",trophyVPK)
  61. shutil.rmtree(trophyVPK+"_temp")
  62. shutil.rmtree(trophyFolder+"_decrypted")
  63.  
  64. tkMessageBox.showinfo(title="Done!",message="Done! Patched game created.")
  65. window.destroy()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement