Friday, 9 March 2018

Find globals left in a website/webpage/webapp browser based game etc.

Visit a clean blank webpage in chrome.
Press F12 or goto JavaScript console.

Copy and paste this in.
It will get a list of all the keys exposed on window object. (Globals)

var _KEYS_ = {}
for (var key in window) {
_KEYS_[key] = 1
copy('var _KEYS_ = '+JSON.stringify(_KEYS_) + "; Object.keys(window).filter(function(key){ return !_KEYS_[key] })")

Next visit the page/site you want to look for exposed globals on.

Somtimes devs forget to write a var keyword or they leave globals in for debug reasons.

Paste the clipboard contents into the JS Console.
It will output an array of exposed global variables.

No comments:

Post a Comment