So apparently because of the recent scams, the developer tools is exploited by people to post spam and even used to "hack" accounts. Facebook has blocked the developer tools, and I can't even use the console.

Enter image description here

How did they do that?? One Stack Overflow post claimed that it is not possible, but Facebook has proven them wrong.

Just go to Facebook and open up the developer tools, type one character into the console, and this warning pops up. No matter what you put in, it will not get executed.

How is this possible?

They even blocked auto-complete in the console:

Enter image description here

推荐答案

I'm a security engineer at Facebook and this is my fault. We're testing this for some users to see if it can slow down some attacks where users are tricked into pasting (malicious) JavaScript code into the browser console.

Just to be clear: trying to block hackers client-side is a bad idea in general; this is to protect against a specific social engineering attack.

If you ended up in the test group and are annoyed by this, sorry. I tried to make the old opt-out page (now help page) as simple as possible while still being scary enough to stop at least some of the victims.

The actual code is pretty similar to @joeldixon66's link; ours is a little more complicated for no good reason.

Chrome wraps all console code in

with ((console && console._commandLineAPI) || {}) {
  <code goes here>
}

... so the site redefines console._commandLineAPI to throw:

Object.defineProperty(console, '_commandLineAPI',
   { get : function() { throw 'Nooo!' } })

This is not quite enough (try it!), but that's the main trick.


Epilogue: The Chrome team decided that defeating the console from user-side JS was a bug and fixed the issue, rendering this technique invalid. Afterwards, additional protection was added to protect users from self-xss.

Javascript相关问答推荐

提交表格后保留Web表格中的收件箱值?

扫描qr code后出错whatter—web.js

使用javascript将Plotly Expandable Sparkline转换为HighCharter Plot在bslib卡中

如何从html元素创建树 struct ?

查找最长的子序列-无法重置数组

获取Uint8ClampedArray中像素数组的宽度/高度

如何在ASP.NET JavaScript中使用Google Charts API仅对绘制为负方向的条形图移动堆叠条形图标签位置

在运行时使用Next JS App Router在服务器组件中运行自定义函数

对路由DOM嵌套路由作出react

本地库中的chartjs-4.4.2和chartjs-plugin-注解

NG/Express API路由处理程序停止工作

如何在箭头函数中引入or子句?

自动滚动功能在当前图像左侧显示上一张图像的一部分

对不同目录中的Angular material 表列进行排序

在JS/TS中构造RSA公钥

Playwright:ReferenceError:browserContext未定义

使用JAVASCRIPT-使用If和Else If多次判断条件-使用JAVASRIPT对象及其属性

已在EventListener中更新/更改异步的React.js状态对象,但不会导致组件重新呈现

调试jQuery代码以获取所有行的总和(票证类型)

我如何才能阻止我的球数以指数方式添加到我的HTML画布中?