Editing Sealedkey / pfsSKKey
Jump to navigation
Jump to search
The edit can be undone. Please check the comparison below to verify that this is what you want to do, and then publish the changes below to finish undoing the edit.
Latest revision | Your text | ||
Line 1: | Line 1: | ||
This key can be found on different places and will be used for eg. | This key can be found on different places and will be used for eg. SaveGame or Trophy Data decryption and encryption. | ||
==== Paths ==== | |||
==== | |||
{| class="wikitable" | {| class="wikitable" | ||
|- | |- | ||
! Kind !! Path | ! Kind !! Path | ||
|- | |- | ||
| | | Trophys || /user/home/[[User ID|user Id]]/trophy/data/[[sce_trop]]/sealedkey | ||
|- | |- | ||
| | | SaveGames || /user/home/[[User ID|user Id]]/[[NP Title ID|title Id]]/[[save data directory]]/[[sce_sys]]/ | ||
|} | |} | ||
== Structure == | == Structure == | ||
- size always 96 bytes | |||
- size | |||
{| class="wikitable" | {| class="wikitable" | ||
Line 22: | Line 19: | ||
| 00 || 07 || MAGIC ("pfsSKKey") (?playstation file system sealed key key?) | | 00 || 07 || MAGIC ("pfsSKKey") (?playstation file system sealed key key?) | ||
|- | |- | ||
| 08 || | | 08 || 0F || Category (game=1 or version ?) | ||
|- | |- | ||
| 10 || 1F || IV (16 bytes) | | 10 || 1F || IV (16 bytes) | ||
Line 35: | Line 30: | ||
'''C''' | '''C''' | ||
<source lang="c"> | <source lang="c"> | ||
typedef struct | typedef struct sealedkey { | ||
const unsigned char MAGIC[8]; | const unsigned char MAGIC[8]; | ||
const unsigned char | const unsigned char CAT[8]; | ||
const unsigned char IV[16]; | const unsigned char IV[16]; | ||
const unsigned char KEY[32]; | const unsigned char KEY[32]; | ||
const unsigned char SHA256[32]; | const unsigned char SHA256[32]; | ||
} | } selaedkey; | ||
</source> | </source> | ||
Line 49: | Line 43: | ||
protected internal struct sealedkey { | protected internal struct sealedkey { | ||
internal static byte[] MAGIC = new byte[8]; | internal static byte[] MAGIC = new byte[8]; | ||
internal static byte[] CAT = new byte[8]; | |||
internal static byte[] | |||
internal static byte[] IV = new byte[16]; | internal static byte[] IV = new byte[16]; | ||
internal static byte[] KEY = new byte[32]; | internal static byte[] KEY = new byte[32]; | ||
Line 57: | Line 50: | ||
</source> | </source> | ||
Note: You | Note: You can't use a const byte[] defination in C#. It need to be a static byte[]. | ||
== De/En -Crypting == | == De/En -Crypting == | ||
Can be decrypted by frindly asking the OS to do it for you. You will need kernel rights to be able to ask the PS4 for it. | |||
Can be decrypted by | |||
<source lang="c"> | <source lang="c"> | ||
/* Decryption */ | /* Decryption */ | ||
Line 73: | Line 65: | ||
typedef unsigned char byte; /* byte defination for c/c++ */ | typedef unsigned char byte; /* byte defination for c/c++ */ | ||
const char USER1 = "10000000"; | const char USER1 = "10000000"; | ||
const char usb0 = "/mnt/usb0/"; | const char usb0 = "/mnt/usb0/"; | ||
Line 82: | Line 72: | ||
const char tropkey = "/trophy/data/sce_trop/sealedkey"; | const char tropkey = "/trophy/data/sce_trop/sealedkey"; | ||
char usb_error = "[-] ERROR: Can't access usb0 nor usb1!\n[-] Will return now to caller.\n" | char usb_error = "[-] ERROR: Can't access usb0 nor usb1!\n[-] Will return now to caller.\n" | ||
char usb0path[( | char usb0path[(sizeof(usb0) + sizeof(pfs))]; | ||
char usb1path[ | char usb1path[sizeof(usb0path)]; | ||
/* Get's the encrypted sealed key based on user id */ | /* Get's the encrypted sealed key based on user id */ | ||
int get_pfsSKKey(byte *buffer, const char *userID, char path) { | int get_pfsSKKey(byte *buffer, const char *userID, char path) { | ||
char toOpen[( | char toOpen[(sizeof(home) + sizeof(userID) + sizeof(path))]; | ||
snprintf(toOpen, sizeof(toOpen), %s%s%s, home, userID, path) | |||
FILE *pfskey = fopen(toOpen, "r"); | FILE *pfskey = fopen(toOpen, "r"); | ||
Line 105: | Line 95: | ||
/* First load the sealedkey into a buffer */ | /* First load the sealedkey into a buffer */ | ||
byte enc_pfsSKKey[96]; | |||
if (!get_pfsSKKey(& | if (!get_pfsSKKey(&enc_pfsSKKey, USER1, tropkey)) { | ||
printf("[-] Can not load the sealed key!\n"); | printf("[-] Can not load the sealed key!\n"); | ||
return -1; | return -1; | ||
} | } | ||
/* Now decrypt it */ | /* Now decrypt it */ | ||
byte | byte dec_pfsSKKey[16]; | ||
int i; | int i; | ||
if (!(i = kernel.sceSblSsDecryptSealedKey(& | if (!(i = kernel.sceSblSsDecryptSealedKey(&enc_pfsSKKey, &dec_pfsSKKey))) { | ||
printf("[-] Error!\n[-] sceSblSsDecryptSealedKey returned %d\n", i); | printf("[-] Error!\n[-] sceSblSsDecryptSealedKey returned %d\n", i); | ||
return -1; | return -1; | ||
Line 139: | Line 114: | ||
printf("[+] Your decrypted sealedkey = "); | printf("[+] Your decrypted sealedkey = "); | ||
foreach(byte *val, & | foreach(byte *val, &dec_pfsSKKey) { printf("%02X", *val); } | ||
printf("\n"); | printf("\n"); | ||
Line 147: | Line 122: | ||
printf("[+] Will try to save to file..."); | printf("[+] Will try to save to file..."); | ||
snprintf(usb0path, sizeof(usb0path), %s%s, usb0, pfs); | |||
snprintf(usb1path, sizeof(usb1path), %s%s, usb1, pfs); | |||
FILE *dump = fopen(usb0path, "w"); | FILE *dump = fopen(usb0path, "w"); | ||
Line 155: | Line 130: | ||
dump = fopen(usb1path, "w"); | dump = fopen(usb1path, "w"); | ||
if (!dump) { | if (!dump) { | ||
printf("fail!\n%s", usb_error); | printf("fail!\n%s" ,usb_error); | ||
return -3; | return -3; | ||
} | } | ||
} | } | ||
fwrite(& | fwrite(&dec_pfsSKKey, 16, 1, dump); | ||
printf("done!\n"); | printf("done!\n"); | ||
fclose(dump); | fclose(dump); | ||
Line 167: | Line 142: | ||
} | } | ||
</source> | </source> | ||