Created
November 1, 2023 18:24
-
-
Save freehuntx/ce3b9902f9c84fbb8dfd3417ac71e94f to your computer and use it in GitHub Desktop.
Javascript function hook logger
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
function logHookFunction(obj, key, hookTime = 5000) { | |
if (typeof obj[key] !== "function") { | |
console.log("[-] Hook failed! Not a function!") | |
return | |
} | |
obj[`o${key}`] = obj[`o${key}`] || obj[key] | |
obj[key] = function(...args) { | |
console.log(`[HOOKR] ${key}(${args.join(',')})`) | |
return this[`o${key}`](...args) | |
} | |
console.log(`[+] Hooked "${key}"`) | |
setTimeout(() => { | |
obj[key] = obj[`o${key}`] | |
delete obj[`o${key}`] | |
console.log(`[+] UnHooked "${key}"`) | |
}, hookTime) | |
} | |
// Example: logHookFunction(document.head, "addChild") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment