Astral Chain package

Extraction and unpacking of game archives and compression, encryption, obfuscation, decoding of unknown files
Demonslayerx8
Posts: 23
Joined: Thu Sep 14, 2017 12:02 am

Astral Chain package

Post by Demonslayerx8 »

I've got the container pretty much all figured out, but I have 0 clue on how to make a script, so I've uploaded some samples from the game for anyone to make a BMS script for

0x00 - magic [pkzl]
0x04 - unk
0x08 - package size
0x10 - files in package
0x14 - table offset location
0x18 - length of filename table

table:
-Filename Location (at ZStandard)
-Decompressed Size [this can be skipped]
-Offset location of said compressed file
-Compressed file length


No need to extract files to their decompressed files since it's all zstandard/zstd compression, I can just decompress them via smash ultimate tools, which is what I did for the model, when I was extracting files 1 at a time without proper filenames.
Image
yham
Posts: 9
Joined: Wed Aug 28, 2019 1:41 pm

Re: Astral Chain package

Post by yham »

I want to extract text file. But I'm noob...I'm waiting for completion of BMS script or another tool.
Demonslayerx8
Posts: 23
Joined: Thu Sep 14, 2017 12:02 am

Re: Astral Chain package

Post by Demonslayerx8 »

yham wrote:I want to extract text file. But I'm noob...I'm waiting for completion of BMS script or another tool.

the text file has 90 compressed files within it, and also compressed with zstd.
yham
Posts: 9
Joined: Wed Aug 28, 2019 1:41 pm

Re: Astral Chain package

Post by yham »

Demonslayerx8 wrote:
yham wrote:I want to extract text file. But I'm noob...I'm waiting for completion of BMS script or another tool.

the text file has 90 compressed files within it, and also compressed with zstd.

Thank you for advice. But I am realy noob. I can only search or double-click. XD
And I can wait patiently.
masagrator
Posts: 82
Joined: Sat Dec 22, 2018 10:03 am

Re: Astral Chain package

Post by masagrator »

My first script. I can't get it to work with names, so for now temporary solution. It's decompressing files.

Code: Select all

comtype zstd
idstring "pkzl"
get UNKN long
get archiveSize longlong
get filecount long
get TABLE_OFFSET long
get NAME_TABLE long
set NAME ""
GoTo TABLE_OFFSET
for x = 0 < filecount
    get NAME_OFFSET longlong
   GET SIZE longlong
   GET OFFSET longlong
   GET ZSIZE longlong
    clog NAME OFFSET ZSIZE SIZE
   set NAME ""
next x


and here is for files with idstring "DAT" - also without correct filenames

Code: Select all

idstring "\x44\x41\x54\x00"
get filecount long
get TABLE_OFFSET long
GET FILE_FORMAT_TABLE long
GET FILENAMES_OFFSET long
set NAME ""
GoTo TABLE_OFFSET
get SIZE_LAST_FILE asize
for x = 1 < filecount
   get offset long
   get size long
   math size - offset
   log NAME offset size
   set NAME ""
   math TABLE_OFFSET + 4
   GOTO TABLE_OFFSET
next x
get offset long
math SIZE_LAST_FILE - offset
set NAME ""
log NAME offset SIZE_LAST_FILE
Demonslayerx8
Posts: 23
Joined: Thu Sep 14, 2017 12:02 am

Re: Astral Chain package

Post by Demonslayerx8 »

oh nice, wasn't expecting a decompress script to be made too, but rip filenames and extensions... :/

edit:
ok apparently it's not a name table.. just string names lol
yham
Posts: 9
Joined: Wed Aug 28, 2019 1:41 pm

Re: Astral Chain package

Post by yham »

I tested the script and some went well.
But Text.pkz became 90 .ptd files.
I tried decompress with ztsd but it didn't work...
masagrator
Posts: 82
Joined: Sat Dec 22, 2018 10:03 am

Re: Astral Chain package

Post by masagrator »

First script is only for pkz files.

I looked at PTD and table looks too complicated for me to understand what's going on.
File has three sections: table, unknown data (encrypted/compressed filenames?) and file data with some info before block. And they are twice, one after another.

I can only assume that beginning is

