Open MichaelXF opened 3 months ago
With that, I think, we can pretty much do the gloablConcealing
Something like that I guess
let root = {};
eval("root=this");
const _Object = {}.constructor;
const globalDescriptors = _Object.getOwnPropertyDescriptors(root);
for (const globalName in globalDescriptors) {
const descriptor = globalDescriptors[globalName];
globalDescriptors[globalName] = {
...descriptor,
...("set" in descriptor
? {
set(value) {
root[globalName] = value;
},
}
: {}),
...("get" in descriptor
? {
get() {
return root[globalName];
},
}
: {}),
};
}
const rootLike = _Object.defineProperties({}, globalDescriptors);
(() => {
with (rootLike) {
console.log(Function);
}
}).call(rootLike);
The
with
statement is able to obfuscate variable names, that could be very difficult for AST analyzers to understand. You can also do weird things with proxies.Unfortunately, the with statement is deprecated, however it will most likely be supported for a very long time and every browser still supports it. You also lose various optimizations as variables cannot be assumed anymore.