Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #Requires make_fself.exe in the same directory as .py file
- #And unoffical vitasdk required for kernel modules.
- from self2elf import *
- from scetypes import *
- import sys
- import os
- def DecryptSelf(inputfile, outputfile, keyriffile=0):
- with open(inputfile, "rb") as inf:
- with open(outputfile, "wb") as outf:
- if keyriffile:
- with open(keyriffile, "rb") as rif:
- lic = SceRIF(rif.read(SceRIF.Size))
- self2elf(inf, outf, lic.klicense)
- else:
- self2elf(inf, outf, 0)
- def DecryptGame(gamefolder,rif=0):
- for root, subdirs, files in os.walk(gamefolder):
- for file in files:
- if open(os.path.abspath(root+"/"+file)).read(0x3) == "SCE":
- print("Decrypt SELF: "+file)
- try:
- if sys.argv[2] == "kernel" or sys.argv[2] == "user":
- DecryptSelf(os.path.abspath(root+"/"+file),os.path.abspath(root+"/"+file) + ".elf")
- else:
- DecryptSelf(os.path.abspath(root+"/"+file),os.path.abspath(root+"/"+file) + ".elf",rif)
- os.rename(root+"/"+file,root+"/"+file+".bak")
- if sys.argv[2] != "kernel":
- print("Execute "+"./make_fself.exe -e -c \""+root+"/"+file + ".elf\" \""+root+"/"+file+"\"")
- os.system("./make_fself.exe -e -c \""+root+"/"+file + ".elf\" \""+root+"/"+file+"\"")
- print("Reading authid...")
- f = open(root+"/"+file+".bak","rb")
- f.seek(0x80)
- authid = f.read(0x8)
- f.close()
- print("Writing authid...")
- f = open(root+"/"+file,"r+b")
- f.seek(0x80)
- f.write(authid)
- f.close()
- else:
- print("Reading authid...")
- f = open(root+"/"+file+".bak","rb")
- f.seek(0x80)
- authid = f.read(0x8)
- f.close()
- print("Execute "+"vita-make-fself -c -a 0x"+authid.encode('hex')+" \""+root+"/"+file + ".elf\" \""+root+"/"+file+"\"")
- os.system("vita-make-fself -c -a 0x"+authid.encode('hex')+" \""+root+"/"+file + ".elf\" \""+root+"/"+file+"\"")
- except:
- print "Failed to decrypt: "+file
- if __name__ == "__main__":
- DecryptGame(sys.argv[1],sys.argv[2])
Advertisement
Add Comment
Please, Sign In to add comment