Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Decrypting SaveData error: "Unexpected file type" #51

Open
jpenalbae opened this issue Feb 3, 2021 · 9 comments
Open

Decrypting SaveData error: "Unexpected file type" #51

jpenalbae opened this issue Feb 3, 2021 · 9 comments

Comments

@jpenalbae
Copy link

I'm trying to decrypt persona 4 golden save file. Copied the save to my computer using qcma, extracted the savedata.psvimg file using psvimgtools-0.1-linux64, and then tried to decrypt using psvpfstools but I'm getting an "Unexpected file type" error.

$ ./psvpfsparser -i ux0_temp_game_PCSE00120_savedata_PCSE00120/ -o save_dec/ -f http://cma.henkaku.xyz
Missing option --klicensee or --zRIF
sealedkey will be used
using sealedkey...
sealedkey: matched retail hmac
parsing  files.db...
verifying header...
header signature is valid
root icv is valid
Unexpected file type
@ghost
Copy link

ghost commented Feb 22, 2021

I fixed the problems with decrypting savegames in my fork here https://github.com/cuevavirus/psvpfstools

@jpenalbae
Copy link
Author

I'm getting the same error message when using master branch from your fork @cuevavirus

@ghost
Copy link

ghost commented Feb 24, 2021

I can take a look if you don't mind uploading your save file

@jpenalbae
Copy link
Author

@ghost
Copy link

ghost commented Mar 7, 2021

The error is due to this check failing.

if(!is_valid_file_type(fi.header.type))
{
std::cout << "Unexpected file type" << std::endl;
return false;
}

This save data contains many files of type 0x0004 which is not described here.

enum sce_ng_pfs_file_types : std::uint16_t
{
unexisting = ATTR_RW_OR_NONE, //(0x0000)
normal_file = ATTR_RO, //(0x0001)
normal_directory = ATTR_DIR, //(0x8000)
sys_directory = ATTR_DIR | ATTR_SYS1 | ATTR_SYS2, //(0x8006)
unencrypted_system_file_rw = ATTR_NENC | ATTR_SYS1 | ATTR_SYS2, //(0x4006)
encrypted_system_file_rw = ATTR_SYS1 | ATTR_SYS2, //(0x0006)
unencrypted_system_file_ro = ATTR_NENC | ATTR_SYS1 | ATTR_SYS2 | ATTR_RO, //(0x4007)
encrypted_system_file_ro = ATTR_SYS1 | ATTR_SYS2 | ATTR_RO, //(0x0007)
acid_directory = ATTR_DIR | ATTR_AC | ATTR_SYS2, //(0x9004) encountered in ADDCONT
};

Decrypted save data is attached.

ux0_temp_game_PCSE00120_savedata_PCSE00120_dec.zip

@Kalanyr
Copy link

Kalanyr commented Mar 18, 2021

@cuevavirus
Do you have a plan for a generic fix?

I have 91 saves and of those only 28 did not have this error so it seems to be a common problem*. I can send you a zip of the saves if that would be helpful.

Even for the successful one many had warnings like this:
[WARNING] Directory SCE_SYS size is invalid
Building file matrix...
[WARNING] Invalid file type for file SDSLOT.DAT. assuming file is encrypted

(These are all files that have been backed up to PSN and then redownloaded which I suspect accounts for the SCE_SYS size being invalid, I've noticed the PSN size and the Vita size clash frequently)

*I suspect it's slightly more common than that number would indicated because some of the successful ones are ones where save data has been generated from starting a game but I haven't actually made a save that contains anything so they only contain the sce_sys files.

@ghost
Copy link

ghost commented Mar 19, 2021

If you could upload the saves that'd be great, so that I can see what other file types there are. The warnings are always there when decrypting savegames, so I will probably remove them.

@Kalanyr
Copy link

Kalanyr commented Mar 19, 2021

If you could upload the saves that'd be great, so that I can see what other file types there are. The warnings are always there when decrypting savegames, so I will probably remove them.

I've uploaded the files to a dropbox, and am happy to send you a link if you could drop an email address or some other contact method (the files are associated with an account I still use and some are for online games so I'd prefer not to risk dumping them all publicly)

(I can be reached at mygithubusername AT gmail.com if you prefer that)

@Zangetsu38
Copy link

Zangetsu38 commented May 9, 2021

image
I have succes decrypt my sazve and save working with added this type 4 (ATTR_SYS2) on is_encrypted and on
is_valid_file_type

have founded other type save no works : 32772
image
this time is >(ATTR_DIR | ATTR_SYS2)
edit: also fixed for this type
image

@Kalanyr binary for that, i hope can decrype all your save, in my side i have succes decrypt full my save
psvpfsparser.zip

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants