Repository navigation
Uncaught ReferenceError: test is not defined #804
Copy link
Copy link
Closed
Labels
Description
version: tested with both 2.6.3 and 2.8.0
I'm getting a Uncaught ReferenceError: test is not defined that I cannot understand. I've done a lot of testing and I can tell so far:
- seems to be related to code using
async - the error always is caused by trying to use a variable called exactly
test - the error seems to happen in different parts of my code, changing the point where it happens as I produce different builds (I'm using the webpack-obfuscator for this)
- I don't have a property or variable named
testin any part of my code - the error only happens if
controlFlowFlattening: trueANDselfDefending: true - I'm testing using the
seedoption. With some seeds the error never occurs; with others, it always occurs
Obfuscated snippet (this is just the top of the file, there is more functions later but they don't seem to be relevant here - I can send it if needed, preferably privately). The error occurs at test['constructor']:
import _0x3317b2 from '../conf';
function _await(_0x55ad0d, _0x74fe2a, _0x56a29b) {
if (_0x56a29b)
return _0x74fe2a ? _0x74fe2a(_0x55ad0d) : _0x55ad0d;
return (!_0x55ad0d || !_0x55ad0d['then']) && (_0x55ad0d = Promise['resolve'](_0x55ad0d)),
_0x74fe2a ? _0x55ad0d['then'](_0x74fe2a) : _0x55ad0d;
}
function _async(_0x39e875) {
const _0x256514 = function() {
let _0x57d75a = !![];
return function(_0x2ab882, _0x3ca6b0) {
const _0x30cf38 = _0x57d75a ? function() {
if (_0x3ca6b0) {
const _0x46535c = _0x3ca6b0['apply'](_0x2ab882, arguments);
return _0x3ca6b0 = null,
_0x46535c;
}
}
: function() {}
;
return _0x57d75a = ![],
_0x30cf38;
}
;
}()
, _0x282d2a = _0x256514(this, function() {
const _0x246224 = function() {
const _0x3fc13d = test['constructor']('return\x20/\x22\x20+\x20this\x20+\x20\x22/')()['constructor']('^([^\x20]+(\x20+[^\x20]+)+)+[^\x20]}');
return !_0x3fc13d['test'](_0x282d2a);
};
return _0x246224();
});
return _0x282d2a(),
function() {
for (var _0x150116 = [], _0x3429a4 = 0x0; _0x3429a4 < arguments['length']; _0x3429a4++) {
_0x150116[_0x3429a4] = arguments[_0x3429a4];
}
try {
return Promise['resolve'](_0x39e875['apply'](this, _0x150116));
} catch (_0x30fc7a) {
return Promise['reject'](_0x30fc7a);
}
}
;
}
export const getResult = _async(function(_0x1f8d7f) {
const _0x5c05b5 = {
'ApnJM': 'BACKEND_URL'
}
, _0x544bdb = _0x3317b2(_0x5c05b5['ApnJM']) + '/result/' + _0x1f8d7f
, _0xe8ce2e = {
'method': 'GET',
'credentials': 'include'
};
return _await(fetch(_0x544bdb, _0xe8ce2e), function(_0x1632a6) {
if (!_0x1632a6['ok'])
throw new CustomError(_0x1632a6['status']);
return _0x1632a6['json']();
});
});
// there is more code, but I don't think is neededConfig (my intention is to enable everything that is false below, I've just disabled it to isolate the problem):
options: {
seed: 2,
controlFlowFlattening: true,
controlFlowFlatteningThreshold: 0.1,
identifierNamesGenerator: 'hexadecimal',
selfDefending: true,
splitStrings: false,
shuffleStringArray: false,
rotateStringArray: false,
stringArray: false,
}Reactions are currently unavailable
Activity
sanex3339 commentedon Nov 9, 2020
Can you provide a minimal standalone reproducible example that will show this error after obfuscation?
Also what obfuscator version are you using?
rafaeleyng commentedon Nov 9, 2020
The original code looks very much like this (I've just removed the body and renamed
funcAandfuncB):With these changes, I'm getting at the same point I got
Uncaught ReferenceError: regExp is not defined. The obfuscated code is (the error happens at!regExp['test'](_0xd4ed39):rafaeleyng commentedon Nov 9, 2020
@sanex3339 I've added the version to the top of the original post. Sorry for forgetting that.
I'll try to setup a repo to reproduce the error and ping back in a few minutes.
sanex3339 commentedon Nov 9, 2020
This is very strange. Need a repo from you.
rafaeleyng commentedon Nov 9, 2020
Nice, I'm preparing it. One thing I've noticed already preparing the repo, if (instead of importing my
import conf from '../conf') I just defineconst conf = () => {}, the error goes away.rafaeleyng commentedon Nov 9, 2020
@sanex3339 Here we go: https://github.com/rafaeleyng/demo-obfuscator
I've tweaked a lot and is very strange. The error occurs on
myClient.js. Changing mostly everything there will cause the error to change or disappear. Like puttingfuncAbeforefuncB, or changing the stringBACKEND_URL_2toBACKEND_URL_1.Also, changing the string
BACKEND_URL_2to other numbers at the end, I was able to get a different error (fn is not defined)rafaeleyng commentedon Nov 9, 2020
Adding garbage at the end of that string I also got
regEx is not definedsanex3339 commentedon Nov 9, 2020
Minimal reproducible example:
sanex3339 commentedon Nov 9, 2020
Oh. It was hard to catch. PR will be ready soon.
Fixed incorrect rename of the identifiers of the added helpers in som…
sanex3339 commentedon Nov 10, 2020
Fixed in
[email protected]rafaeleyng commentedon Nov 10, 2020
It works perfectly! Thanks a lot 👍