Go Back   FileForums > Game Backup > PC Games > PC Games - CD/DVD Conversions > Conversion Tutorials

Reply
 
Thread Tools Search this Thread Display Modes
  #1  
Old 22-04-2025, 17:47
teusma teusma is offline
Registered User
 
Join Date: Oct 2017
Location: Brazil
Posts: 30
Thanks: 24
Thanked 5 Times in 3 Posts
teusma is on a distinguished road
Help me with encrypted data.pak file

I wanted to repack the game Car Jacker Hotwired and Gone but the data.pak file is encrypted - so files like .ogg .wav .dds do not compress efficiently with msc, oggre...

I can extract the files with quickbms but this script cannot reconstruct them back. I wanted someone to help me make a tool that decrypts and encrypts (CLI) this file.

Looking online I found a website (https://habr.com/ru/articles/689354/) where someone explains how to do this but I didn't understand anything. If anyone can help me I would really appreciate it. I really want to compress this data.

interesting topic about this file: https://web.archive.org/web/20220309...p=69458#p69458

the AI ​​claude told me that it is possible, using the quickbms script, to create a program in c++ (CLI) that has the function of decrypting and encrypting the data.pak file. but I don't understand anything about programming . so please, someone who understands programming do this for me, I beg you. Hahaha it was dramatic. it's serious!!! please!


I will leave the file for analysis:
Attached Files
File Type: 7z game+Quickbms+sript.7z (97.90 MB, 15 views)

Last edited by teusma; 23-04-2025 at 01:20.
Reply With Quote
Sponsored Links
  #2  
Old 23-04-2025, 08:56
KaktoR's Avatar
KaktoR KaktoR is offline
Lame User
 
Join Date: Jan 2012
Location: From outer space
Posts: 4,485
Thanks: 1,083
Thanked 7,101 Times in 2,694 Posts
KaktoR is on a distinguished road
Use quickbms reimport
Code:
quickbms_4gb_files -w -r "en_gine_pak_CarJacker - Hotwired and Gone.bms" "data.pak" "data.pak_extract"
Edit: Try this. Make backup of game folder somewhere. Copy contents to (backup) game dir and follow instructions (read BAT/TXT file names)
Attached Files
File Type: 7z test.7z (4.58 MB, 6 views)
__________________
Haters gonna hate

Last edited by KaktoR; 23-04-2025 at 09:32.
Reply With Quote
  #3  
Old 23-04-2025, 19:26
teusma teusma is offline
Registered User
 
Join Date: Oct 2017
Location: Brazil
Posts: 30
Thanks: 24
Thanked 5 Times in 3 Posts
teusma is on a distinguished road
this doesn't help, because I will have to keep the data.pak plus the extracted files.
Reply With Quote
  #4  
Old 23-04-2025, 22:33
KaktoR's Avatar
KaktoR KaktoR is offline
Lame User
 
Join Date: Jan 2012
Location: From outer space
Posts: 4,485
Thanks: 1,083
Thanked 7,101 Times in 2,694 Posts
KaktoR is on a distinguished road
You keep data.pak, but it's empty except for something in the file footer which is required by the script to reimport the files properly so the data.pak file is crc perfect after second reimport.
__________________
Haters gonna hate
Reply With Quote
  #5  
Old 24-04-2025, 00:52
teusma teusma is offline
Registered User
 
Join Date: Oct 2017
Location: Brazil
Posts: 30
Thanks: 24
Thanked 5 Times in 3 Posts
teusma is on a distinguished road
Are you saying that the data.pak is empty after executing "01_unpack.bat" because if so... I'm running it and it's still not getting empty...
Reply With Quote
  #6  
Old 24-04-2025, 02:04
KaktoR's Avatar
KaktoR KaktoR is offline
Lame User
 
Join Date: Jan 2012
Location: From outer space
Posts: 4,485
Thanks: 1,083
Thanked 7,101 Times in 2,694 Posts
KaktoR is on a distinguished road
  1. Unpack data.pak with "01_unpack.bat"
  2. Compress extracted data ("data.pak_extracted" folder) with your tools
  3. Zero extracted data ("data.pak_extracted" folder) with "03_zeroing_extracted_files.bat"
  4. Reimport zero'd extracted data with "04_reimport_zerod_files.bat"
  5. Compress zero'd data.pak with your compressor (ratio is 1% or less because the data.pak file is empty at this point)
  6. Install the game with your installer (or extract archive files otherwise). After this point the extracted data ("data.pak_extracted" folder) is now like the original files again
  7. Reimport extractred data with "07_reimport_extracted_files.bat"

Look at the data.pak before and after reimport zero'd files.

Original


Reimported zero'd files


If you compress the modified data.pak with 7z or any other compressor, ratio is extrem low (compressed data.pak from 91MB to 25KB).
__________________
Haters gonna hate

Last edited by KaktoR; 24-04-2025 at 02:08.
Reply With Quote
The Following User Says Thank You to KaktoR For This Useful Post:
teusma (24-04-2025)
  #7  
Old 24-04-2025, 02:37
teusma teusma is offline
Registered User
 
Join Date: Oct 2017
Location: Brazil
Posts: 30
Thanks: 24
Thanked 5 Times in 3 Posts
teusma is on a distinguished road
It took me a while but I understood haha, thanks. the only downside is that the quickbms executable is 19.3 MB and compressed 3.79 MB, this will overshadow almost all the gain I will have by decrypting the data.pak. But do what you know...that's life. If someone could create a C++ program from this BMS script, the executable would not exceed 100kb....
Reply With Quote
  #8  
Old 24-04-2025, 08:29
L33THAK0R's Avatar
L33THAK0R L33THAK0R is offline
Registered User
 
Join Date: Feb 2021
Location: Saudi Arabia
Posts: 369
Thanks: 129
Thanked 74 Times in 47 Posts
L33THAK0R is on a distinguished road
Quote:
Originally Posted by teusma View Post
It took me a while but I understood haha, thanks. the only downside is that the quickbms executable is 19.3 MB and compressed 3.79 MB, this will overshadow almost all the gain I will have by decrypting the data.pak. But do what you know...that's life. If someone could create a C++ program from this BMS script, the executable would not exceed 100kb....
I had a read through the article you linked and the concept is a lot simpler than you think. Based off of the authors "java-like pseudocode" I whipped up a couple python scripts that "decrypt" and "encrypt" the data.pak file. What is actually happening is basic obfuscation, for even bytes, the value is divided by 2, for odd bytes, 255 is added, and then the value is divided by 2. Very simple stuff.

Even though I've only ever dabbled in python scripting, writing a C++ application proved to be quite simple, here's the source code:

Code:
#include <fstream>
#include <vector>
#include <cstdint>
#include <iostream>

uint8_t reencrypt_byte(uint8_t d) {
    return (d < 128) ? (d * 2)
                     : static_cast<uint8_t>(2 * d - 255);
}

int main(int argc, char* argv[]) {
    if (argc != 3) {
        std::cerr << "Usage: reenc <infile> <outfile>\n";
        return 1;
    }

    // Read input file
    std::ifstream fin(argv[1], std::ios::binary);
    if (!fin) { perror("Error opening input"); return 1; }
    std::vector<uint8_t> buf((std::istreambuf_iterator<char>(fin)),
                              std::istreambuf_iterator<char>());

    // Transform in place
    for (auto &b : buf) {
        b = reencrypt_byte(b);
    }

    // Write output file
    std::ofstream fout(argv[2], std::ios::binary);
    if (!fout) { perror("Error opening output"); return 1; }
    fout.write(reinterpret_cast<char*>(buf.data()), buf.size());

    return 0;
}
I've saved you the trouble of compiling this, attached in the zip file are both the python scripts as well as the C++ source code and application, as well as a copy of sfk + a batch script for patching all the extracted streams (well 1116/1139 files, but all WAV, OGG were found. 651/663 DDS found.), if you choose to go down that route. Good news is this solution meets your requirements, with just srep+lolz the compiled C++ executable goes from 131KiB to 34.9KiB. Hope this helps, this was a good excuse to keep some technical skills fresh.
Attached Files
File Type: zip Solution_Resources.zip (1.13 MB, 6 views)

Last edited by L33THAK0R; 24-04-2025 at 08:34.
Reply With Quote
  #9  
Old 24-04-2025, 19:26
teusma teusma is offline
Registered User
 
Join Date: Oct 2017
Location: Brazil
Posts: 30
Thanks: 24
Thanked 5 Times in 3 Posts
teusma is on a distinguished road
Couldn't you (if it's not too much to ask) simply produce a tool that looks like this pak_enc_dec that can be put in a chain like this: -mpak_enc_dec+oggre+srep+msc+lolz.

