Skip to content

Instantly share code, notes, and snippets.

@Luro02
Created February 13, 2018 17:27
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/52dafc98fbf807887ddf8660cc80f1e4 to your computer and use it in GitHub Desktop.
Save Luro02/52dafc98fbf807887ddf8660cc80f1e4 to your computer and use it in GitHub Desktop.
partially working implementation of how the PSVita creates PDB's....
#!/usr/bin/env python3
def create_pdb(filename, title, location, pkg_link, icon_path, temp_dat, cid, date='Wed, 16 Apr 2008 11:11:41 GMT'):
"""
Example:
title = 'Ape Quest'
location = 'ux0:pspemu/bgdl/0000010d'
pkg_name = 'cCC53YedwIstMh54hhulsqmHmlLCMr4He9aKSNFGRTDNGvcUgcqpqbAcFU25tJC8PN1ksFVqlErDjeHYyijpCfqHD5WSAu6qqEDlt.pkg'
pkg_link = 'http://zeus.dl.playstation.net/cdn/EP9000/NPEG00005_00/cCC53YedwIstMh54hhulsqmHmlLCMr4He9aKSNFGRTDNGvcUgcqpqbAcFU25tJC8PN1ksFVqlErDjeHYyijpCfqHD5WSAu6qqEDlt.pkg?country=de'
icon_path = 'ux0:bgdl/t/0000010d/icon.png'
cid = 'EP9000-NPEG00005_00'
date = 'Wed, 16 Apr 2008 11:11:41 GMT'
titleid = 'NPEG00005'
todo:
pkg_name von Link extrahieren
icon per cid downloaden
titleid aus cid extrahieren
"""
# make the arguments binary
title = title.encode()
location = location.encode()
pkg_name = pkg_link[pkg_link.rfind("/")+1:].encode()
pkg_link = pkg_link.encode() + b'?country=de'
icon_path = icon_path.encode()
temp_dat = temp_dat.encode()
cid = pkg_link[35:54].replace(b'/', b'-') + b'-0000000000000001'
date = date.encode()
titleid = cid[7:16]
# add spaces + header + footer + unknown stuff
header = b'\x00\x00\x00\x00d\x00\x00\x00\x04\x00\x00\x00\x04\x00\x00\x00\x00\x00\x00\x00e\x00\x00\x00\x04\x00\x00\x00\x04\x00\x00\x00\x01\x00\x00\x00f\x00\x00\x00\x01\x00\x00\x00\x01\x00\x00\x00\x01k\x00\x00\x00\x04\x00\x00\x00\x04\x00\x00\x00\x06\x00\x00\x00h\x00\x00\x00\x04\x00\x00\x00\x04\x00\x00\x00\x1c:\x10\x80l\x00\x00\x00\x04\x00\x00\x00\x04\x00\x00\x00\x01\x00\x00\x00m\x00\x00\x00\x04\x00\x00\x00\x04\x00\x00\x00\x02\x00\x00\x00n\x00\x00\x00\x01\x00\x00\x00\x01\x00\x00\x00\x00p\x00\x00\x00\x01\x00\x00\x00\x01\x00\x00\x00\x01q\x00\x00\x00\x01\x00\x00\x00\x01\x00\x00\x00\x00r\x00\x00\x00\x04\x00\x00\x00\x04\x00\x00\x00\x01\x00\x00\x00s\x00\x00\x00\x01\x00\x00\x00\x01\x00\x00\x00\x00t\x00\x00\x00\x01\x00\x00\x00\x01\x00\x00\x00\x00o\x00\x00\x00\x04\x00\x00\x00\x04\x00\x00\x00\x00\x00\x00\x00i'
space_1 = b'\x00\x00\x00\n\x00\x00\x00\n\x00\x00\x00'
space_2 = b'\x00\xe5\x00\x00\x00\x19\x00\x00\x00\x19\x00\x00\x00'
space_3 = b'\x00\xcb\x00\x00\x00j\x00\x00\x00j\x00\x00\x00'
space_4 = b'\x00\xca\x00\x00\x00\xac\x00\x00\x00\xac\x00\x00\x00'
space_5 = b'\x00j\x00\x00\x00\x1d\x00\x00\x00\x1d\x00\x00\x00'
space_6 = b'\x00\xe6\x00\x00\x00\x1d\x00\x00\x00\x1d\x00\x00\x00'
space_7 = b'\x00\xd9\x00\x00\x00%\x00\x00\x00%\x00\x00\x00'
space_8 = b'\x00\xdc\x00\x00\x00\n\x00\x00\x00\n\x00\x00\x00'
space_9 = b'\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00'
footer = b'\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\xcd\x00\x00\x00\x01\x00\x00\x00\x01\x00\x00\x00\x01\xec\x00\x00\x00\x04\x00\x00\x00\x04\x00\x00\x00z\xca\xb0\x99\xed\x00\x00\x00 \x00\x00\x00 \x00\x00\x00\x14\xe3\xb2\x02\x0f\x90{\xbb\x08\xaa\x1e\x01e5\x9c\x04\xd4\x94\x0eM\x93\x1e\x07\x87\xa6\xec\x14\xe1\xa3v\xdcX'
temp_dat = b'ux0:bgdl/t/0000010d/temp.dat'
unknown_1 = b'\x00\xda\x00\x00\x00\x01\x00\x00\x00\x01\x00\x00\x00\x01\xce\x00\x00\x00\x08\x00\x00\x00\x08\x00\x00\x00\xa0Fw\x0e\x00\x00\x00\x00\xd0\x00\x00\x00\x08\x00\x00\x00\x08\x00\x00\x00\x00\x00q\x00\x00\x00\x00\x00\xcc\x00\x00\x00\x1e\x00\x00\x00\x1e\x00\x00\x00'
unknown_2 = b'\x00\xe8\x00\x00\x00x\x00\x00\x00x\x00\x00\x00\x02\x00\x00\x00\x07\x00\x00\x00\x0c\x02\x00\x80\n\x00\x00\x00\xc0\x04\x00\x00\x00\x00\x00\x00\x00@w\x0e\x00\x00\x00\x00\xa0Fw\x0e\x00\x00\x00\x00'
binary_string = header + space_1 + title + space_2 + location + space_3 + pkg_name + space_4 + pkg_link + space_5 + icon_path + space_6 + temp_dat + space_7 + cid + unknown_1 + date + space_8 + titleid + unknown_2 + cid + space_9 + titleid + footer
with open(filename, 'bw+') as f:
f.write(binary_string)
return 0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment