Looking for information about the file format used by Portal Knights.

Extraction and unpacking of game archives and compression, encryption, obfuscation, decoding of unknown files
RedRocket
Posts: 6
Joined: Sun Oct 30, 2016 9:23 am

Looking for information about the file format used by Portal Knights.

Post by RedRocket »

Hi I'm new here and this is my first post.

I want to look at the internals of a game called Portal Knights Steam Page

This game seems quite unique and I just found it. I would like to see how it functions.

The games executable loads a file called "gamebuild.zip" which contains game resource data.
The file can be extracted and [Renamed / Removed] and the game will load the loose files from the "gamebuild" directory.

Here is a sample screenshot of the file names etc.
Image

The game has license information for:
IJG Jpeg software license
LUA scripting license
PCRE regex license
SNAPPY google snappy compression license.

I'm a novice when it comes to reversing or looking into these things and would like someone with more knowledge to help me out. Please and Thank You.

Here are some things I have done.
The game has certain protection, that I have used public tools to remove, I have also "emulated" the ability to play this game online. (*I actually own this game)

I was hoping I could use freely available tools to try and dump some of these files, but I have not had success locating and using them.

Points of interest:
The license refer to google snappy compression, which I know nothing about.
The license also refer to LUA, which is of interest, because I'd love to dig into and modify the game logic, if I am able to.

TrID http://mark0.net/soft-tridnet-e.html
is giving information for some files, but since I'm unfamiliar with these things, I'd like some input from others, and to confirm.

Attached is a log file.
Once again thanks for anyone's time who cares to read, and have a good day.
aluigi
Site Admin
Posts: 12984
Joined: Wed Jul 30, 2014 9:32 pm

Re: Looking for information about the file format used by Portal Knights.

Post by aluigi »

You have to provide some of these files.
Upload the one of 22Mb, one of less than 1Mb and one of those small ones of 1Kb.
RedRocket
Posts: 6
Joined: Sun Oct 30, 2016 9:23 am

Re: Looking for information about the file format used by Portal Knights.

Post by RedRocket »

OK I wasn't quite sure if that was allowed, thank you a lot!

Also there are larger files. 30 of which equal 2.49 gigs They all have a size of 85.2 MB (89,391,160 bytes)
In total there are 16,194 files in this directory.

It seems the game was co-developed by keen http://www.keencore.com/

Had trouble trying to upload files to this site, so here they are.
22mb~ file : http://s000.tinyupload.com/index.php?file_id=00855849592924291854
<1mb file: http://s000.tinyupload.com/index.php?file_id=53614636695071222680
~1kb file: http://s000.tinyupload.com/index.php?file_id=01139790895108588500

Thank you again.
aluigi
Site Admin
Posts: 12984
Joined: Wed Jul 30, 2014 9:32 pm

Re: Looking for information about the file format used by Portal Knights.

Post by aluigi »

Apparently they are not archives and no encryption/obfuscation is used (362292c2fc56641df3b678240fbc049ed3e16837 is clearly readable with the hex editor).
The file 000c633e9cb90a8f2b36e55acaf9fab99ecb0c7a is big but doesn't have a format/structure.
Maybe try to upload one of those 85Mb files, I don't expect something different but it's worth to try.
RedRocket
Posts: 6
Joined: Sun Oct 30, 2016 9:23 am

Re: Looking for information about the file format used by Portal Knights.

Post by RedRocket »

Here is a link, https://ufile.io/5138

So It's looks like the only way to get the files would be to crack the game and have it dump them?

So I used Process Monitor to follow the read order, and the the contents of the first file read, after the resource.rip ->
'0000000000000000080000000000000000000000' I'm going to keep following and see what I can come up with. Since I'm not sure where to start haha.

I was looking into the game save files, and noticed that the saves are using SNPY, I am assuming that is google snappy compression. Maybe the game files also use this?

portal_knights.pksave https://ufile.io/c785
universe file https://ufile.io/7f013
island file https://ufile.io/6fb5
character save https://ufile.io/2c06
aluigi
Site Admin
Posts: 12984
Joined: Wed Jul 30, 2014 9:32 pm

Re: Looking for information about the file format used by Portal Knights.

Post by aluigi »

Just like the file of 22Mb, a senseless header of 32 bytes followed by a sequence of 32bit numbers without sense.
No archive and no real data to extract.
RedRocket
Posts: 6
Joined: Sun Oct 30, 2016 9:23 am

Re: Looking for information about the file format used by Portal Knights.

Post by RedRocket »

Is there anything I can provide you that might be helpful? If you are interested at all in continuing.
aluigi
Site Admin
Posts: 12984
Joined: Wed Jul 30, 2014 9:32 pm

Re: Looking for information about the file format used by Portal Knights.

Post by aluigi »

Personally I have no other ideas, when there is something to extract there is ever a way to do it but if there is nothing (like in this case except if someone finds something interesting with a hex editor) then I have no solutions.
RedRocket
Posts: 6
Joined: Sun Oct 30, 2016 9:23 am

Re: Looking for information about the file format used by Portal Knights.

Post by RedRocket »

Here is a file that seems interesting to me -> https://ufile.io/3bd17

From my very basic knowledge, it appears to be a form of a zip file?! I'm thinking it's multiple zips combined.

Which looks like it contains shader files. Outside of that I'm unsure.

Anyone have thoughts on this?

Also in regards to the files of this game Google Snappy is used somehow, but I'm not sure if it is the compression algorithm used for these files.
https://google.github.io/snappy/

If someone knows anything about snappy, or is willing to use their programming ability to see what they can come up with, it would be much appreciated.
aluigi
Site Admin
Posts: 12984
Joined: Wed Jul 30, 2014 9:32 pm

Re: Looking for information about the file format used by Portal Knights.

Post by aluigi »

That file is definitely useful but in a limited way.
It's an index containing the relative types and full names of these numeric files, you can search their names as sequence of bytes with a hex editor.
Once you have the names it doesn't change much because the format of the files is custom and you are still at the same problem.
This is the (slow) script that does the job by copying the files in the output folder with the new name:

Code: Select all

idstring "RIPF"
get DUMMY1 long
get DUMMY2 long
get DUMMY3 long
get FILES long
get DUMMY5 long
get DUMMY6 long
get DUMMY7 long
get DUMMY8 long
get DUMMY9 long
get DUMMY10 long
for i = 0 < FILES
    get DUMMY long
    getdstring TYPE 4
    get DUMMY long
    get DUMMY long
    getdstring HASH 20
    get DUMMY long
    get DUMMY long
    get DUMMY long
    get DUMMY long

    string HASH b HASH
    putvarchr HASH 40 0
    putarray 0 i HASH
    putarray 1 i TYPE
next i
findloc OFFSET string "recipe"
goto OFFSET
for i = 0 < FILES
    get NAME string
    getarray HASH 0 i
    getarray TYPE 1 i
    open FDSE HASH 1 EXISTS
    if EXISTS != 0
        string NAME p "%s/%s" TYPE NAME
        get SIZE asize 1
        log NAME 0 SIZE 1
    endif
next i
RedRocket
Posts: 6
Joined: Sun Oct 30, 2016 9:23 am

Re: Looking for information about the file format used by Portal Knights.

Post by RedRocket »

I really appreciate you looking into this for me, I'll post in another section the game executable and see if anyone can help me figure out the data structure of these files.