To be honest, your program I don't understand how it works. and it also has a dependency on dlls - which is not a big problem since when compressed it drops from 1.50mb to 343kb...

Sorry if I'm being noob in any way.

Last edited by teusma; 24-04-2025 at 19:44.
Reply With Quote
  #10  
Old 25-04-2025, 03:09
L33THAK0R's Avatar
L33THAK0R L33THAK0R is offline
Registered User
 
Join Date: Feb 2021
Location: Saudi Arabia
Posts: 369
Thanks: 129
Thanked 74 Times in 47 Posts
L33THAK0R is on a distinguished road
Quote:
Originally Posted by teusma View Post
Couldn't you (if it's not too much to ask) simply produce a tool that looks like this pak_enc_dec that can be put in a chain like this: -mpak_enc_dec+oggre+srep+msc+lolz.

To be honest, your program I don't understand how it works. and it also has a dependency on dlls - which is not a big problem since when compressed it drops from 1.50mb to 343kb...

Sorry if I'm being noob in any way.
There shouldn't be a dependency on DLLs for the compiled executable. The usage is also plain to see when you run it from the command line. I'd advise running your own tests but I would think msc+oggre+lolz would be better suited, if you choose to not perform any post-install operations. Given how it would be a single command in a batch script to run the restoration for the data.pak I don't think any further development is warranted.
Reply With Quote
  #11  
