Created
October 4, 2021 04:28
-
-
Save NguyenKhong/e378affe7f4560f8ff3590893ba50607 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// ==UserScript== | |
// @name Anti Anti-debugger | |
// @namespace http://tampermonkey.net/ | |
// @version 1 | |
// @description Stops most anti debugging implementations by JavaScript obfuscaters | |
// @author ww | |
// @match * | |
// @include * | |
// @grant unsafeWindow | |
// @run-at document-start | |
// ==/UserScript== | |
(function() { | |
var _constructor = unsafeWindow.Function.prototype.constructor; | |
// Hook Function.prototype.constructor | |
unsafeWindow.Function.prototype.constructor = function() { | |
var fnContent = arguments[0]; | |
if (fnContent) { | |
if (fnContent.includes('debugger')) { // An anti-debugger is attempting to stop debugging | |
var caller = Function.prototype.constructor.caller; // Non-standard hack to get the function caller | |
var callerContent = caller.toString(); | |
if (callerContent.includes(/\bdebugger\b/gi)) { // Eliminate all debugger statements from the caller, if any | |
callerContent = callerContent.replace(/\bdebugger\b/gi, ''); // Remove all debugger expressions | |
eval('caller = ' + callerContent); // Replace the function | |
} | |
return (function () {}); | |
} | |
} | |
// Execute the normal function constructor if nothing unusual is going on | |
return _constructor.apply(this, arguments); | |
}; | |
})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment