Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

编译之后局部变量处理BUG #309

Closed
GENGSHUANGs opened this issue Aug 8, 2018 · 3 comments

Comments

Projects
None yet
2 participants
@GENGSHUANGs
Copy link

commented Aug 8, 2018

Example:

(function(r){
function r(){

}

r.prototype.getName = function(){
return 'zhangsan';
}

console.log(new r().getName());
})('this is a string');

It will output : "zhangsan"

and the obfuscator code is :

var _0x568b = [
    'bG9n',
    'dGhpcyBpcyBhIHN0cmluZw==',
    'cHJvdG90eXBl',
    'Z2V0TmFtZQ==',
    'emhhbmdzYW4='
];
(function (_0x2e872d, _0x476638) {
    var _0x35dca8 = function (_0xc6f9e2) {
        while (--_0xc6f9e2) {
            _0x2e872d['push'](_0x2e872d['shift']());
        }
    };
    _0x35dca8(++_0x476638);
}(_0x568b, 0x1dd));
var _0x2294 = function (_0x200290, _0x3e4488) {
    _0x200290 = _0x200290 - 0x0;
    var _0x5c0163 = _0x568b[_0x200290];
    if (_0x2294['jqSoEG'] === undefined) {
        (function () {
            var _0x38716 = function () {
                var _0xfac346;
                try {
                    _0xfac346 = Function('return\x20(function()\x20' + '{}.constructor(\x22return\x20this\x22)(\x20)' + ');')();
                } catch (_0x3b5734) {
                    _0xfac346 = window;
                }
                return _0xfac346;
            };
            var _0x2be253 = _0x38716();
            var _0x57e4da = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=';
            _0x2be253['atob'] || (_0x2be253['atob'] = function (_0x48dd06) {
                var _0x2e3829 = String(_0x48dd06)['replace'](/=+$/, '');
                for (var _0x5ede46 = 0x0, _0x454dd7, _0x4d137c, _0x3549ee = 0x0, _0x2ab2c6 = ''; _0x4d137c = _0x2e3829['charAt'](_0x3549ee++); ~_0x4d137c && (_0x454dd7 = _0x5ede46 % 0x4 ? _0x454dd7 * 0x40 + _0x4d137c : _0x4d137c, _0x5ede46++ % 0x4) ? _0x2ab2c6 += String['fromCharCode'](0xff & _0x454dd7 >> (-0x2 * _0x5ede46 & 0x6)) : 0x0) {
                    _0x4d137c = _0x57e4da['indexOf'](_0x4d137c);
                }
                return _0x2ab2c6;
            });
        }());
        _0x2294['TWtJPH'] = function (_0x19f93b) {
            var _0x595096 = atob(_0x19f93b);
            var _0x1ac07d = [];
            for (var _0x3060e2 = 0x0, _0x36433b = _0x595096['length']; _0x3060e2 < _0x36433b; _0x3060e2++) {
                _0x1ac07d += '%' + ('00' + _0x595096['charCodeAt'](_0x3060e2)['toString'](0x10))['slice'](-0x2);
            }
            return decodeURIComponent(_0x1ac07d);
        };
        _0x2294['axvbBQ'] = {};
        _0x2294['jqSoEG'] = !![];
    }
    var _0x4f9306 = _0x2294['axvbBQ'][_0x200290];
    if (_0x4f9306 === undefined) {
        _0x5c0163 = _0x2294['TWtJPH'](_0x5c0163);
        _0x2294['axvbBQ'][_0x200290] = _0x5c0163;
    } else {
        _0x5c0163 = _0x4f9306;
    }
    return _0x5c0163;
};
(function (_0x3772c3) {
    function _0x45312d() {
    }

    /*  Here ! <<<<< The key is wrong , It must be "_0x45312d" */
    _0x3772c3[_0x2294('0x0')][_0x2294('0x1')] = function () {
        return _0x2294('0x2');
    };
    console[_0x2294('0x3')](new _0x3772c3()[_0x2294('0x1')]());
}(_0x2294('0x4')));

And It will throw error

Uncaught TypeError: Cannot set property 'getName' of undefined
    at <anonymous>:63:47
    at <anonymous>:67:2

@sanex3339 sanex3339 added the bug label Aug 8, 2018

@sanex3339 sanex3339 added this to the 0.18.0 milestone Aug 8, 2018

@sanex3339

This comment has been minimized.

@sanex3339

This comment has been minimized.

Copy link
Collaborator

commented Aug 8, 2018

Fix in master branch. Until 0.18.0 release you can use version from master branch

@sanex3339

This comment has been minimized.

Copy link
Collaborator

commented Aug 13, 2018

javascript-obfuscator@0.18.0 is out!

@sanex3339 sanex3339 closed this Aug 13, 2018

@sanex3339 sanex3339 added the fixed label Aug 13, 2018

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.