简体   繁体   English

如何从Web浏览器获取唯一的PC ID

[英]How to get a unique PC ID from a web browser

I have a web app that will be running n several specific target machines. 我有一个Web应用程序,它将运行几个特定的​​目标机器。 I could have the user select which machine he is on when he logs in, but that is prone to error. 我可以让用户在登录时选择他所在的机器,但这很容易出错。 Is there a way I can get some unique ID from each PC, store those in a database on my server and then when someone logs in from a particular machine, identify that machine? 有没有办法可以从每台PC获取一些唯一的ID,将它们存储在我的服务器上的数据库中,然后当有人从特定的机器登录时,识别该机器? I thought of IP address but those might change as well due to the nature of our deployment. 我想到了IP地址,但由于部署的性质,这些也可能会发生变化。 But is is critical that I know which machine the system is running on. 但至关重要的是,我知道系统运行的是哪台机器。

Note: I am not trying to determine the machine code of a web user's machine as that would be a privacy violation. 注意:我不是要确定Web用户计算机的机器代码,因为这会违反隐私。 I KNOW my machines so I was wanting to tie them to the database somehow. 我知道我的机器所以我想以某种方式将它们绑定到数据库。 This also acts as security for me as I can reject logins from unknown machines. 这对我来说也起到了安全作用,因为我可以拒绝来自未知机器的登录。

Thanks for any ideas. 谢谢你的任何想法。 I am running Apache with Code Igniter 3 and Centos 6.5 我使用Code Igniter 3和Centos 6.5运行Apache

It's not possible without a client component, browser plugin or something similar. 没有客户端组件,浏览器插件或类似的东西是不可能的。 The closest alternatives are: 最接近的替代方案是:

  • using cookies; 使用cookies;
  • using client certificates; 使用客户证书;
  • using browser fingerprinting; 使用浏览器指纹识别;

each with their own disadvantages. 每个都有自己的缺点。

You could use this as a computer ID: 您可以将其用作计算机ID:

$computerId = $_SERVER['HTTP_USER_AGENT'].$_SERVER['LOCAL_ADDR'].$_SERVER['LOCAL_PORT'].$_SERVER['REMOTE_ADDR'];

It's not completely fool proof, as the values of $_SERVER can be faked, however it will still add an extra layer of security that does not rely on cookies. 这并不是完全万无一失的,因为$_SERVER的值可以伪造,但它仍然会添加一个不依赖于cookie的额外安全层。

The first time a user hits your site, identify their machine by IP address. 用户第一次访问您的站点时,请通过IP地址识别他们的计算机。 Then set a persistent cookie with a unique identifier of your choosing. 然后使用您选择的唯一标识符设置持久性cookie。

The next time they come to the site, you can identify them by the unique identifier cookie that you set previously. 下次他们访问该站点时,您可以通过之前设置的唯一标识符cookie来识别它们。

I would either 我要么

use a value like bin2hex(openssl_random_pseudo_bytes(512)) and set it as a cookie and then check for the cookie 使用像bin2hex(openssl_random_pseudo_bytes(512))类的值并将其设置为cookie然后检查cookie

or 要么

use IP based logging like (127.0.0.1) has typed hello 使用基于IP的日志记录(127.0.0.1)已键入hello

or 要么

MAC Addresses (php libraries for it) MAC地址(php库)

You can even try getting the MAC Address: 您甚至可以尝试获取MAC地址:

Use this class (https://github.com/BlakeGardner/php-mac-address) 使用这个类(https://github.com/BlakeGardner/php-mac-address)

This is a PHP class for MAC address manipulation on top of Unix, Linux and Mac OS X operating systems. 这是一个用于在Unix,Linux和Mac OS X操作系统之上进行MAC地址操作的PHP类。 it was primarily written to help with spoofing for wireless security audits. 它主要是为了帮助欺骗无线安全审计而编写的。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM