[HELP] *.PAK (PK) archive

Extraction and unpacking of game archives and compression, encryption, obfuscation, decoding of unknown files
amVspR
Posts: 40
Joined: Mon Aug 14, 2017 2:45 am

[HELP] *.PAK (PK) archive

Post by amVspR »

Hi there, I need help extracting this PAK (PK) archive from a decrypted PSV game (Gakuen K wonderful school days). Many thanks in advance. I tried the available PK scripts here but no luck.
Here're the samples:
Link: https://mega.nz/file/t9YXVbTR#-Noed9z0O ... qYcjawkMVc
BloodRaynare
Posts: 367
Joined: Fri Mar 10, 2017 7:23 am

Re: [HELP] *.PAK (PK) archive

Post by BloodRaynare »

Pretty sure this file is just a normal zip file, you can use 7-zip to extract it.
amVspR
Posts: 40
Joined: Mon Aug 14, 2017 2:45 am

Re: [HELP] *.PAK (PK) archive

Post by amVspR »

BloodRaynare wrote:Pretty sure this file is just a normal zip file, you can use 7-zip to extract it.

Thanks for replying! I tried 7-zip with the original PAK archive, but only 1 file "BG_001_a.DAT_" extracted.
BloodRaynare
Posts: 367
Joined: Fri Mar 10, 2017 7:23 am

Re: [HELP] *.PAK (PK) archive

Post by BloodRaynare »

amVspR wrote:Thanks for replying! I tried 7-zip with the original PAK archive, but only 1 file "BG_001_a.DAT_" extracted.


If you open the original PAK with hex editor, does it has the multiple instances of "PK" followed by the filenames? (Normally, zip files has those things at the tail end of the file).
amVspR
Posts: 40
Joined: Mon Aug 14, 2017 2:45 am

Re: [HELP] *.PAK (PK) archive

Post by amVspR »

BloodRaynare wrote:
amVspR wrote:Thanks for replying! I tried 7-zip with the original PAK archive, but only 1 file "BG_001_a.DAT_" extracted.


If you open the original PAK with hex editor, does it has the multiple instances of "PK" followed by the filenames? (Normally, zip files has those things at the tail end of the file).

Here's what it looks like in Hex (attached), there's only 1 PK at the beginning
BloodRaynare
Posts: 367
Joined: Fri Mar 10, 2017 7:23 am

Re: [HELP] *.PAK (PK) archive

Post by BloodRaynare »

amVspR wrote:Here's what it looks like in Hex (attached), there's only 1 PK at the beginning


Try use "Find" (Ctrl-F) then enter this in "hex-values" field: 504b0304 (or 504b0102), then choose "Search All" and post how many search "Hits" the HxD reports?
amVspR
Posts: 40
Joined: Mon Aug 14, 2017 2:45 am

Re: [HELP] *.PAK (PK) archive

Post by amVspR »

BloodRaynare wrote:
amVspR wrote:Here's what it looks like in Hex (attached), there's only 1 PK at the beginning


Try use "Find" (Ctrl-F) then enter this in "hex-values" field: 504b0304 (or 504b0102), then choose "Search All" and post how many search "Hits" the HxD reports?

1720 hits for 504b0102
1719 hits for 504b0304
BloodRaynare
Posts: 367
Joined: Fri Mar 10, 2017 7:23 am

Re: [HELP] *.PAK (PK) archive

Post by BloodRaynare »

amVspR wrote:1720 hits for 504b0102
1719 hits for 504b0304


Okay, can you screenshot the contents of the few (not all) of those hits? (Double click on the results)
amVspR
Posts: 40
Joined: Mon Aug 14, 2017 2:45 am

Re: [HELP] *.PAK (PK) archive

Post by amVspR »

BloodRaynare wrote:
amVspR wrote:1720 hits for 504b0102
1719 hits for 504b0304


Okay, can you screenshot the contents of the few (not all) of those hits? (Double click on the results)

Here you go
BloodRaynare
Posts: 367
Joined: Fri Mar 10, 2017 7:23 am

Re: [HELP] *.PAK (PK) archive

Post by BloodRaynare »

amVspR wrote:Here you go


Okay, after checking again the cutted file you posted here, I kind of understand what's going on here. The DATA.PAK is not an one big zip file, but rather a collection of zip files combined into one. Does the DATA directory also has kind of index file that weighs smaller than the PAK file, like DATA.IDX or something?
amVspR
Posts: 40
Joined: Mon Aug 14, 2017 2:45 am

Re: [HELP] *.PAK (PK) archive

Post by amVspR »

BloodRaynare wrote:
amVspR wrote:Here you go


Okay, after checking again the cutted file you posted here, I kind of understand what's going on here. The DATA.PAK is not an one big zip file, but rather a collection of zip files combined into one. Does the DATA directory also has kind of index file that weighs smaller than the PAK file, like DATA.IDX or something?

The Voice.Pak has an IDX file, but Data.PAK doesn't.
I uploaded some relevant files: https://mega.nz/file/E5RS0Irb#IIrBmGR_b ... g3MJmGy7hE [Core.dat and the Debug folder]
BloodRaynare
Posts: 367
Joined: Fri Mar 10, 2017 7:23 am

Re: [HELP] *.PAK (PK) archive

Post by BloodRaynare »

After some checking, turns out the index file for DATA.PAK (DATA.IDX) was indeed inside the CORE.DAT_ file which were nest-zipped inside CORE.DAT (Use 7-zip to extract it). To obtain the DATA.IDX file we need to run this BMS script to extract the contents of CORE.DAT_ file (note the underscore, don't confuse it with the zip-renamed CORE.DAT):

gakuen_k_dat.bms

Code: Select all

IDString "DAT\x20"
get FILES long
for i = 0 < FILES
   getDstring NAME 0x20
   get SIZE long
   get OFFSET long
   log NAME OFFSET SIZE
next i


After that, you'll need to put the DATA.IDX on the same directory as the DATA.PAK file, then run this script:

gakuen_k_idx_pak.bms

Code: Select all

open FDDE IDX
open FDDE PAK 1

IDString "PAK\x20"
get FILES long
for i = 0 < FILES
   get UNK1 long # Hash?
   get OFFSET long
   get SIZE long
   string NAME p "%s." UNK1
   log NAME OFFSET SIZE 1
next i


These scripts on the above requires to be run with QuickBMS
amVspR
Posts: 40
Joined: Mon Aug 14, 2017 2:45 am

Re: [HELP] *.PAK (PK) archive

Post by amVspR »

BloodRaynare wrote:After some checking, turns out the index file for DATA.PAK (DATA.IDX) was indeed inside the CORE.DAT_ file which were nest-zipped inside CORE.DAT (Use 7-zip to extract it). To obtain the DATA.IDX file we need to run this BMS script to extract the contents of CORE.DAT_ file (note the underscore, don't confuse it with the zip-renamed CORE.DAT):

gakuen_k_dat.bms

Code: Select all

IDString "DAT\x20"
get FILES long
for i = 0 < FILES
   getDstring NAME 0x20
   get SIZE long
   get OFFSET long
   log NAME OFFSET SIZE
next i


After that, you'll need to put the DATA.IDX on the same directory as the DATA.PAK file, then run this script:

gakuen_k_idx_pak.bms

Code: Select all

open FDDE IDX
open FDDE PAK 1

IDString "PAK\x20"
get FILES long
for i = 0 < FILES
   get UNK1 long # Hash?
   get OFFSET long
   get SIZE long
   string NAME p "%s." UNK1
   log NAME OFFSET SIZE 1
next i


These scripts on the above requires to be run with QuickBMS

The scripts worked! Thank you so much!