javascript-obfuscator / javascript-obfuscator

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

0.14.0 plans #153

Closed sanex3339 closed 6 years ago

sanex3339 commented 6 years ago
sanex3339 commented 6 years ago

Just wrote transformer for object keys:

// input
(function(){
    if (true) {
        if (true) {
            var foo = {
                foo: 'abc',
                bar: {
                    baz: 'def',
                    'bax': 'bitcoin'
                },
                bark: 'hawl',
                'inner': {
                    'inner1': {
                        inner2: {
                            inner3: 'inner_value'
                        }
                    }
                }
            };
        }
    }

    console.log(foo);
})();

// output
var _0xbff3 = [
    'foo',
    'abc',
    'bar',
    'bark',
    'hawl',
    'inner',
    'inner1',
    'inner2',
    'inner3',
    'inner_value',
    'baz',
    'def',
    'bax',
    'bitcoin',
    'log'
];
var _0x56e7 = function (_0x134adc, _0x1eb28b) {
    _0x134adc = _0x134adc - 0x0;
    var _0x4608a8 = _0xbff3[_0x134adc];
    return _0x4608a8;
};
(function () {
    if (!![]) {
        if (!![]) {
            var _0x240e3f = {};
            _0x240e3f[_0x56e7('0x0')] = _0x56e7('0x1');
            _0x240e3f[_0x56e7('0x2')] = {};
            _0x240e3f[_0x56e7('0x3')] = _0x56e7('0x4');
            _0x240e3f[_0x56e7('0x5')] = {};
            _0x240e3f[_0x56e7('0x5')][_0x56e7('0x6')] = {};
            _0x240e3f[_0x56e7('0x5')][_0x56e7('0x6')][_0x56e7('0x7')] = {};
            _0x240e3f[_0x56e7('0x5')][_0x56e7('0x6')][_0x56e7('0x7')][_0x56e7('0x8')] = _0x56e7('0x9');
            _0x240e3f[_0x56e7('0x2')][_0x56e7('0xa')] = _0x56e7('0xb');
            _0x240e3f[_0x56e7('0x2')][_0x56e7('0xc')] = _0x56e7('0xd');
        }
    }
    console[_0x56e7('0xe')](_0x240e3f);
}());
sanex3339 commented 6 years ago

I'll put this under transformObjectKeys option that will disabled by default.

sanex3339 commented 6 years ago

or transformObjects? What better?

slig commented 6 years ago

I'd go with the first option transformObjectKeys. In my opinion it's clearer what it does.

sanex3339 commented 6 years ago

This PR will cover object keys obfuscation: https://github.com/javascript-obfuscator/javascript-obfuscator/pull/165

Transformer: https://github.com/javascript-obfuscator/javascript-obfuscator/pull/165/files#diff-41e5b71765008f5cfe8987f0c3b1c577

Still need some work like tests and refactoring

sanex3339 commented 6 years ago

I cutoff improved self defending from this milestone, because PR with object keys obfuscation is huge.

sanex3339 commented 6 years ago

Added obfuscation of eval expressions to this milestone. https://github.com/javascript-obfuscator/javascript-obfuscator/issues/168

sanex3339 commented 6 years ago

I had to add two additional transformation passes over AST-tree - separate converting pass (before it was combined with obfuscation pass) and finalizing pass. So, obfuscation will about 25% slower than in 0.13.0 version (because of two additional AST-tree traverses), but this additional passes will allow to made some complex transformations like eval expressions transformation.

sanex3339 commented 6 years ago

javascript-obfuscator@0.14.0-beta.2 was published to npm. Please, test it in your projects.

sanex3339 commented 6 years ago

I'll publish new beta version later today.

sanex3339 commented 6 years ago

javascript-obfuscator@0.14.0-beta.3 was published to npm

sanex3339 commented 6 years ago

Anybody tested new features? Everything is ok?

sanex3339 commented 6 years ago

out in javascript-obfuscator@0.14.0