在 PHP 中创建唯一用户指纹的方法

发布于 2024-09-30 09:39:23 字数 281 浏览 5 评论 0原文

在 PHP 中生成用户唯一性“指纹”的最佳方法是什么?

例如:

  1. 我可以使用用户的 IP 地址 然而,作为“指纹”, 是同一 IP 上的多个其他用户
  2. 可能 使用用户的IP+用户代理作为 然而,“指纹”是单个用户 可以简单地从 Safari 切换到 firefox 再次被视为独特的

理想情况下,指纹因此标记“机器”而不是浏览器或“ip”,但我无法想象这是如何实现的。

接受有关如何唯一地识别用户的想法/建议,以及您的方法有哪些优点/缺点。

What is the best way to generate a 'fingerprint' of user unique-ness in PHP?

For example:

  1. I could use a user's IP address
    as the 'fingerprint', however, there
    could be multiple other users on the same IP
  2. I could
    use the user's IP + user agent as
    the 'fingerprint', however, a single user
    could simply swap from safari to
    firefox and again be seen as being unique

Ideally, the fingerprint so label the 'machine' rather than browser or 'ip' but I can't think of how this is achievable.

Open to ideas/suggestions of how you uniquely identify your users, and what advantages/disadvantages your method has.

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

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

发布评论

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

评论(4

红焚 2024-10-07 09:39:23

最简单和最好的方法:使用 phps 会话管理 - 每个客户端都是给定一个 ID,存储在 cookie 中(如果启用)或作为每个链接和表单上的 get 变量给出(或者您可以自己设置 cookie)。但是,这只是浏览器的“指纹”——如果用户更改浏览器、删除 cookie 或其他任何内容,您将无法再识别它。

通过 IP 地址识别每个客户端通常是个坏主意,而且行不通。使用同一路由器的客户端将具有相同的 IP 地址 - 通过代理池连接的客户端在每次页面加载时可能会具有另一个 IP 地址。

如果您需要一个无法由客户端以简单方式操作的解决方案,请尝试执行以下操作的组合,使用客户端浏览器支持的所有内容,并在每个页面加载时对它们进行比较:

  • “正常”HTTP Cookie
  • 本地共享对象 (Flash Cookie)
  • 以自动生成、强制缓存的 PNG 的 RGB 值存储 cookie,使用 HTML5 Canvas 标签读取像素 (cookie) 回传
  • 存储 cookie 并读出网络历史记录
  • 在 HTTP ETag 中存储 cookie
  • Internet Explorer userData存储
  • HTML5 会话存储
  • HTML5 本地存储
  • HTML5 全局存储
  • HTML5 通过 SQLite 的数据库存储

有一个名为 evercookie 的解决方案,它实现了所有的这个。

Easiest and best way: use phps session-management - every client is given an ID, stored in a cookie (if enabled) or given as a get-variable on every link and form (alternatively you could set a cookie on your own). But, this only "fingerprints" the browser - if the user changes his browser, deletes his cookies or whatever, you can't identify it anymore.

Identifying every client by IP address is usually a bad idea and won't work. Clients that use the same router will have the same IP addresses - clients connected through a proxy-pool could have another IP address with every page load.

If you need a solution that can't be manipulated by the client in an easy way, try to do a combination of the following, using all that are supported by the clients browser and compare them on each page-load:

  • "normal" HTTP Cookies
  • Local Shared Objects (Flash Cookies)
  • Storing cookies in RGB values of auto-generated, force-cached PNGs using HTML5 Canvas tag to read pixels (cookies) back out
  • Storing cookies in and reading out Web History
  • Storing cookies in HTTP ETags
  • Internet Explorer userData storage
  • HTML5 Session Storage
  • HTML5 Local Storage
  • HTML5 Global Storage
  • HTML5 Database Storage via SQLite

There's a solution called evercookie that implements all of this.

下雨或天晴 2024-10-07 09:39:23

还有其他一些事情需要考虑,用户的公共 IP 地址在每次页面加载时也可能会发生变化。
有多个组织在其路由器中交换公共 IP 以平衡流量。

There's something else to take in account, the public IP Address of a user is something that also can change in every page load.
There are multiple organizations that switch public IP's in they routers to balance traffic.

紅太極 2024-10-07 09:39:23

不能保证达到 100% 的可靠性,但结合一些常用方法可以给您带来有意义的结果

  • 用户通常不会切换浏览器。为了达到工程完美而使算法过于复杂是不值得的。
  • 如果您可以预期多个用户来自同一 IP,那么您肯定属于前 100 名网站。别以为这是针对你个人的,但你只是没那么受欢迎。

采取最简单可行的路线,并在必要时随着时间的推移进行调整。

Achieving 100% reliability is not guaranteed, but combining some common methods can give you meaningful results

  • Users generally don't switch browsers. Over-complication in your algorithm only to reach engineering perfection is not worth the effort.
  • You certainly belong to the top 100 websites if you can expect multiple users from the same IP. Don't take it personal, but you're just not that popular.

Take the simplest possible route that could work and adjust over time if it seems necessary.

心凉怎暖 2024-10-07 09:39:23

我有三台不同的计算机、各种手持设备,其中许多安装了不同的浏览器。我在家里交替使用所有这些,并将它们带到其他地方,所以基本上,在不同的 IP 地址上。我想指出的是,如果您的目标是阻止某人,那么对浏览器或机器进行指纹识别永远不会是万无一失的。

我建议您采取不同的方法。根据您所掌握的非决定性信息来判断您被禁止的用户的身份(如果是不常见的情况,则为相同的 IP 或相同的用户代理,或者一些 javascript 浏览器指纹识别方法,例如可用字体、可用插件、非标准窗口大小等),并要求那些可疑的访问者进行某种更高形式的身份验证——例如使用 Facebook、Google+ 或 Twitter 进行 oauth。然后您可以查看该社交媒体帐户是否真实,或者只是为了规避而创建的。还有电话验证 API,以防您的用户群不熟悉社交媒体,并且取决于用户不规避禁令对您的价值有多大。

I have three different computers, various handheld devices, and many of them have different browsers installed. I use all these interchangeably at home take them with me other places so, basically, on various IP addresses. What I'm trying to point out is that fingerprinting a browser or a machine for that matter is never going to be foolproof if your goal is to block a person.

I recommend you take a different approach. Judge based on the inconclusive information you have available that suggests the identity of your banned user (same IP or same user-agent if it's a uncommon one or else some of the javascript browser fingerprinting methods such as available fonts, available plugins, non-standard window size, etc.) and require of those suspect visitors some higher form of identity verification -- such as oauth with Facebook, Google+, or Twitter. Then you can look to see if that social media account is genuine or created just to circumvent. There are also phone verification APIs in case your user base isn't social-media savvy and depending on how valuable it is to you that users don't circumvent banning.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文