Skip to content

Instantly share code, notes, and snippets.

@Luro02
Created July 2, 2018 13:16
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Luro02/4038c3fb496d92d0b3bebffa7f124623 to your computer and use it in GitHub Desktop.
Save Luro02/4038c3fb496d92d0b3bebffa7f124623 to your computer and use it in GitHub Desktop.
Very early stage of a possible way to install H-encore....
#!/usr/bin/env python3
"""
Do whatever you want with it...
I am too lazy to make it compatible on other platforms or create a gui...
this thing works and it should do the job for some people/may be a help for
someone who is working on this:
https://www.reddit.com/r/vitahacks/comments/8vbkf8/concept_how_to_make_a_proper_user_friendly/
Made by Luro02 in under 2 hours (I know, impressive)
"""
import os
import sys
import requests
import zipfile
import shutil
session = requests.Session()
if os.name != 'nt':
sys.exit('currently this script only works on windows.')
def DownloadFile(url: str, local_filename: str=''):
if not local_filename:
local_filename = url.split('/')[-1]
r = requests.get(url)
with open(local_filename, 'wb') as f:
for chunk in r.iter_content(chunk_size=1024):
if chunk: # filter out keep-alive new chunks
f.write(chunk)
return
def downloadfromGithubUrl(url: str):
r = session.get(url, stream=True)
with open('temp.zip', 'wb') as fd:
fd.write(r.raw.read())
with zipfile.ZipFile("temp.zip", "r") as zip_ref:
zip_ref.extractall('temp')
try:
os.remove('temp.zip')
except:
pass
return
qcma_folder = None
if os.path.exists(os.path.expanduser('~/Documents/PS Vita/APP')):
print("QCMA Folder found!")
qcma_folder = os.path.expanduser('~/Documents/PS Vita/APP')
try:
aid = os.listdir(qcma_folder)[0]
if len(aid) != 16:
sys.exit("invalid length!")
except:
aid = None
else:
print('Please enter your AID:')
aid = input('>> ')
if not aid:
sys.exit('PLEASE ENTER SOMETHING OR I MAY FORMAT YOUR HDD...')
else:
r = session.get('http://cma.henkaku.xyz/', params={'aid': aid})
aid_key = r.content.split(b' ')[-1].replace(b'\n', b'').decode('utf-8')
if aid_key == "invalid</b>":
sys.exit("Input is invalid...")
print(f"Your AID_key is: '{aid_key}'")
if qcma_folder:
print(f"Your QCMA-Folder is: '{qcma_folder}'")
print('Downloading dependencies...')
downloadfromGithubUrl('https://github.com/mmozeiko/pkg2zip/releases/download/v1.8/pkg2zip_64bit.zip')
downloadfromGithubUrl('https://github.com/yifanlu/psvimgtools/releases/download/v0.1/psvimgtools-0.1-win64.zip')
downloadfromGithubUrl('https://github.com/TheOfficialFloW/h-encore/releases/download/v1.0/h-encore.zip')
print("Please wait downloading the pkg now...(this could take a while...)")
DownloadFile('http://ares.dl.playstation.net/cdn/JP0741/PCSG90096_00/xGMrXOkORxWRyqzLMihZPqsXAbAXLzvAdJFqtPJLAZTgOcqJobxQAhLNbgiFydVlcmVOrpZKklOYxizQCRpiLfjeROuWivGXfwgkq.pkg', 'temp/temp.pkg')
print("Finished downloading all required files!")
os.system('temp\\pkg2zip -x temp/temp.pkg')
os.remove('temp/temp.pkg')
shutil.copy('app/PCSG90096/sce_sys/package/temp.bin', 'temp/h-encore/license/ux0_temp_game_PCSG90096_license_app_PCSG90096/6488b73b912a753a492e2714e9b38bc7.rif')
try:
for item in os.listdir('app/PCSG90096'):
temp_path = os.path.join('app/PCSG90096', item)
if os.path.isdir(temp_path):
shutil.copytree(temp_path, os.path.join('temp/h-encore/app/ux0_temp_game_PCSG90096_app_PCSG90096/', item))
else:
shutil.copy(temp_path, os.path.join('temp/h-encore/app/ux0_temp_game_PCSG90096_app_PCSG90096/', item))
except FileExistsError:
pass
print('done copying stuff over...')
# execute the crypto commands:
os.system(f'temp\\psvimg-create.exe -n app -K {aid_key} temp/h-encore/app temp/h-encore/PCSG90096/app')
os.system(f'temp\\psvimg-create.exe -n appmeta -K {aid_key} temp/h-encore/appmeta temp/h-encore/PCSG90096/appmeta')
os.system(f'temp\\psvimg-create.exe -n license -K {aid_key} temp/h-encore/license temp/h-encore/PCSG90096/license')
os.system(f'temp\\psvimg-create.exe -n savedata -K {aid_key} temp/h-encore/savedata temp/h-encore/PCSG90096/savedata')
# move the folder one directory upwards:
try:
if qcma_folder:
shutil.copytree('temp/h-encore/PCSG90096', os.path.join(os.path.join(qcma_folder, aid), 'PCSG90096'))
else:
shutil.copytree('temp/h-encore/PCSG90096', 'PCSG90096')
except FileExistsError:
pass
try:
os.remove('temp')
os.remove('app')
except:
pass
print('done :P')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment