Hitman 3 (2021) .RPKG

Extraction and unpacking of game archives and compression, encryption, obfuscation, decoding of unknown files
Den_krot
Posts: 2
Joined: Thu Jan 21, 2021 9:49 am

Hitman 3 (2021) .RPKG

Post by Den_krot »

Hello,
I want to extract\imports files from a new Hitman game. To localize the game to another language. The method with the last part is not suitable, could you help me?

Example of one of the files (https://goo.su/3vUX)

Sorry for my English

THX
Last edited by Den_krot on Thu Jan 21, 2021 2:00 pm, edited 1 time in total.
Zolodei
Posts: 36
Joined: Sat Sep 16, 2017 6:34 pm

Re: Hitman 3 (2021) .RPKG

Post by Zolodei »

KEY?
Den_krot
Posts: 2
Joined: Thu Jan 21, 2021 9:49 am

Re: Hitman 3 (2021) .RPKG

Post by Den_krot »

Fixed the link to the file, it led to the wrong place
(https://goo.su/3vUX)
Salem
Posts: 1
Joined: Thu Jan 21, 2021 7:34 pm

Re: Hitman 3 (2021) .RPKG

Post by Salem »

I would also appreciate it if someone would post a script for HITMAN 3, as I would like to extract the music.

The new magic number is "2KPR", compared to "GKPR" for the previous two Hitman games.
LinkOFF
Posts: 88
Joined: Thu Aug 11, 2016 6:52 pm

Re: Hitman 3 (2021) .RPKG

Post by LinkOFF »

del
Last edited by LinkOFF on Sat Jan 23, 2021 12:18 pm, edited 5 times in total.
DKDave
Posts: 136
Joined: Mon Nov 23, 2020 6:01 pm

Re: Hitman 3 (2021) .RPKG

Post by DKDave »

Just a quick correction from my own observations:

0x00 UInt - "2KPR"
0x04 UInt - version?
0x08 Threebyte - ?
0x0b Short - 0x7878
0x0d UInt - File count
0x11 UInt - Size of file table 1
0x15 UInt - Size of file table 2

File table 1 starts at 0x19 (0x14 bytes per entry)
File table 2 starts at 0xd2b9 (variable entry size)
Data starts at 0x2e669

For file table 1, each entry is as follows:

0x00 UInt64 - Checksum ?
0x08 UInt - File offset
0x0c UInt - always 0 (maybe uncompressed size for any compressed data)
0x10 UInt - File size (some values have bit 31 set)

File table 2 seems to be info about the file types - same number of entries as in table 1, but variable length.

The file data looks to be encrypted.
JesWhite
Posts: 47
Joined: Sun Jun 02, 2019 10:40 pm

Re: Hitman 3 (2021) .RPKG

Post by JesWhite »

Up...
hida1995
Posts: 3
Joined: Sun Sep 13, 2020 7:34 am

Re: Hitman 3 (2021) .RPKG

Post by hida1995 »

uppp
LennardF1989
Posts: 5
Joined: Fri May 20, 2016 3:05 pm

Re: Hitman 3 (2021) .RPKG

Post by LennardF1989 »

You know, bumping is just really annoying ;) It's not going to make things go faster.

Format is relatively simple, thanks to @DKDave for sparing me initial trouble ;) I'm just going to copy paste his format and extend it.

Header:
0x00 String - "2KPR"
Skip 9 bytes
0x0d UInt - File count
0x11 UInt - File table 1 size
0x15 UInt - File table 2 size

File table 1 immediately follows, loop "File count" times, each entry has:
0x00 UInt64 - Hash (Needs hash to filename mapping)
0x08 UInt - File offset
Skip 4 bytes
0x10 UInt - File size (Bit 31 determines if encrypted, if Bit 31 is set, exclude it, eg. using bitshifting with & 0x3fffffff)

Assert current offset position is total header size + file table 1 size

File table 2 immediately follows, loop "File count" times, each entry has:
0x00 String - Filetype (in reverse, eg. NOSJ is JSON)
0x04 UInt - Additional number of bytes for entry (total size is 0x18 + this value)
Skip 4 bytes
0x0C UInt - Decompressed size
Skip x bytes - Where x = 0x18 + (Additional bytes) - 0x10 (current offset into entry)

Assert current offset position is total header size + file table 1 size + file table 2 size

Extraction:
Loop through all entries, use File offset and File size (adjusted if encrypted!) from File table 1, use File type for file-extension and decompressed size from File table 2.

