42pak-generator
A modern, open-source pak file manager for the Metin2 private server community
What is this?
42pak-generator replaces the legacy EIX/EPK archive format with a new
.VPK format featuring:
- AES-256-GCM encryption - per-file authenticated encryption with unique nonces
- LZ4 / Zstandard / Brotli compression - choose the algorithm that fits your needs
- BLAKE3 content hashing - cryptographic integrity verification for every file
- HMAC-SHA256 - archive-level tamper detection
- Single-file format - no more .eix + .epk pairs
- PBKDF2-SHA512 key derivation - 200,000 iterations, no more hardcoded keys
- Filename obfuscation - optional path mangling to prevent enumeration
It comes with both a
GUI (WebView2 desktop app with dark/light theme) and a full
CLI tool (
42pak-cli).
VPK vs EIX/EPK Comparison
| Feature | EIX/EPK (Legacy) | VPK (42pak) |
|---|
| Encryption | TEA / Panama / HybridCrypt | AES-256-GCM |
| Compression | LZO | LZ4 / Zstandard / Brotli |
| Integrity | CRC32 | BLAKE3 + HMAC-SHA256 |
| File format | Dual file (.eix + .epk) | Single file (.vpk) |
| Archive entries | 512 max | Unlimited |
| Filename length | 160 bytes | 512 bytes (UTF-8) |
| Key derivation | Hardcoded keys | PBKDF2-SHA512 (200k iterations) |
| Tamper detection | None | HMAC-SHA256 whole-archive |
Screenshots
Dark Theme
Light Theme
Features
GUI (Desktop App)
- Create VPK archives from directories with drag-and-drop
- Convert EIX/EPK to VPK (supports both 40250 and FliegeV3 variants)
- Browse, search, extract, and validate VPK archives
- Step-by-step creation wizard with real-time progress
- Dark and light themes
- Archive diff view (side-by-side comparison)
- Duplicate file detection across archives
CLI (42pak-cli)
Code:
42pak-cli pack <SOURCE_DIR> [--output <FILE>] [--compression <lz4|zstd|brotli|none>] [--level <N>] [--passphrase <PASS>]
42pak-cli unpack <ARCHIVE> <OUTPUT_DIR> [--passphrase <PASS>] [--filter <PATTERN>]
42pak-cli list <ARCHIVE> [--passphrase <PASS>] [--filter <PATTERN>] [--json]
42pak-cli info <ARCHIVE> [--passphrase <PASS>] [--json]
42pak-cli verify <ARCHIVE> [--passphrase <PASS>] [--filter <PATTERN>] [--json]
42pak-cli diff <ARCHIVE_A> <ARCHIVE_B> [--passphrase <PASS>] [--json]
42pak-cli migrate <LEGACY_ARCHIVE> [--output <FILE>] [--compression <TYPE>] [--passphrase <PASS>]
42pak-cli search <WORKSPACE_DIR> <FILENAME_OR_PATTERN>
42pak-cli check-duplicates <WORKSPACE_DIR> [--read-index]
42pak-cli watch <SOURCE_DIR> [--output <FILE>] [--debounce <MS>]
-
-q / --quiet suppresses all output except errors
-
--json outputs structured JSON for scripting
- Exit codes: 0 = success, 1 = error, 2 = integrity failure, 3 = wrong passphrase
Metin2 Client Integration
Drop-in C++ integration files are provided for two reference source trees:
- 40250 / ClientVS22 - targets the multi-cipher HybridCrypt architecture (Camellia, Twofish, XTEA)
- FliegeV3 - targets the simpler XTEA/LZ4 architecture
Each profile includes:
-
VpkLoader.h/cpp - drop-in CVpkPack class replacing CEterPack
-
VpkCrypto.h/cpp - standalone crypto module (AES-GCM, BLAKE3, PBKDF2)
-
EterPackManager_Vpk.h/cpp - patched manager with VPK + EPK fallback
-
INTEGRATION_GUIDE.md - step-by-step instructions
Integration is just 2 changes:
- Call
SetVpkPassphrase() before the registration loop
- Replace
RegisterPack() with RegisterPackAuto()
VPK and EPK coexist -
RegisterPackAuto checks for a
.vpk file first and falls back to
.eix/.epk if not found. You can convert packs incrementally.
Server integration is also included (optional
CVpkHandler for reading configs/protos from VPK).
VPK File Format
Single-file archive layout:
Code:
+-------------------------------------+
| VpkHeader (512 bytes, fixed) | Magic "42PK", version, entry count
+-------------------------------------+
| Data Block 0 (aligned to 4096) | Compressed + encrypted file data
+-------------------------------------+
| Data Block 1 (aligned to 4096) |
+-------------------------------------+
| ... |
+-------------------------------------+
| Entry Table (variable size) | If encrypted: AES-GCM wrapped
+-------------------------------------+
| HMAC-SHA256 (32 bytes) | Covers everything above
+-------------------------------------+
Encryption pipeline:
Original -> LZ4 Compress -> AES-256-GCM Encrypt -> Store
Key derivation:
PBKDF2-SHA512("42PK-v1:" + passphrase, salt, 100000 iter) -> 64 bytes
First 32 bytes = AES key, last 32 bytes = HMAC key.
Download & Build
Prerequisites
-
Hidden content
You need to react to this post in order to see this content.
- Windows 10 version 1809+
-
Hidden content
You need to react to this post in order to see this content.
(usually pre-installed)
Build from source
Code:
cd 42pak-generator
dotnet restore
dotnet build --configuration Release
Portable release
Code:
# CLI single-exe (~65 MB)
.\publish.ps1 -Target CLI
# GUI portable (~163 MB)
.\publish.ps1 -Target GUI
# Both + Inno Setup installer
.\publish.ps1 -Target All
Technologies
- Runtime: .NET 8.0 (C# 12)
- UI: WebView2 + WinForms
- Frontend: HTML5, CSS3, Vanilla JS
- Encryption: AES-256-GCM (System.Security.Cryptography)
- Key Derivation: PBKDF2-SHA512 (200,000 iterations)
- Hashing: BLAKE3
- Compression: LZ4, Zstandard, Brotli
- C++ Crypto: OpenSSL 1.1+
- Testing: xUnit (22 tests)
License
MIT License - free to use, modify, and distribute.
Source Code
Hidden content
You need to react to this post in order to see this content.
Contributions welcome! Open an issue or pull request on GitHub.