Live data from Hacker News

How does Facebook disable Developer Tools?

stackoverflow.com

71–80 of 90 posts

Re: How does Facebook disable Developer Tools?

#71
post #32

This is a pretty good reason to never trust Chrome again.

I wouldn't trust any computer, then. It's the same as taking a bunch of code you have no idea how works, and paste it into CMD, then wondering why you just deleted C:/

So you're fine with Google allowing coders to change the function of the dev console? Interesting...

Re: How does Facebook disable Developer Tools?

#72
post #62

Earlier quoted context omitted.

Web browsers had had the capability to execute javascript through the URL bar since as long as I can remember. Social engineers should be able to just bypass this by telling users to copy paste the following code, Control+L, type "javascript:" (chrome strips it when copy-pasting), Control+V, Enter. javascript:alert('hi ' + document.body.innerHTML); If people can be tricked into executing code in the dev console, then…

Browsers have already started to remove/limit code execution capability from the address bar. https://bugzilla.mozilla.org/show_bug.cgi?id=656433 https://code.google.com/p/chromium/issues/detail?id=82181

Wait does this mean bookmarklets will fail in those browsers from now on?

Re: How does Facebook disable Developer Tools?

#73
post #72
post #62

Earlier quoted context omitted.

Browsers have already started to remove/limit code execution capability from the address bar. https://bugzilla.mozilla.org/show_bug.cgi?id=656433 https://code.google.com/p/chromium/issues/detail?id=82181

Wait does this mean bookmarklets will fail in those browsers from now on?

My bookmarklets run just fine, JS in the URL-bar doesn't.

Re: How does Facebook disable Developer Tools?

#74
post #3

Earlier quoted context omitted.

Why not a separate package altogether? That way the Chrome team can focus on Chrome, and the Developer Tools team can focus on producing a high-quality website debugger.

We can put bareers here forever that will deter more and more developers and curious yet-to-be hackers from playing with the web, while scammers will just use simple social tricks to make gullible people jump through any obstacle we put. Here, to be honest, I vote for natural selection. Fight the scammers, and let the gullible be scammed until the society develops an immune response. It happens all the times, and I t…

How isn't this a type of immune response?

Re: How does Facebook disable Developer Tools?

#75

Earlier quoted context omitted.

We can put bareers here forever that will deter more and more developers and curious yet-to-be hackers from playing with the web, while scammers will just use simple social tricks to make gullible people jump through any obstacle we put. Here, to be honest, I vote for natural selection. Fight the scammers, and let the gullible be scammed until the society develops an immune response. It happens all the times, and I t…

How isn't this a type of immune response?

The ongoing dumbing down of the Internet would be an autoimmune disease.

Re: How does Facebook disable Developer Tools?

#77
post #17

The accepted answer teases that this is not enough: Object.defineProperty(console, '_commandLineAPI', { get : function() { throw 'Nooo!' } }) But why isn't it enough?

I spent a while looking at it last night and came up with a solution, I'll walk you through it. For reference, here's the code:

    function escape(s) {
      // Bonus level!

      Object.defineProperty(console, 'foo', 
         { get : function() { throw 'nooo!' } });

      var code = 'with(window.console && console.foo || {}) {\n\t'+s+'\n}';
      console.log(code);

      try {
        console.log(eval(code));
      } catch (e) {
        console.log(e);
      }
    }
The idea is, you need to craft `s`, such that `s` can execute arbitrary code without throwing 'nooo!'. The interesting problem is, any access to `console.foo` with throw because the getter above is called. This includes the access inside the `with` statement. So the solution, if there is any, must somehow cause mutation of state before the `with` even executes.

Now, what brought me to the solution was this thought: "What in Javascript allows you to execute code before a given statement?" Upon framing it in this way, the solution became immediately clear: function declarations are automatically hoisted!

If you redefine `console` to be an object without the property 'foo', the `|| {}` part of the with predicate will instead be passed as the scope, and you have free reign to walk about the system.

So the solution is:

    alert(1) } function console(){} {
Which produces the statement:

    with(window.console && console.foo || {}) { 
      alert(1) } function console(){} {
    }

Re: How does Facebook disable Developer Tools?

#78
post #77
post #17

The accepted answer teases that this is not enough: Object.defineProperty(console, '_commandLineAPI', { get : function() { throw 'Nooo!' } }) But why isn't it enough?

I spent a while looking at it last night and came up with a solution, I'll walk you through it. For reference, here's the code: function escape(s) { // Bonus level! Object.defineProperty(console, 'foo', { get : function() { throw 'nooo!' } }); var code = 'with(window.console && console.foo || {}) {\n\t'+s+'\n}'; console.log(code); try { console.log(eval(code)); } catch (e) { console.log(e); } } The idea is, you need…

Ah, very clever, thanks :)

Re: How does Facebook disable Developer Tools?

#79
I think the burden lies on the browsers to warn average users of the danger of pasting javascript code. Perhaps a popup confirmation the first time you paste `javascript:...` in the address bar with a "Never ask again," and a warning that "Here be danger" when you open the dev console that you can dismiss.

Re: How does Facebook disable Developer Tools?

#80
post #32

Earlier quoted context omitted.

I wouldn't trust any computer, then. It's the same as taking a bunch of code you have no idea how works, and paste it into CMD, then wondering why you just deleted C:/

Exactly, how many developers can honestly say they've never copy pasted commands into the terminal without being 100% sure what they were doing?

Hesitantly, I will claim that I can say this because I cannot remember every pasting a command in I did not take the time to understand.
Post reply on HN