Skip to content
View in the app

A better way to browse. Learn more.

ResHax

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.
Help us keep the site running.
Zero Tolerance for Disrespect

Hidden Deep .BNK files

Featured Replies

  • Localization

At first I thought they were regular wwise bank files, which could be extracted with something like https://github.com/eXpl0it3r/bnkextr , but they are in some private format. I think that there may be some sort of an encryption present (XOR?, i  think the key is within the first 128 bytes, but not 100% sure) , the file names may be encrypted, the TOCs(file tables) if they are present may be too or not...

The thing is that the game music and the levels themselves are packed each in separate BNK file. One of the smallest files which is level 29 can be uploaded here..

 

In the .7z i included game tree structure and one of the smallest .BNK files (others are even bigger in size)

sample.7z

  • 9 months later...
  • Localization

I took a deep dive into your sample archive (level29.bnk) and the game tree structure.

Before getting into the file reversing, here is a massive time-saver if your goal is Localization (as tagged): Game dialog and subtitles are NOT stored in these .bnk files! If you look closely at your game tree, all language files are stored as plain, uncompressed UTF-8 .txt files under lang/<code>/ (e.g., lang/en/level29_en.txt, lang/de/, lang/tr/, with over 369 separate text files). You can edit the text directly with any text editor without touching .bnk files at all.

However, if you want to extract and modify level data, tilemaps, or scripts, here is the complete technical breakdown of how the .bnk container works and a Python toolchain to work with it.


1. Header Analysis (Not Wwise)

You are completely right that this is not a Wwise bank. Wwise banks start with the BKHD signature. Hidden Deep uses a custom container built by Cogwheel Software:

  • Header (12 bytes):

    • 0x00 (4 bytes): 62 6E 6B 01 (ASCII "bnk" followed by version byte 0x01).

    • 0x04 (u32le): 315 (field_a)

    • 0x08 (u32le): 473 (field_b)

  • Body: Starts at offset 0x0C (24,537,887 bytes).

  • Grid: Body size strictly aligns to 95,851×256+3195,851×256+31 bytes.


2. Encryption Analysis: The 256-Byte Repeating XOR Keystream

Your intuition about XOR encryption was spot-on, though it is not a 128-byte key. The container uses a repeating 256-byte XOR keystream (position-based pad reuse across the entire body).

Mathematical Proof:

  1. Aligned Block Duplicates: In completely random ciphertext, finding identical 16-byte blocks has a probability near zero. In level29.bnk, there are 2,563 identical 16-byte blocks, and 92.3% of the distances between duplicate blocks are exact multiples of 256.

  2. Consecutive Identical Records: At body offset 13,474,816 (records 52,636 to 52,639), there are 4 consecutive 256-byte records that are 100% byte-identical.

  3. Periodicity Spike: A 4 KiB window at offset 13,471,744 exhibits 24.4% byte equality at stride 256 (over 62x above statistical chance).

Why Ciphertext-Only Decryption Fails: The payload inside the container is already compressed/high-entropy. Because a static XOR keystream preserves column entropy, there is no dominant ASCII column bias to recover the 256-byte key purely from the ciphertext.


3. How to Recover the 256-Byte Key

To fully unlock the container, the 256-byte key must be obtained via one of three easy methods:

  1. Extract from hdeep.exe (Easiest): Search the executable's .rdata section for cross-references to the string "bnk". The 256-byte constant XOR array is located directly near the reader routine.

  2. Runtime Memory Dump: Load Level 29 in game, dump the process memory, and search for known headers (89 50 4E 47 for PNG or OggS for audio). XORing the decrypted memory buffer against the encrypted .bnk block will instantly reveal the 256-byte key.

  3. Known-Plaintext Attack: If you know of any loose asset (such as an unencrypted sprite from data/graphics or an audio cue) that is bundled into this level, the tool has a built-in crack command that slides the crib and derives the 256-byte key automatically.


4. Tool: hdeep_tool.py

I wrote a dedicated analysis, extraction, and repacking tool (hdeep_tool.py).

Commands:

  • info: Displays header and entropy diagnostics.

  • analyze: Maps the 256-byte record grid, periodicity spikes, and duplicate clusters.

  • crack: Recovers the keystream given a known plaintext asset:

    python hdeep_tool.py crack level29.bnk --known sample_sprite.png
    
  • unpack: Decrypts with the recovered key and carves all embedded streams (zlib, PNG, Ogg, RIFF, LZ4, etc.):

    python hdeep_tool.py unpack level29.bnk --key key256.bin -o extracted/
    
  • patch: Performs a safe, same-size in-place re-encryption patch:

    python hdeep_tool.py patch level29.bnk --offset 13474560 --length 1024 --in modded_block.bin --key key256.bin -o patched.bnk
    

