Git Product home page Git Product logo

repak's Introduction

repak

Library and CLI tool for working with Unreal Engine .pak files.

  • Supports reading and writing a wide range of versions
  • Easy to use API while providing low level control:
    • Only parses index initially and reads file data upon request
    • Can rewrite index in place to perform append or delete operations without rewriting entire pak

repak CLI

  • Sane handling of mount points: defaults to ../../../ but can be configured via flag
  • 2x faster unpacking over UnrealPak. As much as 30x faster has been observed (on Linux unpacked to ramdisk)
  • Unpacking is guarded against malicious pak that attempt to write to parent directories

cli

$ repak --help
Usage: repak [OPTIONS] <COMMAND>

Commands:
  info       Print .pak info
  list       List .pak files
  hash-list  List .pak files and the SHA256 of their contents. Useful for finding differences between paks
  unpack     Unpack .pak file
  pack       Pack directory into .pak file
  get        Reads a single file to stdout
  help       Print this message or the help of the given subcommand(s)

Options:
  -a, --aes-key <AES_KEY>  256 bit AES encryption key as base64 or hex string if the pak is encrypted
  -h, --help               Print help
  -V, --version            Print version

packing

$ find mod
mod
mod/assets
mod/assets/AssetA.uasset
mod/assets/AssetA.uexp

$ repak pack -v mod
packing assets/AssetA.uasset
packing assets/AssetA.uexp
Packed 4 files to mod.pak

$ repak list mod.pak
assets/AssetA.uasset
assets/AssetA.uexp

unpacking

$ repak --aes-key 0x12345678 unpack MyEncryptedGame.pak
Unpacked 12345 files to MyEncryptedGame from MyEncryptedGame.pak

compatibility

UE Version Version Version Feature Read Write
1 Initial
4.0-4.2 2 NoTimestamps ✔️ ✔️
4.3-4.15 3 CompressionEncryption ✔️ ✔️
4.16-4.19 4 IndexEncryption ✔️ ✔️
4.20 5 RelativeChunkOffsets ✔️ ✔️
6 DeleteRecords
4.21 7 EncryptionKeyGuid ✔️ ✔️
4.22 8A FNameBasedCompression ✔️ ✔️
4.23-4.24 8B FNameBasedCompression ✔️ ✔️
4.25 9 FrozenIndex ✔️ ✔️1
10 PathHashIndex
4.26-5.32 11 Fnv64BugFix ✔️ ✔️
Feature Read Write
Compression ✔️ 〰️3
Encrypted Index ✔️
Encrypted Data ✔️

Supports reading encrypted (both index and/or data) and compressed paks. Writing does not support compression or encryption yet.

notes

determinism

As far as I can tell, the index is not necessarily written deterministically by UnrealPak. repak uses BTreeMap in place of HashMap to deterministically write the index and happens to rewrite the test paks in the same order, but this more likely than not stops happening on larger pak files.

full directory index

UnrealPak includes a directory entry in the full directory index for all parent directories back to the pak root for a given file path regardless of whether those directories contain any files or just other directories. repak only includes directories that contain files. So far no functional differences have been observed as a result.

acknowledgements

  • unpak: original crate featuring read-only pak operations
  • rust-u4pak's README detailing the pak file layout
  • jieyouxu for serialization implementation of the significantly more complex V11 index

Footnotes

  1. Except for paks compressed using frozen index which has significant complexity and only existed for UE 4.25 anyway.

  2. As of writing. Later versions are likely supported but untested.

  3. Zlib, Gzip, and Zstd are supported. Not all compression algorithms are available in all games.

repak's People

Contributors

bananaturtlesandwich avatar giovannimounir avatar jieyouxu avatar trumank avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

repak's Issues

Unpack multiple at once

It would be nice if repak unpack supported providing multiple input .pak files. Then you'd be able to combine it with bash globs or wildcards on the Windows cmd.

Example

repak.exe unpack -aes-key abcdef --out outdir *.pak

Right now, you have to write a for-loop for games with loads of paks.

C# bindings

I just want to thank for these tools. Its working nicely and this is the best implementation of packing tool ever to be honest.

Are you also gonna support UE5 files ? Lastly could you please export the functions(unmanaged or managed) where i can utilize it in c# for example ?

