This game's got some pretty weird audio files. They've all got the .wma extension, but only some of them actually have a header and work. Here's one that works and here's one that doesn't. An automatic assumption is that it's the same format and simply missing a header, but if that's the case I don't know how to build the header.
OK, after looking at some RAM dumps and managing to extract a working version of the menu music, I've come to the conclusion that the files that don't work are probably compressed or obfuscated in some way. I would be really, really grateful if somebody was able to figure out what sort of compression is used!!
I've attached a zip containing the compressed file and the uncompressed file I extracted.
It's encryption with a 64bit block-cipher without using ivec, probably blowfish or *tea. You can see that at offset 0x1300 of both the files where there is a long sequence of zeroes in the RIFF file and 5 identical 8bytes patters in the other file.
Yes you need the key. You can check with signsrch if there are known encryption algorithms in the executable, it's useful if you want to debug/analyze the executable because it tells you where to search. If the game uses OpenSSL you will see tons of encryption algorithms... very confusing
Consider that sometimes it's also possible that the game uses a custom obfuscation but I don't think this is the case, other times games use customized encryption algorithms (like xtea with different constants and so on).
Signsrch 0.2.3 by Luigi Auriemma e-mail: aluigi@autistici.org web: aluigi.org optimized search function by Andrew http://www.team5150.com/~andrew/ disassembler engine by Oleh Yuschuk
- open file "BattleBlockTheater.exe" - 4026880 bytes allocated - load signatures - open file E:\Resource Ripping\Tools\Signsrch\signsrch.sig - 3069 signatures in the database - start 2 threads - start signatures scanning:
- 45 signatures found in the file in 8 seconds - done
Unfortunately I can't really make heads or tails of this, not sure what to do now. However it does look like we can conclude that the encryption is indeed Blowfish. It also seems to mention zlib, which is used for the BAF animation files.
Basically now it's a job for the debugger or the disassembler, but I guess you have no experience with this type of analysis. If you can upload the executable, Ekey or I may take a look at it.
I would like to know how to do these things myself, if you do figure it out then I would appreciate an explanation of how you did it. However if that is too complex then I understand
I tried the key "\x61\xf4\x4d\x75\x89\x4b\xbb\x2c\x71\x0f\x3b\xa4\xa9\x38\x56\x74\x12\x74\xa9\x99\xd2\xab\x0f\xc8\x99\x3a\x02\xd3" with both blowfish and bf_ecb (the endianess is changed automatically so no need of generating 2 keys) but without good results. Anyway it was just a quick check.
What does that mean? I've looked it up and I know that SHA is a hash algorithm and Mersenne Twister is a PRNG, but I don't understand what you mean by "check > 004100BA ->" or "> 0046AFB0"?
I would really like to decrypt these files if it's possible.
Someone figured it out and made a program to decrypt the files. Apparently it uses Mersenne Twister to generate a key, and then Blowfish for the decryption, or something along those lines. That's just the code, I have a compiled version here.
One important thing to note is that the encryption relies on the filename, and the program doesn't remove parent directories from the input path, so you need to use the program in the same folder as the file(s) you're converting. So for example this doesn't work:
Someone figured it out and made a program to decrypt the files. Apparently it uses Mersenne Twister to generate a key, and then Blowfish for the decryption, or something along those lines. That's just the code, I have a compiled version here.
One important thing to note is that the encryption relies on the filename, and the program doesn't remove parent directories from the input path, so you need to use the program in the same folder as the file(s) you're converting. So for example this doesn't work:
Ah right, sorry about that. They are actually listenable in Audacity, but yeah most players have issues with them. I forgot to mention that you need to convert them using xWMAEncode, which you can download here. You can use it convert files to .wav (this is also needed for any other .wma files from the game, even those that weren't initially encrypted). Here's the syntax:
This will convert to uncompressed .wav. You can also use the batch script I've included to convert all the .wma files in the same directory as the .exe, and put them in a subfolder.
I don't know what I did wrong, I rename gameplay_1.wma to 1.wma, then use PowerShell to type .\decrypt 1.wma 2.wma
I found that the generated 2.wma was 16 bytes smaller than 1.wma. Finally, I used PowerShell to input .\xWMAEncode 2.wma 3.wav, but no file was generated
Just prompt in the PowerShell window:
ERROR: Input file type is neither PCM nor xWMA
Converting 2.wma to 3.wav failed with error E_INVALIDARG (Invalid arguments)
And when I import 2.wma into Audacity, it prompts that the copyright issue cannot be played
If anyone else sees this post I'd like some help, thanks a lot!
puggsoy wrote:Ah right, sorry about that. They are actually listenable in Audacity, but yeah most players have issues with them. I forgot to mention that you need to convert them using xWMAEncode, which you can download here. You can use it convert files to .wav (this is also needed for any other .wma files from the game, even those that weren't initially encrypted). Here's the syntax:
This will convert to uncompressed .wav. You can also use the batch script I've included to convert all the .wma files in the same directory as the .exe, and put them in a subfolder.
Someone figured it out and made a program to decrypt the files. Apparently it uses Mersenne Twister to generate a key, and then Blowfish for the decryption, or something along those lines. That's just the code, I have a compiled version here.
One important thing to note is that the encryption relies on the filename, and the program doesn't remove parent directories from the input path, so you need to use the program in the same folder as the file(s) you're converting. So for example this doesn't work: