Tool RPGM Decompressor Script For SRD_DataCompressor.js

the66

beware, the germans are cumming
Modder
Respected User
Donor
Jan 27, 2017
7,551
23,372
i just created a little script to decompress the .json files created with the SRD_DataCompressor.js plugin for RPG Maker MV
it's pretty raw and checks for no errors at all
so back up any files, that might get destroyed

usage:
extract the archive and copy decompress.py to the www/data folder of the game with said plugin
you should have a folder called compressed within it
run the script (you need a working python 2.7 installation) and enjoy your uncompressed .json's
it's only tested with , and inserts there also the encryption key for the encrypted audio and image files to the right position

edit: script updated, wrong file name for enc_key was displayed
 

Maid Lain

Well-Known Member
Modder
Game Developer
Apr 4, 2018
1,888
16,215
Thanks for making this! I'm trying to get it to work with but I'm getting an error:
TypeError: cannot use a string pattern on a bytes-like object

Here's a link of just the data files if you'd like to take a look at it. :)


Edit:
worked for me. But I still can't get an encyrption key from the :/

rpg_core.js says this. very confusing that there is no key.
Code:
Decrypter.hasEncryptedImages = false;
Decrypter.hasEncryptedAudio = false;
Decrypter._requestImgFile = [];
Decrypter._headerlength = 16;
Decrypter._xhrOk = 400;
Decrypter._encryptionKey = "";
 

the66

beware, the germans are cumming
Modder
Respected User
Donor
Jan 27, 2017
7,551
23,372
Thanks for making this! I'm trying to get it to work with but I'm getting an error:
TypeError: cannot use a string pattern on a bytes-like object

Here's a link of just the data files if you'd like to take a look at it. :)


Edit:
worked for me. But I still can't get an encyrption key from the :/

rpg_core.js says this. very confusing that there is no key.
Code:
Decrypter.hasEncryptedImages = false;
Decrypter.hasEncryptedAudio = false;
Decrypter._requestImgFile = [];
Decrypter._headerlength = 16;
Decrypter._xhrOk = 400;
Decrypter._encryptionKey = "";
my script worked absolutely fine here
Code:
Searching encryption key
Key 3a76fa9709ca6c0f6d4c9847df430287 found in rpg_core.js
Injecting encryption key into system.json
Done
 

Maid Lain

Well-Known Member
Modder
Game Developer
Apr 4, 2018
1,888
16,215
my script worked absolutely fine here
Code:
Searching encryption key
Key 3a76fa9709ca6c0f6d4c9847df430287 found in rpg_core.js
Injecting encryption key into system.json
Done
Maybe I'm an idiot. How exactly did you run/execute your script? I think that's what I'm doing wrong.
 

the66

beware, the germans are cumming
Modder
Respected User
Donor
Jan 27, 2017
7,551
23,372
Maybe I'm an idiot. How exactly did you run/execute your script? I think that's what I'm doing wrong.
  1. have a working python 2.7 environment (i assume, you have)
  2. drop the script to the folder that contains the compressed folder (should be game root/www/data)
  3. run the script decompress.py or like you did with the .bat
now the compressed *.json from the folder compressed are beeing decompressed and copied to the the script folder
in step 2 system.json is scanned for the encryption key and if it's not found, the content of the js folder is scanned
if we have the key now, it's injected into system.json and you can use your preferred image/audio decryption tool
(if no key has been found, it's hidden somewhere else and i have to update my script :))
 

Maid Lain

Well-Known Member
Modder
Game Developer
Apr 4, 2018
1,888
16,215
  1. have a working python 2.7 environment
Oops. :coldsweat: I just assumed it was python 3. I swear more people use python 2 than 3 even though it's >current year. Thanks for the rest of the explanation though.

Could you tell me what you think of The javascript files in School of Lust are all like this, and with my limited knowledge I don't think it's actual encryption with a missing key, but just functions/loops/variables that are used to obfuscate the code (I could be wrong). You know of any simple way to make these readable?
 

the66

beware, the germans are cumming
Modder
Respected User
Donor
Jan 27, 2017
7,551
23,372
Oops. :coldsweat: I just assumed it was python 3. I swear more people use python 2 than 3 even though it's >current year. Thanks for the rest of the explanation though.

Could you tell me what you think of The javascript files in School of Lust are all like this, and with my limited knowledge I don't think it's actual encryption with a missing key, but just functions/loops/variables that are used to obfuscate the code (I could be wrong). You know of any simple way to make these readable?
i would reverse-engineer this function
Code:
function fyf(t)
    {
    var d=2633285;
    var w=t.length;
    var n=[];
    for(var v=0;v<w;v++)
        {
        n[v]=t.charAt(v)
        };
    for(var v=0;v<w;v++)
        {
        var y=d*(v+288)+(d%31111);
        var g=d*(v+229)+(d%52938);
        var s=y%w;
        var i=g%w;
        var u=n[s];
        n[s]=n[i];
        n[i]=u;
        d=(y+g)%2746409;
        };
    return n.join('')
    }
looks for me like rearranging a string
 

Maid Lain

Well-Known Member
Modder
Game Developer
Apr 4, 2018
1,888
16,215
i would reverse-engineer this function
looks for me like rearranging a string
Yeah that's what I thought, that the JS code is just held in variables and passed into functions that un-obfuscate it, but it looks like there's unique functions for each file.

Here's another one for example. It's pretty similar.
Code:
function()
{
var ycG='',mvz=11;
function xLp(r)
{
var y=2442126;
var h=r.length;
var p=[];
for(var j=0;j<h;j++)
{
p[j]=r.charAt(j)};
for(var j=0;j<h;j++)
{
var f=y*(j+252)+(y%17122);
var t=y*(j+196)+(y%53127);
var a=f%h;
var u=t%h;
var o=p[a];
p[a]=p[u];
p[u]=o;y=(f+t)%2489181;
};
return p.join('')
}
So I don't think there's a fast or easy way to 'decrypt' all the JS files. :/
 

the66

beware, the germans are cumming
Modder
Respected User
Donor
Jan 27, 2017
7,551
23,372
Yeah that's what I thought, that the JS code is just held in variables and passed into functions that un-obfuscate it, but it looks like there's unique functions for each file.

Here's another one for example. It's pretty similar.
Code:
function()
{
var ycG='',mvz=11;
function xLp(r)
{
var y=2442126;
var h=r.length;
var p=[];
for(var j=0;j<h;j++)
{
p[j]=r.charAt(j)};
for(var j=0;j<h;j++)
{
var f=y*(j+252)+(y%17122);
var t=y*(j+196)+(y%53127);
var a=f%h;
var u=t%h;
var o=p[a];
p[a]=p[u];
p[u]=o;y=(f+t)%2489181;
};
return p.join('')
}
So I don't think there's a fast or easy way to 'decrypt' all the JS files. :/
you might look for the code that creates these functions, it's probably in the plugin that isn't encrypted
but do you really have that strong need, to view the code of the js plugins? :)
 

Maid Lain

Well-Known Member
Modder
Game Developer
Apr 4, 2018
1,888
16,215
you might look for the code that creates these functions, it's probably in the plugin that isn't encrypted
but do you really have that strong need, to view the code of the js plugins? :)
I think the game dev wrote or used the code that creates the functions to obfuscate his plugins and I don't think it would have been included in the game.

And I need the code of the JS plugins because I can't create the incest patch for the game without changing a couple things in a few of the plugins. I've figured out how to do everything else needed to make the patch but this is the last thing that is preventing me from doing so. =/
 

the66

beware, the germans are cumming
Modder
Respected User
Donor
Jan 27, 2017
7,551
23,372
I think the game dev wrote or used the code that creates the functions to obfuscate his plugins and I don't think it would have been included in the game.

And I need the code of the JS plugins because I can't create the incest patch for the game without changing a couple things in a few of the plugins. I've figured out how to do everything else needed to make the patch but this is the last thing that is preventing me from doing so. =/
well, then write a script that..
  1. scans for *.js containing the crypt function
  2. open that file one by one
  1. scan for the different var values within the crypt function
  2. feed your own decrypter function with these and decrypt the data
  3. write the decrypted .js, crop the crypt function, exchange the encrypted data with your generated ones
 

Maid Lain

Well-Known Member
Modder
Game Developer
Apr 4, 2018
1,888
16,215
well, then write a script that..
  1. scans for *.js containing the crypt function
  2. open that file one by one
  1. scan for the different var values within the crypt function
  2. feed your own decrypter function with these and decrypt the data
  3. write the decrypted .js, crop the crypt function, exchange the encrypted data with your generated ones
I'm not sure if I know enough to be able to do all of that. I could probably write that script in pseudo-code but if I tried to do it for real it would probably take me forever lol.

I was messing around with the JS function and printed variables near the bottom and found you can print the decrypted code, but if you try substituting that code for the encrypted plugin it won't work. I think the game or one of the plugins relys on the code in the plugins being encrypted. Oh well, thanks for your help.


(click preview to run)
 

gue5t

Active Member
Sep 11, 2016
594
1,026
Clicking on preview doesn't decrypt the code correctly resulting in damaged plugins.js file.

[EDIT]
I'm attaching a manually fixed version that should work (with SRD_DataCompressor disabled)
 
  • Like
Reactions: Maid Lain

Maid Lain

Well-Known Member
Modder
Game Developer
Apr 4, 2018
1,888
16,215
Clicking on preview doesn't decrypt the code correctly resulting in damaged plugins.js file.

[EDIT]
I'm attaching a manually fixed version that should work (with SRD_DataCompressor disabled)
I just saw this now, this works with my patch changes, so I think you figured everything out. Thanks! What did you do differently to decrypt plugins.js? I knew something had to be wrong with mine because:

#1. Printing RJm(8512); did nothing, I only printed RJm
#2. Everything in my link was wrapped in a function which returned 6807, but that was weird and I didn't include that because I can't see how you would use that function for anything.
 

gue5t

Active Member
Sep 11, 2016
594
1,026
I didn't do anything to RE that - my java knowledge isn't good enough unfortunately :(
You had almost the whole thing except it had some characters escaped (like \u2500 instead of ) and some variables like <Ellye Title Text> missing (basically every text string between <> was missing) so I converted the characters and added the missing variables. I hope I haven't missed something.

P.S. If someone can find a way to decode his scripts it'll be better because it's a problem if we have to do this manually for each version.
 

Maid Lain

Well-Known Member
Modder
Game Developer
Apr 4, 2018
1,888
16,215
I didn't do anything to RE that - my java knowledge isn't good enough unfortunately :(
You had almost the whole thing except it had some characters escaped (like \u2500 instead of ) and some variables like <Ellye Title Text> missing (basically every text string between <> was missing) so I converted the characters and added the missing variables. I hope I haven't missed something.

P.S. If someone can find a way to decode his scripts it'll be better because it's a problem if we have to do this manually for each version.
Ah, in one of my previous comments to you in the SoL thread (I deleted it once I found out you had already fixed plugins.js) I mentioned that I found some UTF characters weren't translated, but I only caught ones that began with '\x' and didn't know there were others beginning '\u' that you found, and I didn't catch missing '<>' text either.

I think I understand the <> thing now. Since that specific online compiler is wrapping the output in an html doc, it thinks <> are html tags so whenever <> appears in the output if you inspect element on the output it treats it as a new element and omits the text in it. This link will include the <> text now.


I've tried looking online for a site that will convert any UTF codes inside a block of text to the normal characters but surprisingly can't find anything that works.. Also I think that it contains both UTF-8 characters and UTF-16 characters but I'm not 100% sure.

Thanks again btw for figuring that out.
 

the66

beware, the germans are cumming
Modder
Respected User
Donor
Jan 27, 2017
7,551
23,372
Ah, in one of my previous comments to you in the SoL thread (I deleted it once I found out you had already fixed plugins.js) I mentioned that I found some UTF characters weren't translated, but I only caught ones that began with '\x' and didn't know there were others beginning '\u' that you found, and I didn't catch missing '<>' text either.

I think I understand the <> thing now. Since that specific online compiler is wrapping the output in an html doc, it thinks <> are html tags so whenever <> appears in the output if you inspect element on the output it treats it as a new element and omits the text in it. This link will include the <> text now.


I've tried looking online for a site that will convert any UTF codes inside a block of text to the normal characters but surprisingly can't find anything that works.. Also I think that it contains both UTF-8 characters and UTF-16 characters but I'm not 100% sure.

Thanks again btw for figuring that out.
for your en/decoding, whatever needs
 

gue5t

Active Member
Sep 11, 2016
594
1,026
@Maim Lain, It seems I missed a few spaces on two lines, here's the fixed version.
@the66, I can't find a tool that converts \x0D to \r directly so I'm guessing it'll be a combination + it's much faster to do it by hand for so smaller a sample.