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

Uncaught TypeError:Connot read property 'test' of undefined Chrome old versions <60 #615

Closed
typeoo opened this issue May 30, 2020 · 11 comments
Labels

Comments

@typeoo
Copy link

typeoo commented May 30, 2020

Expected Behavior

Hi,
I noticed that my obfuscated code doesn't work on the old versions of Chrome.
I tested it on most of old versions. (versions: 32,42,43,44 .... 63);
Also I tried to check the other browsers (old versions); I got the same problem from Opera too.
Firefox had no problem.

image

it seems the problem is in this part:
var _0x581498 = function() {
var _0x50df5e = _0x581498[_0xa8ea('0x53e', '7]tY')](_0x2b610f[_0xa8ea('0x1b07', '%Rif')])()_0xa8ea('0x12c8', 'KvLJ')]);
return !_0x50df5e'test';
};
I'm trying to figure it out ,and also waiting your help.
thanks for making this amazing tool.

@sanex3339
Copy link
Member

Hi. Can you show me original source code of this part?

var _0x581498 = function() {
var _0x50df5e = _0x581498[_0xa8ea('0x53e', '7]tY')](_0x2b610f[_0xa8ea('0x1b07', '%Rif')])()_0xa8ea('0x12c8', 'KvLJ')]);
return !_0x50df5e'test';
};

@sanex3339
Copy link
Member

Hmm.
Show me your obfuscator version, your options and example how I can reproduce this bug.

This is invalid code. How did you obfuscate your code?

@JerryChan31
Copy link

I bumped into this error, too.
In my case, I found this situation happens when you turned on selfDefending and stringArray at the same time.
This is my options and I use webpack-obfuscator to obfuscate my code.

const obfConfig = {
  compact: true,
  controlFlowFlattening: false,
  deadCodeInjection: false,
  debugProtection: false,
  debugProtectionInterval: false,
  disableConsoleOutput: true,
  identifierNamesGenerator: 'hexadecimal',
  log: false,
  renameGlobals: false,
  rotateStringArray: true,
  selfDefending: true,
  shuffleStringArray: true,
  splitStrings: true,
  stringArray: true,
  stringArrayEncoding: false,
  stringArrayThreshold: 1,
  unicodeEscapeSequence: false
}

@sanex3339
Copy link
Member

sanex3339 commented Jun 3, 2020

Probably something other breaks your code, because here

var _0x581498 = function() {
    var _0x50df5e = _0x581498[_0xa8ea('0x53e', '7]tY')](_0x2b610f[_0xa8ea('0x1b07', '%Rif')])()_0xa8ea('0x12c8', 'KvLJ')]);
    return !_0x50df5e'test';
};

this line is invalid JS code.:

!_0x50df5e'test';

@sanex3339
Copy link
Member

@JerryChan31 can you try to reproduce it here?
https://obfuscator.io/

@JerryChan31
Copy link

JerryChan31 commented Jun 3, 2020

var a0_0x39cc89 = a0_0x2ff663(this, function() {
    var _0x3bc218 = function() {
        var _0x1ea51c = _0x3bc218['constructor']('return\x20/\x22\x20+\x20this\x20+\x20\x22/')()['compile']('^([^\x20]+(\x20+[^\x20]+)+)+[^\x20]}');
        return !_0x1ea51c['test'](a0_0x39cc89);
    };
    return _0x3bc218();
});

This is where my code throws error.It looks like regular expression I guess ?
I can try to reproduce it later.

@typeoo
Copy link
Author

typeoo commented Jun 3, 2020

hi Timofey
by turning off compact code I got it resolved.
I think the problem is here: regular expression

uncompacted code:

 if (!_0x51839a[_0x4add('0x9f4')]($, _0x4add('0x10a2'))[_0x4add('0x122d')]) {
        if (_0x51839a[_0x4add('0x25a')](_0x51839a[_0x4add('0xf3a')], _0x51839a[_0x4add('0xf3a')])) {
            return ![];
        } else {
            var _0x14e114 = /^[A-Za-z]*$/;
            if (_0x14e114['test'](result)) {
                return !![];
            } else {
                return ![];


            }
        }
    }

I think regular expressions can throw an error on old versions when we compact the code:

var english = /^[A-Za-z]*$/;
if (english.test(String.fromCharCode(result))){english_chr=true;}else{english_chr=false;}
  • note I just had this problem on old versions.

@sanex3339 sanex3339 added the bug label Jun 4, 2020
@TerranTian
Copy link

TerranTian commented Jun 25, 2020

Bumped into this problem too.

image

Here is the original code :

function loadLib(src, callback) {
        var s = document.createElement('script');
        s.async = false;
        s.src = src;
        s.addEventListener('load', function () {
            s.parentNode.removeChild(s);
            s.removeEventListener('load', arguments.callee, false);
            callback && callback();
        }, false);
        document.head.appendChild(s);
    };

Here are the options:

{
    "compact": true,
    "controlFlowFlattening": false,
    "deadCodeInjection": false,
    "debugProtection": false,
    "debugProtectionInterval": false,
    "disableConsoleOutput": false,
    "identifierNamesGenerator": "mangled",
    "log": false,
    "renameGlobals": false,
    "rotateStringArray": true,
    "selfDefending": true,
    "stringArray": true,
    "stringArrayEncoding": true,
    "stringArrayThreshold": 0.75,
    "unicodeEscapeSequence": false,

    "transformObjectKeys":false
}

@sanex3339
Copy link
Member

Just have applied for a free opensource BrowserStack plan, so can test it.

@sanex3339
Copy link
Member

sanex3339 commented Jun 25, 2020

I have found the problem, the PR is ready.

@sanex3339
Copy link
Member

Fixed in 1.2.1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants