God of War script for unpacking .pak file

Extraction and unpacking of game archives and compression, encryption, obfuscation, decoding of unknown files
Kratos9999
Posts: 129
Joined: Mon Aug 22, 2016 10:30 am

God of War script for unpacking .pak file

Post by Kratos9999 »

Hi everyone, I need to help with an script for unpacking the PART1.PAK archive in god of war game (PS2 Version). I have found an script here in Zenhax, but the script extract only the WAD files. Someone can make for me an script for unpacking all files inside archive .pak? The link for download the game is this: http://www.emuparadise.mobi/Sony_Playst ... f_War_(USA)/150565
aluigi
Site Admin
Posts: 12984
Joined: Wed Jul 30, 2014 9:32 pm

Re: God of War script for unpacking .pak file

Post by aluigi »

7Gb? No way.
If that PART1.PAK is too big to upload then use the filecutter script and upload the 2 files it generates:
http://aluigi.org/bms/filecutter.bms
If PART1.PAK is bigger than 2Gb then set the MEGABYTES var in the filecutter script to 32.
Kratos9999
Posts: 129
Joined: Mon Aug 22, 2016 10:30 am

Re: God of War script for unpacking .pak file

Post by Kratos9999 »

Sorry aluigi, it is why my internet is slow, even to send the split file, the speed here is 412Kbps. It is impossible for me send this file, if I can post a link with the dvd5 version, less than 4gb, you can download and make the script for me?
AnonBaiter
Posts: 1125
Joined: Tue Feb 02, 2016 2:35 am

Re: God of War script for unpacking .pak file

Post by AnonBaiter »

The structure is really simple.

Code: Select all

# God of War (PS2)

open FDSE "GODOFWAR.TOC"
open FDSE "PART1.PAK" 1

get TOC_SIZE asize
math TOC_SIZE - 0xc
for CURR_OFF = 0 < TOC_SIZE
   savepos BASE_OFF
   putarray 0 i BASE_OFF
   getdstring NAME 0xc
   get DUPLICATE long
   get SIZE long
   get OFFSET long
   math OFFSET * 0x800
   log NAME OFFSET SIZE 1
   savepos CURR_OFF
next
Here is the .PAK sample.
This script needs to be improved though, because sometimes there would be incorrect offsets for each extracted file.
AnonBaiter
Posts: 1125
Joined: Tue Feb 02, 2016 2:35 am

Re: God of War script for unpacking .pak file

Post by AnonBaiter »

God of War 2 uses the same .TOC file, except the structure is different from the previous one.
I'll upload the .PAK/.TOC samples of that game once I'll get around to understanding their structure.
AnonBaiter
Posts: 1125
Joined: Tue Feb 02, 2016 2:35 am

Re: God of War script for unpacking .pak file

Post by AnonBaiter »

Okay, here are the .TOC/.PAK samples from God of War 2. Oh, and here's a script:

Code: Select all

# God of War 2 (PS2)

math LAST_PART_NUM = -1
open FDSE "GODOFWAR.TOC"

get FILES long
for i = 0 < FILES
   getdstring NAME 0x18
   if NAME == ""
        break
    endif
   get SIZE long
   get PART_NUM long
   get DUMMY long
   if PART_NUM == 3
      math PART_NUM == 1
   elif PART_NUM == 4
      math PART_NUM == 2
   elif PART_NUM == 5
      math PART_NUM == 1
   elif PART_NUM == 6
      math PART_NUM == 2
   elif PART_NUM == 7
      math PART_NUM == 1
   elif PART_NUM == 8
      math PART_NUM == 2
   elif PART_NUM == 10
      math PART_NUM == 2
   elif PART_NUM == 13
      math PART_NUM == 1
   elif PART_NUM == 14
      math PART_NUM == 2
   elif PART_NUM == 17
      math PART_NUM == 1
   elif PART_NUM == 18
      math PART_NUM == 2
   endif
   if PART_NUM != LAST_PART_NUM
        math LAST_PART_NUM = PART_NUM
        string TMP p "PART%d.PAK" PART_NUM
      open FDSE TMP 1
    endif
   putarray 0 i NAME
   putarray 1 i SIZE
