Skip to content

Instantly share code, notes, and snippets.

@zhanang19
Created July 29, 2020 02:28
Show Gist options
  • Save zhanang19/667e7977ed74e05e1c4518f2ea68a891 to your computer and use it in GitHub Desktop.
Save zhanang19/667e7977ed74e05e1c4518f2ea68a891 to your computer and use it in GitHub Desktop.
Browser Console Warning

Browser Console Warning

There is so many user that don't know what is browser console. An attacker can steal an information from their account by injecting a malicious javascript. By using this script, developer can easily give a warning for user on the browser console.

(function() {
var warning = "🚫STOP!";
var message = "This is a browser feature intended for developers. Do not enter or paste code which you don't understand. It may allow attackers to steal your information or impersonate you.\nSee https://en.wikipedia.org/wiki/Self-XSS for more details";
if (navigator && navigator.userAgent) {
var t = navigator.userAgent.match(/opera|chrome|safari|firefox|msie|trident(?=\/)/i);
if (t && t[0].search(/trident|msie/i) < 0) {
window.console.log("%c" + warning, "color:red;font-size:xx-large;font-weight:bold;");
window.console.log("%c" + message, "font-size:large;");
return;
}
}
window.console.log(warning + "\n" + message)
})()
(function(){var e="This is a browser feature intended for developers. Do not enter or paste code which you don't understand. It may allow attackers to steal your information or impersonate you.\nSee https://en.wikipedia.org/wiki/Self-XSS for more details";if(navigator&&navigator.userAgent){var o=navigator.userAgent.match(/opera|chrome|safari|firefox|msie|trident(?=\/)/i);if(o&&o[0].search(/trident|msie/i)<0)return window.console.log("%c🚫STOP!","color:red;font-size:xx-large;font-weight:bold;"),void window.console.log("%c"+e,"font-size:large;")}window.console.log("🚫STOP!\n"+e)})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment