[PC] Lumines Remastered .bytes / .manifest.bytes archive encryption

Extraction and unpacking of game archives and compression, encryption, obfuscation, decoding of unknown files
mbc07
Posts: 12
Joined: Sun Oct 13, 2019 7:19 pm

[PC] Lumines Remastered .bytes / .manifest.bytes archive encryption

Post by mbc07 »

So, I'm trying to mod the skins from Lumines Puzzle & Music to work on the PC version of Lumines Remastered. I already figured out the compression details of Lumines Puzzle & Music (mostly CRI Middleware stuff) and successfully decompressed them, but I'm having a hard time with Lumines Remastered.

I know the game was made on Unity and already uncompressed the sharedassets*.assets files with common Unity unpackers, however nothing really relevant was there, as most of the game files seems to be stored in a custom format on the AssetBundles subfolder found inside StreamingAssets folder. All files on this subfolder have a .bytes extension and is accompanied by a smaller .manifest.bytes file which I think is the TOC, but I actually didn't manage to do anything with them. Perhaps I'm missing something?

I attached two pair of .bytes / .manifest.bytes on this post if it helps...
Last edited by mbc07 on Sun Nov 03, 2019 8:38 pm, edited 1 time in total.
mbc07
Posts: 12
Joined: Sun Oct 13, 2019 7:19 pm

Re: Lumines Remastered (PC) .bytes / .manifest.bytes archives

Post by mbc07 »

Okay, some news. Messing around with the .dll files of the game I discovered mentions of the following constants which I believe were used to encrypt the files. Tried to run some decryption tools with them but still got nowhere:

Code: Select all

AesInitVector = "kiadsjfgpomcjknorjgujksoifhjoasf";
AesKey = "nhbiotasihdughicopasxjlbcnvwaeuh";
BlockSize = 256;
KeySize = 256;
Last edited by mbc07 on Mon Oct 14, 2019 4:41 am, edited 1 time in total.
mbc07
Posts: 12
Joined: Sun Oct 13, 2019 7:19 pm

Re: Lumines Remastered (PC) .bytes / .manifest.bytes archives

Post by mbc07 »

With the help of ILSpy, I found the actual decryption algorithm used by the game and isolated it on a small C# console app that takes a file path from the first argument and decrypt the file to the same path with a "_dec" appended to the file name. The decrypted file then can be unpacked normally with any Unity extractor of your preference. This is the source code (I attached a pre-compiled binary for Windows on this post):

Code: Select all

using System.IO;
using System.Security.Cryptography;
using System.Text;

public class Program
{
    public static void Main(string[] args)
    {
        string path   = args[0];
        byte[] input  = File.ReadAllBytes(path);
        byte[] output = new byte[input.Length];

        byte[] key = Encoding.UTF8.GetBytes("nhbiotasihdughicopasxjlbcnvwaeuh");
        byte[] iv  = Encoding.UTF8.GetBytes("kiadsjfgpomcjknorjgujksoifhjoasf");

        RijndaelManaged rijndaelManaged = new RijndaelManaged();
        rijndaelManaged.Padding = PaddingMode.Zeros;
        rijndaelManaged.Mode = CipherMode.CBC;
        rijndaelManaged.KeySize = 256;
        rijndaelManaged.BlockSize = 256;

        ICryptoTransform transform = rijndaelManaged.CreateDecryptor(key, iv);
        MemoryStream stream = new MemoryStream(input);
        CryptoStream cryptoStream = new CryptoStream(stream, transform, CryptoStreamMode.Read);
        cryptoStream.Read(output, 0, output.Length);

        File.WriteAllBytes(path + "_dec", output);
    }
}


Could someone help me transform that into a QuickBMS script? I tried doing one based on the example "_aes.bms" script but the resulting output file isn't the actual decrypted content...
Last edited by mbc07 on Mon Oct 14, 2019 7:11 am, edited 1 time in total.
aluigi
Site Admin
Posts: 12984
Joined: Wed Jul 30, 2014 9:32 pm

Re: Lumines Remastered (PC) .bytes / .manifest.bytes archives

Post by aluigi »

The results are different using aes_256_cbc (even by switching iv and key since there you swapped them) so can't help.
mbc07
Posts: 12
Joined: Sun Oct 13, 2019 7:19 pm