next i
for i = 0 < FILES
   sortarray 0 1
   math ARCHIVE_NUM = 0
   math ARCHIVE_OFF = 0
   get ARCHIVE_SIZE asize 1
   getarray NAME 0 i
   getarray SIZE 1 i
   math TMP_OFF == OFFSET
   math OFFSET - ARCHIVE_OFF
   if OFFSET u>= ARCHIVE_SIZE
      math ARCHIVE_OFF + OFFSET
      get ARCHIVE_SIZE asize 1
      math OFFSET = 0
   endif
   savepos BASE_OFF
   get OFFSET long
   math OFFSET * 0x800
   log NAME OFFSET SIZE 1
next i
Last edited by AnonBaiter on Sun Dec 11, 2016 7:20 pm, edited 2 times in total.
aluigi
Site Admin
Posts: 12984
Joined: Wed Jul 30, 2014 9:32 pm

Re: God of War script for unpacking .pak file

Post by aluigi »

Kratos9999
Posts: 129
Joined: Mon Aug 22, 2016 10:30 am

Re: God of War script for unpacking .pak file

Post by Kratos9999 »

Aluigi, the link for the script is broken
AnonBaiter
Posts: 1125
Joined: Tue Feb 02, 2016 2:35 am

Re: God of War script for unpacking .pak file

Post by AnonBaiter »


"404

Page not found

Pagina non trovata


Check your link, probably you have an old link so go to my homepage http://aluigi.org
or to my mirror site http://mirror.aluigi.org

If you have doubts send me an e-mail
...and remember that nothing is removed from this site if doesn't exist a better solution,
so probably I have simply developed a new tool/patch/PoC with more features and a different name.

Note that you may see this page also if you have been filtered,
in which case try using another browser."
AAAAAAHAHAHAHAHAHA
aluigi
Site Admin
Posts: 12984
Joined: Wed Jul 30, 2014 9:32 pm

Re: God of War script for unpacking .pak file

Post by aluigi »

Very simple... I forgot to upload the file :D
Try now.
AnonBaiter
Posts: 1125
Joined: Tue Feb 02, 2016 2:35 am

Re: God of War script for unpacking .pak file

Post by AnonBaiter »

Well, I think that explains it!
AnonBaiter
Posts: 1125
Joined: Tue Feb 02, 2016 2:35 am

Re: God of War script for unpacking .pak file

Post by AnonBaiter »

EDIT: Actually, since the game disc partition uses two layers(this game being stored using DVD9 and all), one can assume that PART2.PAK is in the second layer of the disc itself since the rest of the files are on the first layer of the disc.

Therefore, I can say that fixing is not needed.
Last edited by AnonBaiter on Sun Dec 11, 2016 7:19 pm, edited 1 time in total.
AnonBaiter
Posts: 1125
Joined: Tue Feb 02, 2016 2:35 am

Re: God of War script for unpacking .pak file

Post by AnonBaiter »

God of War 2 script updated.

I've been able to think of a work-around that assigns "PART_NUM" numbers above 1 and 2(such as 3, 4, 5, 6, 7, 8, 10, 13, 14, 17 and 18) as... 1 and 2 respectively. And since there are only two big files(PART1.PAK and PART2.PAK), it doesn't make sense for the .TOC file to reference the above PART_NUM numbers since the .PAK files with those numbers don't exist on the disc.

It's still incomplete though(the referenced offsets for these files go way bigger than the archive itself, and so far I haven't thought of a fix for this), so here's hoping someone(and I mean anyone, not me) can pick up and finish my script.

The sample will be up soon or sometime, can't say when(PART1.PAK and PART2.PAK included). In the meantime, here's the report using the "-V -0" parameters.
Kratos9999
Posts: 129
Joined: Mon Aug 22, 2016 10:30 am

Re: God of War script for unpacking .pak file

Post by Kratos9999 »

Thank you very much Anon baiter and aluigi, the last script works perfectly here, both to extract and repack the PAK file. Now I have a new question; Where is the texts of menu and messages, the only suspect file is "SANITY.TXT", but this file has only 1Kb and don't have any text materials.
Someone know say me where is the texts of menu (needed for transalation of game)?
AnonBaiter
Posts: 1125
Joined: Tue Feb 02, 2016 2:35 am