Compression:
If file is encrypted, XOR the bytes with key [0xDC, 0x45, 0xA6, 0x9C, 0xD3, 0x72, 0x4C, 0xAB], then decompress with LZ4.

I have a program up and running for this, let me finalize that and get it on Github. Otherwise, someone else could make a QuickBMS script out of this. Don't want to spend time on creating one right now.

EDIT:
It's up, you can find the repository here: https://github.com/LennardF1989/HitmanExtractor
You can download the tool here: https://github.com/LennardF1989/HitmanE ... _1_0_0.zip

Be sure to read the README for instructions! To OP I think the bad news right now is that TEXT/LINE files are not extractable yet, there are still some holes in the fileformat. I attempted not trying to decompress them and take the "decompressed file size" as-is, but it didn't yield anything interesting. I'd have to look at the Hitman 2 format to see if there are some hints in there, but maybe someone else can fill in the blanks and make a Pull Request :)
LinkOFF
Posts: 88
Joined: Thu Aug 11, 2016 6:52 pm

Re: Hitman 3 (2021) .RPKG

Post by LinkOFF »

LennardF1989, excellent work!
JesWhite
Posts: 47
Joined: Sun Jun 02, 2019 10:40 pm

Re: Hitman 3 (2021) .RPKG

Post by JesWhite »

LinkOFF wrote:LennardF1989, excellent work!


Yea, i'm searching text localization files.
Waiting for quickbms script for extraction and import...
LinkOFF
Posts: 88
Joined: Thu Aug 11, 2016 6:52 pm

Re: Hitman 3 (2021) .RPKG

Post by LinkOFF »

chunk0.rpkg extraction log:

Code: Select all

Extraced 174925 files, skipped is 128347. LZ4 decompress errors: 100933


Due to the first incorrect LZ4 block, subsequent errors occur
LennardF1989
Posts: 5
Joined: Fri May 20, 2016 3:05 pm

Re: Hitman 3 (2021) .RPKG

Post by LennardF1989 »

@LinkOFF Is that the result of my tool or something of yours?

Either way, I fixed the extraction issue. My initial thought yesterday was right after all. I took MEWW files as a test now, and they extract fine with a proper header, so everything that skipped with the v1.0.0 should now properly extract. I'll push this when I can. Playing with a Hash-function for a bit.
LinkOFF
Posts: 88
Joined: Thu Aug 11, 2016 6:52 pm

Re: Hitman 3 (2021) .RPKG

Post by LinkOFF »

LennardF1989, your tool. I added the log by try-catch exception in LZ4 decode function. Rest chunks extracted without any errors.
DKDave
Posts: 136
Joined: Mon Nov 23, 2020 6:01 pm

Re: Hitman 3 (2021) .RPKG

Post by DKDave »

Good stuff!

I can see the "PRIM" files contain the 3d geometry - just an example from one I got something from:

Image
LennardF1989
Posts: 5
Joined: Fri May 20, 2016 3:05 pm

Re: Hitman 3 (2021) .RPKG

Post by LennardF1989 »

Just pushed v1.0.1, will update compiled version accordingly. This fixes the extraction of files that aren't compressed.

@LinkOFF: I didn't extract the FULL chunk yet, also due to sheer the number of files it would generate. If you can get me a bunch of failing offsets on that file, I can specifically investigate them :) Copy/paste of the log from v1.0.1 should give me enough information to find them in the table headers block.
LinkOFF
Posts: 88
Joined: Thu Aug 11, 2016 6:52 pm

Re: Hitman 3 (2021) .RPKG

Post by LinkOFF »

There is a lot of compressed data in extracted files. Log-file with offsets (lz4 decode exceptions).
chimera67
Posts: 1
Joined: Tue Feb 02, 2021 5:11 am

Re: Hitman 3 (2021) .RPKG

Post by chimera67 »

Hello everyone!
I really want to access this game's models and textures:

* Will it be possible in the near future to unpack the game archives into proper directories (or to generate a document with real descriptive filenames)? Which utility is best for extracting the game files?

* What is the main model and texture format for this game and which program (plus addon?) is best to load the extracted models?

-
The two unpacking tools I found are a bit confusing... it unpacked thousands of files, but if anyone could at least kindly answer my question about model format+previewing, it couldn't be too too awful previewing thousands of mystery models - oh but how do the textures correspond...... Does that directx ripping program work with this type of game at all then?

Thank you very much to anyone who can possibly provide some insight~