Re: Lumines Remastered (PC) .bytes / .manifest.bytes archives

Post by mbc07 »

Whoops, indeed I switched them on the sample C# code above (just corrected that to avoid further confusion). QuickBMS is out of question then?
Ekey
Posts: 1383
Joined: Sat Aug 09, 2014 2:34 pm

Re: Lumines Remastered (PC) .bytes / .manifest.bytes archives

Post by Ekey »

The code that you provided is working fine. Here example decrypted manifest (skin001sound.manifest.bytes)

Code: Select all

ManifestFileVersion: 0
CRC: 3553356263
Hashes:
  AssetFileHash:
    serializedVersion: 2
    Hash: aa0ae0fcadd720fe5a91f4b7625028da
  TypeTreeHash:
    serializedVersion: 2
    Hash: c516f2a3b2b6b67ef759f6410a790acd
HashAppended: 0
ClassTypes:
- Class: 83
  Script: {instanceID: 0}
Assets:
- Assets/Resources/Audio/Skin001/se_lr.wav
- Assets/Resources/Audio/Skin001/shtr13.wav
- Assets/Resources/Audio/Skin001/se_dec_lp.wav
- Assets/Resources/Audio/Skin001/se_rrot.wav
- Assets/Resources/Audio/Skin001/shtr18.wav
- Assets/Resources/Audio/Skin001/shtr11.wav
- Assets/Resources/Audio/Skin001/shtr09.wav
- Assets/Resources/Audio/Skin001/shtr01v.wav
- Assets/Resources/Audio/Skin001/shtr07v10_01.wav
- Assets/Resources/Audio/Skin001/shse_dec1.wav
- Assets/Resources/Audio/Skin001/shtr03.wav
- Assets/Resources/Audio/Skin001/shtr30.wav
- Assets/Resources/Audio/Skin001/se_on.wav
- Assets/Resources/Audio/Skin001/shtr16v4.wav
- Assets/Resources/Audio/Skin001/shse_fall1.wav
- Assets/Resources/Audio/Skin001/shse_fall3.wav
- Assets/Resources/Audio/Skin001/shtr14.wav
- Assets/Resources/Audio/Skin001/shtr28v8.wav
- Assets/Resources/Audio/Skin001/se_dash.wav
- Assets/Resources/Audio/Skin001/shtr04.wav
- Assets/Resources/Audio/Skin001/shse_dec2.wav
- Assets/Resources/Audio/Skin001/shtr29.wav
- Assets/Resources/Audio/Skin001/shtr05.wav
- Assets/Resources/Audio/Skin001/shse_fall4.wav
- Assets/Resources/Audio/Skin001/shtr07v10.wav
- Assets/Resources/Audio/Skin001/shtr22.wav
- Assets/Resources/Audio/Skin001/se_lrot.wav
- Assets/Resources/Audio/Skin001/shtr24.wav
- Assets/Resources/Audio/Skin001/shtr08.wav
- Assets/Resources/Audio/Skin001/shtr21.wav
- Assets/Resources/Audio/Skin001/shtr27.wav
- Assets/Resources/Audio/Skin001/shtr20.wav
- Assets/Resources/Audio/Skin001/shtr02.wav
- Assets/Resources/Audio/Skin001/shtr26.wav
- Assets/Resources/Audio/Skin001/shtr06.wav
- Assets/Resources/Audio/Skin001/shtr12.wav
- Assets/Resources/Audio/Skin001/shse_fall2.wav
- Assets/Resources/Audio/Skin001/shtr15.wav
- Assets/Resources/Audio/Skin001/shtr10v8.wav
- Assets/Resources/Audio/Skin001/shse_bonus.wav
- Assets/Resources/Audio/Skin001/shtr31v.wav
- Assets/Resources/Audio/Skin001/shtr07v10_02.wav
- Assets/Resources/Audio/Skin001/shtr23.wav
- Assets/Resources/Audio/Skin001/shtr25v6.wav
- Assets/Resources/Audio/Skin001/shtr19.wav
Dependencies: []


Tool with code is attached. Usage as well simple:

Code: Select all

LRDecryptor <PATH_TO_FILE>


