1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

[RPGM] decompressor script for SRD_DataCompressor.js

Discussion in 'Tools & Tutorials' started by the66, May 8, 2018.

  1. the66

    the66 beware, the germans are coming Donor

    1,131
    1,159
    Jan 27, 2017
    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

    Please Log in / Register to view this link

    ,

    Please Log in / Register to view this link

    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
     

    Attached Files:

    N7, Maim Lain and bossapplesauce like this.
  2. Tdius

    Tdius New Member

    2
    0
    Feb 20, 2018
    not work clothes shop close
     
  3. the66

    the66 beware, the germans are coming Donor

    1,131
    1,159
    Jan 27, 2017
    the script doesn't fix errors, it just enables you to access the formerly compressed data files :rolleyes:
     
  4. Maim Lain

    Maim Lain Member

    84
    52
    Apr 4, 2018
    Thanks for making this! I'm trying to get it to work with

    Please Log in / Register to view this link

    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. :)

    Please Log in / Register to view this link



    Edit:

    Please Log in / Register to view this link

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

    Please Log in / Register to view this link

    :/

    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 = "";
     
  5. the66

    the66 beware, the germans are coming Donor

    1,131
    1,159
    Jan 27, 2017
    my script worked absolutely fine here
    Code:
    Searching encryption key
    Key 3a76fa9709ca6c0f6d4c9847df430287 found in rpg_core.js
    Injecting encryption key into system.json
    Done
    
     
  6. Maim Lain

    Maim Lain Member

    84
    52
    Apr 4, 2018
    Maybe I'm an idiot. How exactly did you run/execute your script? I think that's what I'm doing wrong.
     
  7. the66

    the66 beware, the germans are coming Donor

    1,131
    1,159
    Jan 27, 2017
    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 :))
     
  8. Maim Lain

    Maim Lain Member

    84
    52
    Apr 4, 2018
    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

    Please Log in / Register to view this link

    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?
     
  9. the66

    the66 beware, the germans are coming Donor

    1,131
    1,159
    Jan 27, 2017
    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
     
  10. Maim Lain

    Maim Lain Member

    84
    52
    Apr 4, 2018
    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. :/
     
  11. the66

    the66 beware, the germans are coming Donor

    1,131
    1,159
    Jan 27, 2017
    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? :)
     
  12. Maim Lain

    Maim Lain Member

    84
    52
    Apr 4, 2018
    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. =/
     
  13. the66

    the66 beware, the germans are coming Donor

    1,131
    1,159
    Jan 27, 2017
    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
     
  14. Maim Lain

    Maim Lain Member

    84
    52
    Apr 4, 2018
    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.

    Please Log in / Register to view this link


    Please Log in / Register to view this link

    (click preview to run)
     
Loading...