decryption algorithm?

I am writing a tool for unreal pak, but I encountered a decryption problem.

The key for unreal pak is AES256 of aWlpaWlpaWlpaWlpaWlpaWlpaWlpaWlpaWlpaWlpaWk=

The string before encryption is foo-bar seven characters

The encrypted string is 6c cc cd c8 60 8c 80 or 6c cc cd c8 60 8c 80 ef 69 8c 99 e4 a4 9a d5 ad?

But I used openssl's aes-256-ecb (not sure which one to use?) to encrypt foo-bar, which is a fixed 16 characters, so the decryption also fails.

openssl_encrypt('foo-bar', 'aes-256-ecb', base64_decode('aWlpaWlpaWlpaWlpaWlpaWlpaWlpaWlpaWlpaWlpaWk='), OPENSSL_RAW_DATA);
// bbe8d48c0f5b9aca2e460ed3253a67e3

Does aes-256 have non-block encryption?

https://github.com/Xenira/ue4-pak-examples

  • pak/v9/test_encrypted_v9.pak

[Not Working] Not unpack dead by daylight (UE 5.2.1) pak files

repak.exe --aes-key 0x22B1639B548124925CF7B9CBAA09F9AC295FCF0324586D6B37EE1D42670B39B3 unpack pakchunk2-Windows.pak

Error:
trying version V11 failed: got 123, which is not a boolean
trying version V10 failed: got 123, which is not a boolean
trying version V9 failed: got 234, which is not a boolean
trying version V8B failed: got 123, which is not a boolean
trying version V8A failed: got 145, which is not a boolean
trying version V7 failed: found magic of 0x0 instead of 0x5a6f12e1
trying version V6 failed: found magic of 0x0 instead of 0x5a6f12e1
trying version V5 failed: found magic of 0x0 instead of 0x5a6f12e1
trying version V4 failed: found magic of 0x0 instead of 0x5a6f12e1
trying version V3 failed: found magic of 0x0 instead of 0x5a6f12e1
trying version V2 failed: found magic of 0x0 instead of 0x5a6f12e1
trying version V1 failed: found magic of 0x0 instead of 0x5a6f12e1
trying version V0 failed: found magic of 0x0 instead of 0x5a6f12e1
version unsupported or is encrypted (possibly missing --aes-key?)

ghostrunner 2 demo fails to parse

when trying to run any command on the ghostrunner 2 demo pak this comes up

C:\Program Files (x86)\Steam\steamapps\common\Ghostrunner 2 Demo\Ghostrunner2\Content\Paks>repak info Ghostrunner2-WindowsNoEditor.pak
Error:
trying version V11 failed: pak is encrypted but no key was provided
trying version V10 failed: used version PathHashIndex but pak is version Fnv64BugFix
trying version V9 failed: got 90, which is not a boolean
trying version V8B failed: used version FNameBasedCompression but pak is version Fnv64BugFix
trying version V8A failed: got 188, which is not a boolean
trying version V7 failed: found magic of 0x0 instead of 0x5a6f12e1
trying version V6 failed: found magic of 0x0 instead of 0x5a6f12e1
trying version V5 failed: found magic of 0x0 instead of 0x5a6f12e1
trying version V4 failed: found magic of 0x0 instead of 0x5a6f12e1
trying version V3 failed: found magic of 0x0 instead of 0x5a6f12e1
trying version V2 failed: found magic of 0x0 instead of 0x5a6f12e1
trying version V1 failed: found magic of 0x0 instead of 0x5a6f12e1
trying version V0 failed: found magic of 0x0 instead of 0x5a6f12e1
version unsupported or is encrypted (possibly missing --aes-key?)

the game is 4.27 so should be V11

Create debug summary command for easier troubleshooting

Often it is necessary to download a multi-gigabyte pak to troubleshoot problems that are often only in a few bytes in the index or footer. Creating a summary file that contains a few megabytes of the head and tail of the pak file should provide enough information to debug the majority of pak issues and would make sharing significantly easier.

repak.exe keeps closing when opening

like the title says Each time I try to open repak it completely closes not even a second after idk what to do rn can someone help and yes I have .net

Crate?

Any plans on putting this crates.io?
I get that there's no docs right now but putting it on crates should be much lower effort.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.