VitaSmith / gust_tools

A set of utilities for dealing with Gust (Koei Tecmo) PC games files
Other
206 stars 23 forks source link

Failed to unpack PACK00_02.PAK of Atelier Sophie 2 #57

Closed fioredio closed 2 years ago

fioredio commented 2 years ago

PACK00_02.PAK of Atelier Sophie 2 (steam) cannot be extracted with v1.49 gust_pak.exe giving the following error:

Extracting 'PACK00_02.PAK'... Detected A22/64-bit PAK format

OFFSET SIZE NAME 00003fd68 00005c67 8#&?90zA)J ERROR: Can't create file 'C:\Program Files (x86)\Steam\steamapps\common\Atelier Sophie 2\Data\8#&?90zA)J'

Masquerade64 commented 2 years ago

Adding to this, none of the PAKs from Atelier Sophie 2 can be unpacked with gust_pak.exe.

I have uploaded a sample PAK here if you wish to take a look.

20051231 commented 2 years ago

I created a pull request for decoding A23 PAK. It needs a per game key but I am not sure is it legal to post it or not.

The key is in 0x11AFC58 in the game binary. A 32 characters ASCII string.

Masquerade64 commented 2 years ago

@20051231 Working great, thanks for the fix 👍

VitaSmith commented 2 years ago

@20051231, very nice work indeed. I'm also wondering about the publishing of the decrypting key, though, to be honest, I don't think a key that appears in plain text in an executable, for everybody to see, can be considered as something that can give way to legal action if published.

Interestingly, since I was using a different approach to look into the unpacking (basically, I've been trying to avoid going through the debugger, in case I could figure the changes by just looking at the data), I think I might have found a way to crack the key, without having to get it from the executable.

At any rate, I'll need to rework your patch so that, for the time being, we can drop the need for users to provide the key, either by embedding it in the executable or, preferably, cracking it (so that, if KT use the same method for A24, we might get unpacking on day zero).

It may be a couple of days before I publish an updated version if gust_pak with these changes. But you do have my thanks, as well as some well deserved congratulations, for figuring out the new algorithm and key.

VitaSmith commented 2 years ago

Okay, all things considered, I am going to hardcode the master key for A23 in the application, because it is certainly possible to derive it directly from the PAK files without looking at the executable, and that should leave us safe from any legal proceeding (if legally challenged, I will be happy to publish proof of how it is possible to "guess" the key directly from a PAK file on a machine where Atelier_Sophie_2.exe is not present).

I am not going to add actual cracking of the key to the application however, as I think it's preferable not to let KT know how this can be accomplished and, since we don't actually need to poke into the .exe to obtain these keys for now, I see no legal issue with going the hardcode route.

Expect a release with A23 support soon.