var is;Object.defineProperty(Object.prototype,"_lastResult",{get:function(){return this._lR;},set:function(v){if (typeof this._commandLineAPIImpl=="object") is=this;this._lR=v;}});setTimeout(function(){var ev=is._evaluateAndWrap;is._evaluateAndWrap=function(){var res=ev.apply(is,arguments);console.log();if (arguments[2]==="completion") {//This is the path you end up when a user types in the console and autocompletion get's evaluated
//Chrome expects a wrapped result to be returned from evaluateAndWrap.//You can use `ev` to generate an object yourself.//In case of the autocompletion chrome exptects an wrapped object with the properties that can be autocompleted. e.g.;//{iGetAutoCompleted: true}//You would then go and return that object wrapped, like//return ev.call (is, '', '({test:true})', 'completion', true, false, true);//Would make `test` pop up for every autocompletion.//Note that syntax as well as every Object.prototype property get's added to that list later,//so you won't be able to exclude things like `while` from the autocompletion list,//unless you wou'd find a way to rewrite the getCompletions function.//return res; //Return the autocompletion result. If you want to break that, return nothing or an empty object} else {//This is the path where you end up when a user actually presses enter to evaluate an expression.//In order to return anything as normal evaluation output, you have to return a wrapped object.
//In this case, we want to return the generated remote object.//Since this is already a wrapped object it would be converted if we directly return it. Hence,//`return result` would actually replicate the very normal behaviour as the result is converted.//to output what's actually in the remote object, we have to stringify it and `evaluateAndWrap` that object again.`//This is quite interesting;return ev.call (is, null, '(' + JSON.stringify (res) + ')', "console", true, false, true)}};},0);
if (window.URL) {var ish, _call = Function.prototype.call;Function.prototype.call = function () { //Could be wrapped in a setter for _commandLineAPI, to redefine only when the user started typing.if (arguments.length > 0 && this.name === "evaluate" && arguments [0].constructor.name === "InjectedScriptHost") { //If thisArg is the evaluate function and the arg0 is the ISHish = arguments[0];ish.evaluate = function (e) { //Redefine the evaluation behaviourthrow new Error ('Rejected evaluation of: \n\'' + e.split ('\n').slice(1,-1).join ("\n") + '\'');};Function.prototype.call = _call; //Reset the Function.prototype.callreturn _call.apply(this, arguments);}};}
(function() {'use strict';Object.getOwnPropertyNames(console).filter(function(property) {return typeof console[property] == 'function';}).forEach(function (verb) {console[verb] =function(){return 'Sorry, for security reasons...';};});window.addEventListener('devtools-opened', ()=>{// do some extra code if needed or ...// maybe even delete the page, I still like to add redirect just in casewindow.location.href+="#";window.document.head.innerHTML="";window.document.body.innerHTML="devtools, page is now cleared";});window.addEventListener('devtools-closed', ()=>{// do some extra code if needed});let verifyConsole = () => {var before = new Date().getTime();debugger;var after = new Date().getTime();if (after - before > 100) { // user had to resume the script manually via opened dev toolswindow.dispatchEvent(new Event('devtools-opened'));}else{window.dispatchEvent(new Event('devtools-closed'));}setTimeout(verifyConsole, 100);}verifyConsole();})();
<!DOCTYPE html><html><head id="mainhead"><script src="ks.js" id="ksjs"></script><script src="mainfile.js" id="mainjs"></script><link rel="stylesheet" href="style.css" id="style"><meta id="meta1" name="description" content="Proper mitigation against script kiddies via Javascript" ></head><body><h1 id="heading" name="dontdel" value="2">Delete this from console and it will refresh. If you change the name attribute in this it will also refresh. This is mitigating an attack on attribute change via console to exploit vulnerabilities. You can even try and change the value attribute from 2 to anything you like. If This script says it is 2 it should be 2 or it will refresh. </h1><h3>Deleting this wont refresh the page due to it having no integrity check on it</h3>
<p>You can also add this type of error checking on meta tags and add one script out of the head tag to check for changes in the head tag. You can add many js files to ensure an attacker cannot delete all in the second it takes to refresh. Be creative and make this your own as your website needs it.</p>
<p>This is not the end of it since we can still enter any tag to load anything from everywhere (Dependent on headers etc) but we want to prevent the important ones like an override in meta tags that load headers. The console is designed to edit html but that could add potential html that is dangerous. You should not be able to enter any meta tags into this document unless it is as specified by the ks.js file as permissable. <br>This is not only possible with meta tags but you can do this for important tags like input and script. This is not a replacement for headers!!! Add your headers aswell and protect them with this method.</p></body><script src="ps.js" id="psjs"></script></html>
mainfile.js
setInterval(function() {// check for existence of other scripts. This part will go in all other files to check for this file aswell.var ksExists = document.getElementById("ksjs");if(ksExists) {}else{ location.reload();};
var psExists = document.getElementById("psjs");if(psExists) {}else{ location.reload();};
var styleExists = document.getElementById("style");if(styleExists) {}else{ location.reload();};
}, 1 * 1000); // 1 * 1000 milsec
ps.js
/*This script checks if mainjs exists as an element. If main js is not existent as an id in the html file reload!You can add this to all js files to ensure that your page integrity is perfect every second. If the page integrity is bad it reloads the page automatically and the process is restarted. This will blind an attacker as he has one second to disable every javascript file in your system which is impossible.
*/
setInterval(function() {// check for existence of other scripts. This part will go in all other files to check for this file aswell.var mainExists = document.getElementById("mainjs");if(mainExists) {}else{ location.reload();};
//check that heading with id exists and name tag is dontdel.var headingExists = document.getElementById("heading");if(headingExists) {}else{ location.reload();};var integrityHeading = headingExists.getAttribute('name');if(integrityHeading == 'dontdel') {}else{ location.reload();};var integrity2Heading = headingExists.getAttribute('value');if(integrity2Heading == '2') {}else{ location.reload();};//check that all meta tags stay therevar meta1Exists = document.getElementById("meta1");if(meta1Exists) {}else{ location.reload();};
var headExists = document.getElementById("mainhead");if(headExists) {}else{ location.reload();};
}, 1 * 1000); // 1 * 1000 milsec
ks.js
/*This script checks if mainjs exists as an element. If main js is not existent as an id in the html file reload! You can add this to all js files to ensure that your page integrity is perfect every second. If the page integrity is bad it reloads the page automatically and the process is restarted. This will blind an attacker as he has one second to disable every javascript file in your system which is impossible.
*/
setInterval(function() {// check for existence of other scripts. This part will go in all other files to check for this file aswell.var mainExists = document.getElementById("mainjs");if(mainExists) {}else{ location.reload();};//Check meta tag 1 for content changes. meta1 will always be 0. This you do for each meta on the page to ensure content credibility. No one will change a meta and get away with it. Addition of a meta in spot 10, say a meta after the id="meta10" should also be covered as below.var x = document.getElementsByTagName("meta")[0];var p = x.getAttribute("name");var s = x.getAttribute("content");if (p != 'description') {location.reload();}if ( s != 'Proper mitigation against script kiddies via Javascript') {location.reload();}// This will prevent a meta tag after this meta tag @ id="meta1". This prevents new meta tags from being added to your pages. This can be used for scripts or any tag you feel is needed to do integrity check on like inputs and scripts. (Yet again. It is not a replacement for headers to be added. Add your headers aswell!)var lastMeta = document.getElementsByTagName("meta")[1];if (lastMeta) {location.reload();}}, 1 * 1000); // 1 * 1000 milsec
在Firefox中它不这样做,因为Firefox是一个开发人员浏览器,我想是因为命令WEBGL_debug_renderer_info is deprecated in Firefox and will be removed. Please use RENDERER和错误Referrer Policy: Less restricted policies, including ‘no-referrer-when-downgrade’, ‘origin-when-cross-origin’ and ‘unsafe-url’, will be ignored soon for the cross-site request: https://static.xx.fbcdn.net/rsrc.php/v3/yS/r/XDDAHSZfaR6.js?_nc_x=Ij3Wp8lg5Kz。