If you want to encrypt it back just change > CreateDecryptor to CreateEncryptor
mbc07
Posts: 12
Joined: Sun Oct 13, 2019 7:19 pm

Re: Lumines Remastered (PC) .bytes / .manifest.bytes archives

Post by mbc07 »

Ekey wrote:The code that you provided is working fine. [...]
Yes, I know, I tested it before posting here. What I wanted was to have that decryption working through a BMS script, to easily integrate with other BMS scripts I already have and to skip the need to recompile the program every time I change something in the script. However it seems out of reach as like aluigi said encryption aes_256_cbc function from QuickBMS doesn't decrypt the files correctly...
aluigi
Site Admin
Posts: 12984
Joined: Wed Jul 30, 2014 9:32 pm

Re: Lumines Remastered (PC) .bytes / .manifest.bytes archives

Post by aluigi »

Mcrypt can do the job, apparently the RijndaelManaged uses a block size of 256 bit instead of the 128 one used by openssl and most of the other libraries.

Code: Select all

get SIZE asize
encryption "mcrypt rijndael-256 cbc" "nhbiotasihdughicopasxjlbcnvwaeuh" "kiadsjfgpomcjknorjgujksoifhjoasf"
get NAME filename
string NAME + "_dec"
log NAME 0 SIZE
MexicanPB
Posts: 15
Joined: Tue Apr 07, 2020 5:44 am

Re: Lumines Remastered (PC) .bytes / .manifest.bytes archives

Post by MexicanPB »

Ekey wrote:The code that you provided is working fine. Here example decrypted manifest (skin001sound.manifest.bytes)

Code: Select all

ManifestFileVersion: 0
CRC: 3553356263
Hashes:
  AssetFileHash:
    serializedVersion: 2
    Hash: aa0ae0fcadd720fe5a91f4b7625028da
  TypeTreeHash:
    serializedVersion: 2
    Hash: c516f2a3b2b6b67ef759f6410a790acd
HashAppended: 0
ClassTypes:
- Class: 83
  Script: {instanceID: 0}
Assets:
- Assets/Resources/Audio/Skin001/se_lr.wav
- Assets/Resources/Audio/Skin001/shtr13.wav
- Assets/Resources/Audio/Skin001/se_dec_lp.wav
- Assets/Resources/Audio/Skin001/se_rrot.wav
- Assets/Resources/Audio/Skin001/shtr18.wav
- Assets/Resources/Audio/Skin001/shtr11.wav
- Assets/Resources/Audio/Skin001/shtr09.wav
- Assets/Resources/Audio/Skin001/shtr01v.wav
- Assets/Resources/Audio/Skin001/shtr07v10_01.wav
- Assets/Resources/Audio/Skin001/shse_dec1.wav
- Assets/Resources/Audio/Skin001/shtr03.wav
- Assets/Resources/Audio/Skin001/shtr30.wav
- Assets/Resources/Audio/Skin001/se_on.wav
- Assets/Resources/Audio/Skin001/shtr16v4.wav
- Assets/Resources/Audio/Skin001/shse_fall1.wav
- Assets/Resources/Audio/Skin001/shse_fall3.wav
- Assets/Resources/Audio/Skin001/shtr14.wav
- Assets/Resources/Audio/Skin001/shtr28v8.wav
- Assets/Resources/Audio/Skin001/se_dash.wav
- Assets/Resources/Audio/Skin001/shtr04.wav
- Assets/Resources/Audio/Skin001/shse_dec2.wav
- Assets/Resources/Audio/Skin001/shtr29.wav
- Assets/Resources/Audio/Skin001/shtr05.wav
- Assets/Resources/Audio/Skin001/shse_fall4.wav
- Assets/Resources/Audio/Skin001/shtr07v10.wav
- Assets/Resources/Audio/Skin001/shtr22.wav
- Assets/Resources/Audio/Skin001/se_lrot.wav
- Assets/Resources/Audio/Skin001/shtr24.wav
- Assets/Resources/Audio/Skin001/shtr08.wav
- Assets/Resources/Audio/Skin001/shtr21.wav
- Assets/Resources/Audio/Skin001/shtr27.wav
- Assets/Resources/Audio/Skin001/shtr20.wav
- Assets/Resources/Audio/Skin001/shtr02.wav
- Assets/Resources/Audio/Skin001/shtr26.wav
- Assets/Resources/Audio/Skin001/shtr06.wav
- Assets/Resources/Audio/Skin001/shtr12.wav
- Assets/Resources/Audio/Skin001/shse_fall2.wav
- Assets/Resources/Audio/Skin001/shtr15.wav
- Assets/Resources/Audio/Skin001/shtr10v8.wav
- Assets/Resources/Audio/Skin001/shse_bonus.wav
- Assets/Resources/Audio/Skin001/shtr31v.wav
- Assets/Resources/Audio/Skin001/shtr07v10_02.wav
- Assets/Resources/Audio/Skin001/shtr23.wav
- Assets/Resources/Audio/Skin001/shtr25v6.wav
- Assets/Resources/Audio/Skin001/shtr19.wav
Dependencies: []


Tool with code is attached. Usage as well simple:

Code: Select all

LRDecryptor <PATH_TO_FILE>


If you want to encrypt it back just change > CreateDecryptor to CreateEncryptor



Sorry for responding to this dead topic but do you know how to encrypt the file, I found the line in the source code and was able to change it to CreateEncryptor but it seems like the game isn't loading the file and instead results in a endless loading loop on start, did I do something wrong?
MexicanPB
Posts: 15
Joined: Tue Apr 07, 2020 5:44 am

Re: [PC] Lumines Remastered .bytes / .manifest.bytes archive encryption

Post by MexicanPB »

Bump: just wanted to see if someone could help :)
mbc07
Posts: 12
Joined: Sun Oct 13, 2019 7:19 pm

Re: [PC] Lumines Remastered .bytes / .manifest.bytes archive encryption

Post by mbc07 »

Sorry for the delay, I don't check this forum too often. I did a quick test (decrypting a file, then encrypting it back without changing anything) and the game booted just fine.

If it got stuck on the loading screen it probably didn't like whatever you've changed in the file, but I can confirm changing rijndaelManaged.CreateDecryptor to rijndaelManaged.CreateEncryptor in any of the two C# codes posted before is all that you need to encrypt the files back.

Did you try updating the manifest of the file you've changed? Every .bytes file has an accompanying .manifest.bytes file and it contains a checksum field, so you should update it too to match the checksum of the modded the .bytes file...
ExData7
Posts: 2
Joined: Mon Jul 05, 2021 3:33 am

Re: [PC] Lumines Remastered .bytes / .manifest.bytes archive encryption

Post by ExData7 »

mbc07 wrote:Sorry for the delay, I don't check this forum too often. I did a quick test (decrypting a file, then encrypting it back without changing anything) and the game booted just fine.

If it got stuck on the loading screen it probably didn't like whatever you've changed in the file, but I can confirm changing rijndaelManaged.CreateDecryptor to rijndaelManaged.CreateEncryptor in any of the two C# codes posted before is all that you need to encrypt the files back.

Did you try updating the manifest of the file you've changed? Every .bytes file has an accompanying .manifest.bytes file and it contains a checksum field, so you should update it too to match the checksum of the modded the .bytes file...


can you take a look at the .bytes file for SaGa Scarlet Grace on pc for me pls? I have no clue on how to get into that games .bytes files which i need for the story text.
mbc07
Posts: 12
Joined: Sun Oct 13, 2019 7:19 pm

Re: [PC] Lumines Remastered .bytes / .manifest.bytes archive encryption

Post by mbc07 »

I don't own that game, so no, I can't. Also keep in mind .bytes is a very generic extension, the .bytes files from Lumines Remastered is very unlikely to have anything in common...
MexicanPB
Posts: 15
Joined: Tue Apr 07, 2020 5:44 am

Re: [PC] Lumines Remastered .bytes / .manifest.bytes archive encryption

Post by MexicanPB »

Hello, I would like to revive this topic. I am trying to mod the .bytes files but the game refuses to load. I have no ideas why this is the case but what I do know is that the byte files are just encrypted Unity Assets files, but the game required the files to be encrypted. I tried the linked encrypter with zero success. Is anyone willing to look into a better tool for these .byte files and allow for reimport?