Re: God of War script for unpacking .pak file

Post by AnonBaiter »

Kratos9999 wrote:Where is the texts of menu and messages, the only suspect file is "SANITY.TXT", but this file has only 1Kb and don't have any text materials.
The "SANITY.TXT" file is useless since it's just a developers' message and nothing else.
Kratos9999 wrote:Someone know say me where is the texts of menu (needed for transalation of game)?
I have no idea. My guess is that it could be in one of those .WAD files.
aluigi
Site Admin
Posts: 12984
Joined: Wed Jul 30, 2014 9:32 pm

Re: God of War script for unpacking .pak file

Post by aluigi »

@AnonBaiter
I know that it's a work-in-progress but the script for GOW2 you posted can't work.
There are 5 PART*.PAK in GOW2 and there are 0x12 parts specified in the TOC.

I already made various tests but all failed.
Anyway, I leave my work-in-progress here just in case someone will have more ideas in future (which means that it DOESN'T WORK SO DON'T TRY):

Code: Select all

math LAST_PART_NUM = -1
open FDSE "GODOFWAR.TOC"

get FILES long
xmath OFFSET_OFF "4 + (FILES * (0x18 + 4 + 4 +4))"
for i = 0 < FILES
    getdstring NAME 0x18
    get SIZE long
    get PART_NUM long   # max is 0x12
    get OFFSET_IDX long

    savepos TMP
    xmath TMP2 "OFFSET_OFF + (OFFSET_IDX * 4)"
    goto TMP2
    get OFFSET long
    goto TMP

    print "%PART_NUM%"
    #math TMP    = OFFSET
    #math OFFSET = SIZE
    #math SIZE   = TMP

    if PART_NUM != LAST_PART_NUM
        math LAST_PART_NUM = PART_NUM
        xmath TMP "((PART_NUM - 1) / 4) + 1"
        string TMP p "PART%d.PAK" TMP
        open FDSE TMP 1
    endif

    #xmath OFFSET "(((PART_NUM - 1) % 4) * 0x10000000) + OFFSET"

    log NAME OFFSET SIZE 1
next i
AnonBaiter
Posts: 1125
Joined: Tue Feb 02, 2016 2:35 am

Re: God of War script for unpacking .pak file

Post by AnonBaiter »

.
"There are 5 PART*.PAK in GOW2"
Wait a minute, what? How do you know about this? Perhaps your copy of the game is different from mine?
Anyways, let's go back to square one, and for the sake of clarity let's us state which version of the game we have because you just got me lost there: mine is the USA version, and it has 2 PART*.PAK files, each with 3,97GB size. Yours?
aluigi
Site Admin
Posts: 12984
Joined: Wed Jul 30, 2014 9:32 pm

Re: God of War script for unpacking .pak file

Post by aluigi »

I have nothing.
I simply searched on Google while I tried to understand the format and there were references to 5 parts.
Considererd the PART2.PAK you missed in GOW1, my doubt had sense.
AnonBaiter
Posts: 1125
Joined: Tue Feb 02, 2016 2:35 am

Re: God of War script for unpacking .pak file

Post by AnonBaiter »

.
"I simply searched on Google while I tried to understand the format and there were references to 5 parts."
They could very well be taking about the European/Australian version of the game, but as you said there are 0x12 parts specified in the TOC. They could exist depending on the region the game was released on.

"Considererd the PART2.PAK you missed in GOW1, my doubt had sense."
I didn't realize IsoBuster couldn't read the second layer of the disc(unless I wasn't aware about some method to make the program read DVD9 ISO files), so I had to make IsoBuster find for "missing files and folders". But when I used vgmtoolbox for extracting the DVD9 ISO of GOW2(USA version), that realization came in because vgmtoolbox could read the second layer of the disc. Hence my stupidity.

Anyway, I personally think this thread is a bit out-of-topic right now.
And as you always like to say, "time is limited" so I don't think it's wise to waste it on arguments over PART*.PAK files. So let's just leave this as it is for now.
Kratos9999
Posts: 129
Joined: Mon Aug 22, 2016 10:30 am

Re: God of War script for unpacking .pak file

Post by Kratos9999 »

Aluigi, if you wish continue to search the .pak files in gow, this program extracts the second layer of ISO