Skip to content

Tatsh/bfcodec

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

156 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

bfcodec

C++ GitHub tag (with filter) License GitHub commits since latest release (by SemVer including pre-releases) Dependabot GitHub Pages Stargazers pre-commit CMake Prettier Tests Coverage Status

@Tatsh Buy Me A Coffee Libera.Chat Mastodon Follow Patreon

Tools and a C/C++ library to manipulate BFCodec-encrypted content.

How to use

jbt

jbt encrypts a directory of game data then zips it up. The extension depends on the target game. You must use the correct key to encrypt the data.

jbt -K 'the game key' game-data/ game-data.jbt

unjbt

Like unzip, unjbt extracts the zip file then decrypts each game file. Conversions will happen if tools are in PATH:

Input Format Output Format Tool Used
Binary Property List (plist) XML Property List libplist (if found at configure time), CoreFoundation (macOS)
CgBI PNG PNG pngcrush, pngdefry

pngdefry can be downloaded from its official site (archived). pngcrush is only available on macOS if you have Xcode installed.

unjbt -d game-data game-data.jbt

If the directory passed to -d/--extract-to does not exist it will be created.

bfc

bfc encrypts a single file in place, overwriting it with the encrypted data. The same key and IV must be supplied to decrypt it again with unbfc.

bfc -K 'the game key' game-file

Pass -o/--output to write to a different path instead of overwriting the input. With --backup, an existing destination is first copied to <dest>.bak.

Pass --uuid instead of -K to derive the key from a device UUID. The key is the MD5 of the UUID's canonical uppercase form, so dashes and letter case are optional.

unbfc

unbfc reverses bfc. It decrypts a file in place, overwriting it with the decrypted data. The key and IV must match those used to encrypt the file.

unbfc -K 'the game key' game-file

Pass -o/--output to write to a different path instead of overwriting the input. With --backup, an existing destination is first copied to <dest>.bak.

Some iOS games key files to a per-device UUID (for example mulist and prodlist). Pass that UUID with --uuid; the key is the MD5 of its canonical uppercase form, so dashes and letter case are optional:

unbfc --uuid 1ac4f2e0-9b3d-4c77-ae51-2d9f8c0a77b1 mulist

C interface

// If using a DLL on Windows:
// #ifdef _WIN32
// #define BFCODEC_USE_DLL 1
// #endif
#include <bfcodec.h>

void func() {
  C_BLOWFISH *blf = bfcodec_init();
  const uint8_t my_key = {};
  const uint8_t iv[8] = {};
  bfcodec_expand_key(blf, &my_key, 16);
  bfcodec_decrypt(blf, in_out_data, data_len, my_iv);
  // or
  bfcodec_encrypt(blf, in_out_data, data_len, my_iv);
}

Link with -lbfcodec.

C++ interface

// If using a DLL on Windows:
// #ifdef _WIN32
// #define BFCODEC_USE_DLL 1
// #endif
#include <bfcodecpp.h>

void func() {
  auto bfc = BFCodec::create();
  bfc.expandKey({ /* key here */});
  bfc.decrypt(inOutData, {/* IV here */});
  // or
  bfc.encrypt(inOutData, {/* IV here */})
}

Link with -lbfcodec.

Building from source

Requirements:

  • CMake
  • On Linux (for tools): OpenSSL
  • Optional: libplist on non-macOS

Basic commands to build after cloning:

mkdir build
cd build
cmake ..
make

jbt and unjbt will be in the tools directory.

About

Tools and a C/C++ library to manipulate BFCodec-encrypted content.

Topics

Resources

License

Contributing

Security policy

Stars

Watchers

Forks

Contributors