Native VS Tampered
https://adtechmadness.wordpress.com/2019/03/23/javascript-tampering-detection-and-stealth/
In the following paragaraph, the author is trying to create a stealth function that pretends to
be a native function. But he finds one problem: the stealth function has "prototype."
In other words, if the function has "prototype", then it's a fake function.
Is it perfect? not yet. The one problem I couldn’t find a solution for is the “prototype” property.
i.e., the native toString doesn’t have one:
'prototype' in Function.prototype.toString;
false
Where’s the tampered:
'prototype' in Function.prototype.toString;
true
You might think “oh, just use the delete operator“, but it won’t work since it’s a non-configurable property:
delete Function.prototype.toString.prototype;
false
'prototype' in Function.prototype.toString;
true
Let me know if you can find a solution to this one!
See console
function isNative(fn){
return !("prototype" in fn);
};
BEFORE
AFTER
This detection method works in all browsers(Chrome,FF,Opera,Safari,Edge,Moble) except IE11.