How we know we have global variables like console, window, alert and etc.
If I obfuscate some code, for example:
const date = new Date();
let kruzya = 0;
kruzya++;
if (kruzya >= 1) console.log(`${kruzya} is more like 0`, date); // Output number (1) and timestamp (date)
we get:
const O = ['log', 'ike 0', 'ore l', ' is m'];
(function (j, u) {
const k = function (C) {
while (--C) {
j['push'](j['shift']());
}
};
k(++u);
}(O, -0x1 * -0x10fd + -0x92 + -0xf5b));
const j = function (u, s) {
u = u - (-0x1 * -0x10fd + -0x92 + -0x106b);
let E = O[u];
return E;
};
const u = function (s, E) {
return j(s - '0x3c8', E);
},
date = new Date();
let kruzya = -0x92 + 0x771 + -0x6df;
kruzya++;
if (kruzya >= 0x1c * -0xd1 + -0x92 + 0x176f) console[u('0x3c8')](kruzya + (u('0x3cb') + u('0x3ca') + u('0x3c9')), date);
but some code we didn't obfuscate. For example: new Date(), console etc.
_What about obfuscate this too?_
Why?
If I have debug in my code user can check by code what exact is wrong or etc.
UPD: Yep, if I just disable console... I can didn't obfuscate console, but what if I really need it?
This is more question like suggestion but ... what about create method to obfuscate global methods and/or variables? :eyes:
Example of obfuscate
const obj = ["Date", "console", "log"];
function getVariable(index) {
return obj[index];
}
const date = new window[getVariable(0)]; // just example. This is typo!
const myHidedConsole = window[getVariable(1)];
myHidedConsole[getVariable(2)]("some debug info");
So the suggestion is to transform
new Date()
into
new window['Date']()
After that it can be moved to the strings array
Yep, something like that.
If you know a better choice do it better :eyes:
Like this idea. Will try to implement it in the feature.
Some modern idea:
```
window["0x1"] // bad because we was see what this can be global variable.
windowHandler["0x1"] // better because we see only function.
function windowHandler(arg) // can have random name
{
return window[arrayWithWords[arg]]; // can be else ... just for example
}
@sanex3339 tagging. If you didn't see that.
Most helpful comment
Like this idea. Will try to implement it in the feature.