motoharu-gosuto / psvpfstools

Tools for decrypting PS Vita PFS filesystem
127 stars 22 forks source link

Decrypting SaveData error: "Unexpected file type" #51

Open jpenalbae opened 3 years ago

jpenalbae commented 3 years ago

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 commented 3 years ago

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

jpenalbae commented 3 years ago

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

ghost commented 3 years ago

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

jpenalbae commented 3 years ago

You can find the save here:

https://drive.google.com/file/d/1mWjthnepC7fzGMdR7RqgezixGREHQ9sh/view?usp=sharing

ghost commented 3 years ago

The error is due to this check failing.

https://github.com/motoharu-gosuto/psvpfstools/blob/558b91ca401cbf2720b44e8d65e232ce248b795a/psvpfsparser/FilesDbParser.cpp#L316-L320

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

https://github.com/motoharu-gosuto/psvpfstools/blob/558b91ca401cbf2720b44e8d65e232ce248b795a/psvpfsparser/FilesDbParser.h#L78-L93

Decrypted save data is attached.

ux0_temp_game_PCSE00120_savedata_PCSE00120_dec.zip

Kalanyr commented 3 years ago

@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 commented 3 years ago

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 commented 3 years ago

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 commented 3 years ago

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