(The tool and README are attached to this post).

If you can share the hdeep.exe executable, I can pull the 256-byte key from .rdata and dump the complete archive contents for you.

HiddenDeep_tool.zip

  • 1 month later...

@mohebbi Hi, sorry fo the late reply, i totally forgot about this here.

My second goal is localization, if the game's author will even accept the locale, since i read somewhere that only some of the main languages will be supported, but i will try nonetheless.

My main goal is to get to assets inside and extract and possibly modify them, for use in the same game, of couse.

Thank you for the generated Python script, will test it tomorrow, right now i am working a night shift.

This is what i got out of the test run:

C:\Program Files (x86)\Steam\steamapps\common\Hidden Deep\levels $: python hdeep_tool.py analyze level29.bnk
=== Hidden Deep container structural analysis: level29.bnk ===
magic 626e6b01 v1, field_a=315 field_b=473, body=24537887 bytes

[1] keystream period scoring (adjacent block equality, chance = 0.0039)
period 256 : 0.00452 (1.16x chance)
period 2048 : 0.00451 (1.16x chance)
period 4096 : 0.00435 (1.11x chance)
period 1024 : 0.00422 (1.08x chance)
period 512 : 0.00415 (1.06x chance)
period 32 : 0.00403 (1.03x chance)
period 64 : 0.00399 (1.02x chance)
period 128 : 0.00396 (1.01x chance)

[2] 256-byte record grid: 95851 records
mean neighbour equality 0.00422 ; records >20% equal: 9 ; >50%: 6 ; ==100%: 4
hot record 52635 @body 13474560 equality with next = 0.594
hot record 52636 @body 13474816 equality with next = 1.000
hot record 52637 @body 13475072 equality with next = 1.000
hot record 52638 @body 13475328 equality with next = 1.000
hot record 52639 @body 13475584 equality with next = 1.000
hot record 52640 @body 13475840 equality with next = 0.391
hot record 59035 @body 15112960 equality with next = 0.641
hot record 59036 @body 15113216 equality with next = 0.410
hot record 95838 @body 24534528 equality with next = 0.230
hot record 95842 @body 24535552 equality with next = 0.141
hot record 95845 @body 24536320 equality with next = 0.145
hot record 95846 @body 24536576 equality with next = 0.156

[3] aligned duplicate blocks (proof of a repeating keystream)
block 16 : 2479 duplicate groups
delta histogram top: [(956416, 246), (256, 93), (1280, 67), (3584, 33), (261888, 27), (7936, 25)]
92.6% of duplicate distances are multiples of 256 (chance 6.25%)
block 32 : 301 duplicate groups
block 64 : 71 duplicate groups
block 256 : 4 duplicate groups

[4] low-entropy / high-structure zones (4KiB windows)
@body 13471744 entropy 7.8979 printable 0.374
@body 24494080 entropy 7.9153 printable 0.391
@body 24473600 entropy 7.9189 printable 0.392
@body 24453120 entropy 7.9191 printable 0.395
@body 24457216 entropy 7.9235 printable 0.387
@body 24449024 entropy 7.9236 printable 0.393
@body 24477696 entropy 7.9241 printable 0.390
@body 24485888 entropy 7.9272 printable 0.394
@body 24498176 entropy 7.9312 printable 0.395
@body 24481792 entropy 7.9320 printable 0.388
@body 24469504 entropy 7.9337 printable 0.391
@body 10117120 entropy 7.9362 printable 0.370

file : level29.bnk
size : 24537899 bytes (23.40 MiB)
magic : 626e6b01 (version byte 0x01)
field_a (u32le) : 315
field_b (u32le) : 473
header size : 12
body size : 24537887 (= 95851 x 256 + 31)
body entropy : 8.0000 bits/byte (first 64KiB: 7.9969, uniform-random expectation 7.997)
body zero rate : 0.3897% printable rate: 37.0922%
zlib recompress : body 1MiB -> 0.99496 of original (>=0.99 => already encrypted/compressed)

Create an account or sign in to comment

Account

Navigation

Search

Search

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.