网站可以知道我是否正在运行用户脚本吗?

发布于 2024-12-21 20:41:57 字数 147 浏览 1 评论 0原文

例如,Facebook.com 能否在我的浏览器上运行版本控制脚本,并查明我是否使用脚本运行更改过的 HTML 代码?

是否可以通过一个脚本来完成此操作,该脚本可以读取缓存中的 HTML 代码并生成某种哈希标签,该标签被发送回服务器并与发送到客户端的代码进行比较?

Can, for example, Facebook.com run a version control script on my browser and find out if I am running altered HTML code with the use of a script?

Could that be done with a script that can read the HTML code in the cache and produce some kind of hash tag that is sent back to the server and compared with the code that was sent to the client?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

撩心不撩汉 2024-12-28 20:41:57

是的,理论上,站点可以推断出各种情况下脚本的存在。

这并不是万无一失的,而且通常对于网站的可忽略不计的“威胁”来说太麻烦了。 (话又说回来,一些网站管理员可能对此类事情过于偏执。;))

一些方法,取决于脚本的作用(无特定顺序):

  1. 游戏或拍卖网站可以监控时间(速度和规律性) “出价”点击。

  2. 站点可以通过 AJAX 方式返回

  3. 类似地,站点可以 AJAX 返回页面的任何或全部内容,并将其与预期值进行比较。

  4. 可以记录额外的 AJAX 调用或不满足隐藏要求的 AJAX 调用(并允许显示为成功)。

  5. 如果脚本以正确(错误)的方式使用unsafeWindow页面可以检测到这一点,甚至劫持(稍微)提升的权限

  6. 可以检测到之前没有鼠标悬停事件的“点击”。我实际上见过这种方法在野外使用。

  7. 页面的 javascript 通常可以检测到脚本生成的点击(等)用户生成的。 (感谢 c69 的提醒。)

不过,最终,优势在于用户脚本编写者。网页采取的任何反措施都可以在用户端被检测到并阻止。即使是定制的、所需的插件或所需的硬件加密狗也可以被熟练且积极的用户破坏。

Yes, in theory, a site can deduce the presence of scripts in various situations.

This is not foolproof and usually is way too much trouble for the negligible "threat" to the site. (Then again, some webmasters can be obsessive-paranoids about such things. ;) )

Some methods, depending on what the script does (in no particular order):

  1. Gaming or auction sites can monitor the timing (speed and regularity) of "bid" clicks.

  2. A site can AJAX-back the count of say, <script> nodes, looking for extras.

  3. Similarly, a site can AJAX-back any or all of the content of a page and compare that to expected values.

  4. Extra AJAX calls, or AJAX calls that don't meet hidden requirements can be noted (and allowed to appear to succeed).

  5. If the script uses unsafeWindow in just the right (wrong) way, a page can detect that and even hijack (slightly) elevated privileges.

  6. "Clicks" that were not preceded by mouseover events can be detected. I've actually seen this used in the wild.

  7. A page's javascript can often detect script-generated clicks (etc.) as being different than user generated ones. (Thanks, c69, for the reminder.)

Ultimately, the advantage is to the userscript writer, however. Any counter-measures that a webpage takes can be detected and thwarted on the user end. Even custom, required plugins or required hardware dongles can be subverted by skilled and motivated users.

花辞树 2024-12-28 20:41:57

更新:自起,以下方法完全无效油猴3.3



请参阅(死链接)如何检测油猴

用于检测 GM 是否已安装(但不检测脚本是否实际在该页面上运行)的 JavaScript:

已过时​​的选项 1:

if (Components.interfaces.gmIGreasemonkeyService) {
  alert("I smell a monkey!");
}

过时的选项 2:

<script type="text/javascript" src="resource://greasemonkey/addons4.js"></script>
<script type="text/javascript">
if (typeof GM_addonsStartup !== "undefined") {
  alert("I smell a monkey!");
}
</script>

Update: The methods below are fully ineffective as of Greasemonkey 3.3.



See (Dead link) How-to Detect Greasemonkey.

Javascript to detect if GM is installed (but not whether a script is actually running on that page):

Obsolete Option 1:

if (Components.interfaces.gmIGreasemonkeyService) {
  alert("I smell a monkey!");
}

Obsolete Option 2:

<script type="text/javascript" src="resource://greasemonkey/addons4.js"></script>
<script type="text/javascript">
if (typeof GM_addonsStartup !== "undefined") {
  alert("I smell a monkey!");
}
</script>
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文