Silicaly

Decrypt-Game.py

Jan 3rd, 2019
292
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 2.12 KB | None | 0 0
  1. #Requires make_fself.exe in the same directory as .py file
  2. #And unoffical vitasdk required for kernel modules.
  3.  
  4. from self2elf import *
  5. from scetypes import *
  6. import sys
  7. import os
  8.  
  9. def DecryptSelf(inputfile, outputfile, keyriffile=0):
  10.     with open(inputfile, "rb") as inf:
  11.         with open(outputfile, "wb") as outf:
  12.             if keyriffile:
  13.                 with open(keyriffile, "rb") as rif:
  14.                     lic = SceRIF(rif.read(SceRIF.Size))
  15.                     self2elf(inf, outf, lic.klicense)
  16.             else:
  17.                 self2elf(inf, outf, 0)
  18.                        
  19.  
  20. def DecryptGame(gamefolder,rif=0):
  21.     for root, subdirs, files in os.walk(gamefolder):
  22.         for file in files:
  23.             if open(os.path.abspath(root+"/"+file)).read(0x3) == "SCE":
  24.                 print("Decrypt SELF: "+file)
  25.                 try:
  26.                     if sys.argv[2] == "kernel" or sys.argv[2] == "user":
  27.                         DecryptSelf(os.path.abspath(root+"/"+file),os.path.abspath(root+"/"+file) + ".elf")
  28.                     else:
  29.                         DecryptSelf(os.path.abspath(root+"/"+file),os.path.abspath(root+"/"+file) + ".elf",rif)
  30.                     os.rename(root+"/"+file,root+"/"+file+".bak")
  31.                     if sys.argv[2] != "kernel":
  32.                         print("Execute "+"./make_fself.exe -e -c  \""+root+"/"+file + ".elf\" \""+root+"/"+file+"\"")
  33.                         os.system("./make_fself.exe -e -c  \""+root+"/"+file + ".elf\" \""+root+"/"+file+"\"")
  34.                         print("Reading authid...")
  35.                         f = open(root+"/"+file+".bak","rb")
  36.                         f.seek(0x80)
  37.                         authid = f.read(0x8)
  38.                         f.close()
  39.                         print("Writing authid...")
  40.                         f = open(root+"/"+file,"r+b")
  41.                         f.seek(0x80)
  42.                         f.write(authid)
  43.                         f.close()
  44.                     else:
  45.                         print("Reading authid...")
  46.                         f = open(root+"/"+file+".bak","rb")
  47.                         f.seek(0x80)
  48.                         authid = f.read(0x8)
  49.                         f.close()
  50.                        
  51.                         print("Execute "+"vita-make-fself -c -a 0x"+authid.encode('hex')+" \""+root+"/"+file + ".elf\" \""+root+"/"+file+"\"")
  52.                         os.system("vita-make-fself -c -a 0x"+authid.encode('hex')+" \""+root+"/"+file + ".elf\" \""+root+"/"+file+"\"")
  53.  
  54.                 except:
  55.                     print "Failed to decrypt: "+file
  56.  
  57. if __name__ == "__main__":
  58.     DecryptGame(sys.argv[1],sys.argv[2])
Advertisement
Add Comment
Please, Sign In to add comment