Code: Select all

magic "PTD\x00"
dummy longlong
textscount long
table_offset long
unknown long
data_offset long


Table contains 4 informations

Code: Select all

unknown long
unknown2 long
unknown3 long
unknown4 long


Only second looks like it's offset (it's jumping to offset which is summary of unknown2 + offset of unknown) to some unreadable data.
First one may be offset for RAM (though I don't know what is base offset to confirm it with exefs)

So this looks like it's not for unpacking, but this is proper file. So some tool needs to be done for reading it.

If someone want to look at it
(Here you have script for renaming to correct filenames for text.pkz files - https://pastebin.com/huqXr5rz
ui.pkz files - https://pastebin.com/hsPzKuJs )
Last edited by masagrator on Thu Aug 29, 2019 11:24 am, edited 1 time in total.
yham
Posts: 9
Joined: Wed Aug 28, 2019 1:41 pm

Re: Astral Chain package

Post by yham »

>need tools.
If we find text like hidden weapons or items, I think it's worth.
But if not easy...
Anyway, thank you for the script!
Demonslayerx8
Posts: 23
Joined: Thu Sep 14, 2017 12:02 am

Re: Astral Chain package

Post by Demonslayerx8 »

Someone over at Xentax made a proper script, so enjoy. It exports files with their proper names, and also decompresses the files also.

# Astral Chain . pkz extract
# By Dave, 2019

IDString "pkzl"

ComType ZSTD

Goto 0x10
Get ITEMS Long
Get FILE_ENTRY Long

XMath NAME_TABLE "FILE_ENTRY + (ITEMS * 0x20)"

For A = 1 to ITEMS

Goto FILE_ENTRY
Get NAME_OFFSET Long
Get JUNK Long
Get SIZE Long
Get JUNK Long
Get OFFSET Long
Get JUNK Long
Get ZSIZE Long
Math NAME_OFFSET + NAME_TABLE
Goto NAME_OFFSET
GetDSTring FILENAME 0x10

Clog FILENAME OFFSET ZSIZE SIZE
# Log FILENAME OFFSET ZSIZE # Use this line to get compressed output instead

Math FILE_ENTRY + 0x20

Next A
lisomn
Posts: 40
Joined: Thu Jan 11, 2018 7:14 am

Re: Astral Chain package

Post by lisomn »

masagrator wrote:First script is only for pkz files.

I looked at PTD and table looks too complicated for me to understand what's going on.
File has three sections: table, unknown data (encrypted/compressed filenames?) and file data with some info before block. And they are twice, one after another.

I can only assume that beginning is

Code: Select all

magic "PTD\x00"
dummy longlong
textscount long
table_offset long
unknown long
data_offset long


Table contains 4 informations

Code: Select all

unknown long
unknown2 long
unknown3 long
unknown4 long


Only second looks like it's offset (it's jumping to offset which is summary of unknown2 + offset of unknown) to some unreadable data.
First one may be offset for RAM (though I don't know what is base offset to confirm it with exefs)

So this looks like it's not for unpacking, but this is proper file. So some tool needs to be done for reading it.

If someone want to look at it
(Here you have script for renaming to correct filenames for text.pkz files - https://pastebin.com/huqXr5rz
ui.pkz files - https://pastebin.com/hsPzKuJs )

Table contains 4 informations

Code: Select all

unknown1 long
block_Offset long(Need add table_offset)
block_Original_size long
block_in_file_size long
Kerilk
Posts: 18
Joined: Sun Aug 27, 2017 1:21 pm

Re: Astral Chain package

Post by Kerilk »

I have looked a bit at astral chain text files (now that the Noesis plugin supports textures), here are some binary templates:
- for PTD files: https://github.com/Kerilk/bayonetta_too ... n%20ptd.bt
- for ktb font files: https://github.com/Kerilk/bayonetta_too ... n%20ktb.bt

ftb files are also used, they seem to determine glyphs position on the texture but I have yet to understand how it works.

From my point of view, the format is pretty similar to bayo 2 but without the name of the code points which made bayonetta/bayo 2 text format easy to read. See discussion here: https://github.com/Kerilk/bayonetta_tools/issues/4