Post: Fixed Keys / Ungpkgs for Vita Release by Der0ad
11-30-2016, 05:03 PM #1
Hydrogen
Super Mod
(adsbygoogle = window.adsbygoogle || []).push({}); Hello NextGenUpdate, previously, PS Vita Developer You must login or register to view this content. had released his code for decrypted PS Vita .PKGs. Which you can find here: You must login or register to view this content..

A twitter user by name You must login or register to view this content. has now released the fixed version of St4rk's work. You can find both Github links down below.

GitHub Fixed Keys: You must login or register to view this content.

GitHub Fixed Ungpkgs
: You must login or register to view this content.

Fixed Keys Code:

    gpkg-key-2

@@ -1 +1 @@
-**********p****************************+******************b)c***************************
+*********۵***************************8*********Oް


    
gpkg-key-3

@@ -1 +1 @@
-B:*********:+*********d*********************************************o؀*
+*********L********************wG********** *********L@*********J


    
gpkg-key-4

@@ -1 +1 @@
-******************Ye%'******************3*********f***************************
+*********e*********^******************b"******************ਗ0F*********


    gpkg-key-beta → gpkg-key-psp


Fixed Ungpkgs Code:


    @@ -32,21 +32,6 @@ static u64 offset;



-static void decrypt_beta_retail_pkg(void)
-{
- u8 key[0x10];
- u8 iv[0x10];
-
- if (be16(pkg + 0x06) != 2)
- fail("invalid pkg type: %x", be16(pkg + 0x06));
-
- if (key_get_simple("gpkg-key-beta", key, 0x10) < 0)
- fail("failed to load the beta package key.");
-
- memcpy(iv, pkg + 0x70, 0x10);
- aes128ctr(key, iv, pkg + offset, size, pkg + offset);
-}
-
static void decrypt_retail_pkg(void)
{
u8 key[0x10];
@@ -55,8 +40,23 @@ static void decrypt_retail_pkg(void)
if (be16(pkg + 0x06) != 2)
fail("invalid pkg type: %x", be16(pkg + 0x06));

- if (key_get_simple("gpkg-key", key, 0x10) < 0)
+ u32 type = be32(pkg + 0xE4) & 0xFF;
+ if(type == 1) {
+ if (key_get_simple("gpkg-key-psp", key, 0x10) < 0)
+ fail("failed to load the psp package key.");
+ } else if(type == 2) {
+ if (key_get_simple("gpkg-key-2", key, 0x10) < 0)
+ fail("failed to load the package key.");
+ } else if(type == 3) {
+ if (key_get_simple("gpkg-key-3", key, 0x10) < 0)
fail("failed to load the package key.");
+ } else if(type == 4) {
+ if (key_get_simple("gpkg-key-4", key, 0x10) < 0)
+ fail("failed to load the package key.");
+ } else {
+ printf("Key Type: %d\n", type);
+ fail("failed to find the package key.");
+ }

memcpy(iv, pkg + 0x70, 0x10);
aes128ctr(key, iv, pkg + offset, size, pkg + offset);
@@ -113,7 +113,6 @@ static void unpack_pkg(void)
u8 *tmp;

n_files = be32(pkg + 0x14);
-
for (i = 0; i < n_files; i++) {
tmp = pkg + offset + i*0x20;

@@ -130,12 +129,16 @@ static void unpack_pkg(void)
strncpy(fname, (char *)(pkg + fname_off), fname_len);

flags &= 0xff;
- if (flags == 4)
+ if (flags == 4 || flags == 1Cool Man (aka Tustin) {
+ printf(" %02x : %s\n", flags, fname);
MKDIR(fname, 0777);
- else if (flags == 0 || flags == 1 || flags == 3 || flags == 14)
+ } else if (flags == 0 || flags == 1 || flags == 3 || flags == 14 ||
+ flags == 15 || flags == 16 || flags == 17 || flags == 19 ||
+ flags == 21 || flags == 22) {
+ printf(" %02x : %s (%u bytes)\n", flags, fname, size);
memcpy_to_file(fname, pkg + file_offset, size);
- else
- fail("unknown flags: %08x", flags);
+ } else
+ fail("unknown flag %d for %s", flags, pkg + fname_off);
}
}

@@ -147,8 +150,7 @@ int main(int argc, char *argv[])

if (argc != 2 && argc != 3)
fail("usage: ungpkg filename.pkg\n"
- " This is just for PS Vita Game Packages. not PS Vita System Packages.\n"
- " -b | use beta key instead of the retail one");
+ " This is just for PS Vita Game Packages. not PS Vita System Packages.\n");

if (argc == 2) {
pkg = mmap_file(argv[1]);
@@ -157,13 +159,7 @@ int main(int argc, char *argv[])
memset(dir, 0, 0x30);
memcpy(dir, pkg + 0x30, 0x30);
} else {
- if (strcmp(argv[1], "-b") != 0)
- fail("invalid option: %s", argv[1]);
- else
- beta=1;
-
pkg = mmap_file(argv[2]);
-
dir = malloc(0x31);
memset(dir, 0, 0x31);
memset(dir, 0, 0x30);
@@ -178,9 +174,7 @@ int main(int argc, char *argv[])
offset = be64(pkg + 0x20);
size = be64(pkg + 0x2Cool Man (aka Tustin);

- if(be16(pkg + 0x04) & 0x8000 && beta)
- decrypt_beta_retail_pkg();
- else if (be16(pkg + 0x04) & 0x8000)
+ if(be16(pkg + 0x04) & 0x8000)
decrypt_retail_pkg();
else
decrypt_debug_pkg();
(adsbygoogle = window.adsbygoogle || []).push({});

The following user thanked Hydrogen for this useful post:

SHAkA

Copyright © 2026, NextGenUpdate.
All Rights Reserved.

Gray NextGenUpdate Logo