Old 08-05-2025, 17:02
teusma teusma is offline
Registered User
 
Join Date: Oct 2017
Location: Brazil
Posts: 30
Thanks: 24
Thanked 5 Times in 3 Posts
teusma is on a distinguished road
forget it, I managed to create myself (with the help of AI) a tool(with only 29kb) that can be used like this: -mpak+oggre+srep+msc+lolz reaching all types
of files inside the data.pak already decrypted. this ambition I had to make this repack was more for sport - because it doesn't save much
space - due to the amount of .ogg and .wav being small, but even so it was a delight to compress after applying the decryption.

I'll leave the tool here for anyone who wants to use it too:
Attached Files
File Type: zip pak_decrypt.zip (14.0 KB, 0 views)

Last edited by teusma; 10-05-2025 at 18:14.
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Borderlands 2 GOTY omdj PC Games - CD/DVD Conversions 11 22-01-2021 08:22
Tom Clancy's Splinter Cell Conviction Faks PC Games - Protection List 3 03-06-2010 02:10
Having a nightmare with Iomega USB ZipCD - Help! Tranced CD/DVD-Writers 2 03-04-2005 06:00
PMA Update failure....????????? dannyk DVD Backup Forum 1 05-01-2005 14:19
HELP ME PLZ!!!! Dalvin DC Games 0 02-01-2001 22:15



All times are GMT -7. The time now is 19:45.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2025, vBulletin Solutions Inc.
FileForums @ https://fileforums.com