-
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Closed
Labels
Description
Expected Behavior
The code with transformObjectKeys param should work the same as without, with no extra crashes
Current Behavior
It causes a crash in specific cases
Steps to Reproduce (for bugs)
I created a little project with minimal reproducible script: https://github.com/Kukunin/javascript-obfuscator-repro. Considering we have the source script:
var SHA256 = (function () {
var CryptoJS = CryptoJS || (function () {
var C = {};
C.Base = {
extend: function () { return {}; }
};
C.WordArray = C.Base.extend({
method: function () {
return new C.WordArray();
}
});
return C;
})();
CryptoJS.SHA256 = function() { return "sha256"; };
return CryptoJS.SHA256;
})();
console.log(SHA256("my text").toString());If we obfuscate it with transformObjectKeys, it works fine.
If we uglify it with uglify-js package, and try to obfuscate the result: it fails.
It works without transformObjectKeys.
The uglified code is:
var SHA256=function(){var n,r=r||((n={Base:{extend:function(){return{}}}}).WordArray=n.Base.extend({method:function(){return new n.WordArray}}),n);return r.SHA256=function(){return"sha256"},r.SHA256}();console.log(SHA256("my text").toString());which in prettified mode gives:
var SHA256 = (function() {
var n,
r =
r ||
(((n = {
Base: {
extend: function() {
return {};
}
}
}).WordArray = n.Base.extend({
method: function() {
return new n.WordArray();
}
})),
n);
return (
(r.SHA256 = function() {
return "sha256";
}),
r.SHA256
);
})();
console.log(SHA256("my text").toString());It reproduces on obfuscator.io on the last code.
Your Environment
Obfuscator version: 0.18.1
Node: 10.7.0
Stack trace
Minimal working example that will help to reproduce issue
You can clone and play with this repo: https://github.com/Kukunin/javascript-obfuscator-repro
Reactions are currently unavailable