javascript-obfuscator / javascript-obfuscator

A powerful obfuscator for JavaScript and Node.js
https://obfuscator.io
BSD 2-Clause "Simplified" License
13.91k stars 1.53k forks source link

Obfuscator with matrices #995

Open pedroamarques opened 3 years ago

pedroamarques commented 3 years ago

Hello, first of all I'd like to thank your work producing a really impressive javascript obfuscator, it really does make the code secure to be used. I was testing it with a personal project of mine and came across the following problem. This is a simple initializer for a structure of mine:

function ProductionTest(settings) {
        this.settings = settings;
        this.settings.sysCompErrors = [];
        this.settings.sysFilter = 0;
        this.settings.fltAlarm = '\''+ settings.alarmFilter +'\'';
        this.settings.exFilter = (settings.exFlt) ? true : false;
        this.settings.fltServ = 0;
        this.settings.fltUrg = '';
        this.settings.soundEnabled = false;
        this.settings.gridCount = 0;    
        this.settings.refreshTime = 3600000;
        this.settings.sessionId = setInterval(maintainSession, this.settings.refreshTime);
        this.data = {};
}

And this is the result after using the obfuscator.io website:

(function (_0x5347ef, _0xca228d) {
    var _0x145d59 = _0x43d6,
        _0x46fd36 = _0x5347ef();
    while (!![]) {
        try {
            var _0xfec297 =
                parseInt(_0x145d59(0x66)) / 0x1 +
                parseInt(_0x145d59(0x68)) / 0x2 +
                (parseInt(_0x145d59(0x6f)) / 0x3) * (-parseInt(_0x145d59(0x71)) / 0x4) +
                parseInt(_0x145d59(0x65)) / 0x5 +
                (parseInt(_0x145d59(0x6d)) / 0x6) * (-parseInt(_0x145d59(0x74)) / 0x7) +
                parseInt(_0x145d59(0x67)) / 0x8 +
                (-parseInt(_0x145d59(0x77)) / 0x9) * (parseInt(_0x145d59(0x64)) / 0xa);
            if (_0xfec297 === _0xca228d) break;
            else _0x46fd36["push"](_0x46fd36["shift"]());
        } catch (_0x7ddd16) {
            _0x46fd36["push"](_0x46fd36["shift"]());
        }
    }
})(_0x30bf, 0x8ebf6);
function _0x30bf() {
    var _0x55805f = [
        "4947448PGkECQ",
        "944382UcZTnp",
        "fltServ",
        "sysFilter",
        "exFlt",
        "settings",
        "6gnnzlW",
        "exFilter",
        "12453ugsmBn",
        "fltUrg",
        "204DtXHIi",
        "fltAlarm",
        "refreshTime",
        "6267653IXQiTB",
        "sessionId",
        "data",
        "9svFYlK",
        "gridCount",
        "4698350usAfCM",
        "2204350uXqSDe",
        "630117PydieB",
    ];
    _0x30bf = function () {
        return _0x55805f;
    };
    return _0x30bf();
}
function _0x43d6(_0x1bcbb3, _0x3cc825) {
    var _0x30bf6b = _0x30bf();
    return (
        (_0x43d6 = function (_0x43d6ea, _0x389645) {
            _0x43d6ea = _0x43d6ea - 0x64;
            var _0x2e3ffc = _0x30bf6b[_0x43d6ea];
            return _0x2e3ffc;
        }),
        _0x43d6(_0x1bcbb3, _0x3cc825)
    );
}
function ProductionTest(_0x195780) {
    var _0x50a854 = _0x43d6;
    (this[_0x50a854(0x6c)] = _0x195780),
        (this[_0x50a854(0x6c)]["sysCompErrors"] = []),
        (this["settings"][_0x50a854(0x6a)] = 0x0),
        (this[_0x50a854(0x6c)][_0x50a854(0x72)] = "\x27" + _0x195780["alarmFilter"] + "\x27"),
        (this[_0x50a854(0x6c)][_0x50a854(0x6e)] = _0x195780[_0x50a854(0x6b)] ? !![] : ![]),
        (this[_0x50a854(0x6c)][_0x50a854(0x69)] = 0x0),
        (this[_0x50a854(0x6c)][_0x50a854(0x70)] = ""),
        (this[_0x50a854(0x6c)]["soundEnabled"] = ![]),
        (this[_0x50a854(0x6c)][_0x50a854(0x78)] = 0x0),
        (this[_0x50a854(0x6c)][_0x50a854(0x73)] = 0x36ee80),
        (this["settings"][_0x50a854(0x75)] = setInterval(maintainSession, this[_0x50a854(0x6c)][_0x50a854(0x73)])),
        (this[_0x50a854(0x76)] = {});
}

As can be seen, sometimes the obfuscator does not substitute the array index "settings" for "_0x50a854(0x6c)", which then breaks the code, affirming that this["settings"] does not exist.

sanex3339 commented 3 years ago

Hello. How it breaks your code? I mean, _0x50a854(0x6c) returns 'settings' string, so these two lines should work in the same way:

this[_0x50a854(0x6c)][_0x50a854(0x6a)] = 0x0
this["settings"][_0x50a854(0x6a)] = 0x0