-
-
Save pnigos/9bc75578c151dee4f26f5636654194d1 to your computer and use it in GitHub Desktop.
logger.js for hunting script gadgets. More info about script gadgets: https://github.com/google/security-research-pocs/tree/master/script-gadgets (Sebastian Lekies / Eduardo Vela Nava / Krzysztof Kotowicz)
This file contains 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
var logger = console.trace; | |
// ELEMENT | |
;(getElementByIdCopy => { | |
Element.prototype.getElementById = function(q) { | |
logger('getElementById', q, this, this.innerHTML); | |
return Reflect.apply(getElementByIdCopy, this, [q]) | |
} | |
})(Element.prototype.getElementById) | |
;(getElementsByTagNameCopy => { | |
Element.prototype.getElementsByTagName = function(q) { | |
logger('getElementsByTagName', q, this, this.innerHTML); | |
return Reflect.apply(getElementsByTagNameCopy, this, [q]) | |
} | |
})(Element.prototype.getElementsByTagName) | |
;(getAttributeCopy => { | |
Element.prototype.getAttribute = function(q) { | |
logger('getAttribute', q, this, this.innerHTML); | |
return Reflect.apply(getAttributeCopy, this, [q]) | |
} | |
})(Element.prototype.getAttribute) | |
;(querySelectorCopy => { | |
Element.prototype.querySelector = function(q) { | |
logger('querySelector', q, this, this.innerHTML); | |
return Reflect.apply(querySelectorCopy, this, [q]) | |
} | |
})(Element.prototype.querySelector) | |
;(querySelectorAllCopy => { | |
Element.prototype.querySelectorAll = function(q) { | |
logger('querySelectorAll', q, this, this.innerHTML); | |
return Reflect.apply(querySelectorAllCopy, this, [q]) | |
} | |
})(Element.prototype.querySelectorAll) | |
// DOCUMENT | |
;(getElementByIdCopy => { | |
document.getElementById = function(q) { | |
logger('document.getElementById', q); | |
return Reflect.apply(getElementByIdCopy, document, [q]) | |
} | |
})(document.getElementById) | |
;(getElementsByTagNameCopy => { | |
document.getElementsByTagName = function(q) { | |
logger('document.getElementsByTagName', q); | |
return Reflect.apply(getElementsByTagNameCopy, document, [q]) | |
} | |
})(document.getElementsByTagName) | |
;(querySelectorCopy => { | |
document.querySelector = function(q) { | |
logger('document.querySelector', q); | |
return Reflect.apply(querySelectorCopy, document, [q]) | |
} | |
})(document.querySelector) | |
;(querySelectorAllCopy => { | |
document.querySelectorAll = function(q) { | |
logger('document.querySelectorAll', q); | |
return Reflect.apply(querySelectorAllCopy, document, [q]) | |
} | |
})(document.querySelectorAll) | |
// TEST | |
console.log(document.getElementById("test")); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment