简体   繁体   English

记录注册用户的特定IP地址

[英]Log Specific IP address of a Registered User

How can I get the IP of someone and then check if this specific user has already created 2 users ? 如何获取某人的IP,然后检查该特定用户是否已创建2个用户?

Like, if this ip: xx.xx.xxx.xx has already successfully registered 2 users then cancel his third registration. 像,如果此IP地址:xx.xx.xxx.xx已成功注册2个用户,则取消其第三次注册。

How can I do that? 我怎样才能做到这一点?

As the IP address usually will change every day, and the person could obtain a new IP address while reconnecting to his provider or he could use a proxy your solution will not work. 由于IP地址通常每天都会更改,因此该人可以在重新连接到其提供者的同时获得新的IP地址,或者他可以使用代理,因此您的解决方案将无法使用。 Don't even try it! 甚至不要尝试!

Also note that multiple users can be members of a bigger network with one outer IP (like an university). 还要注意,多个用户可以是具有一个外部IP(例如大学)的更大网络的成员。 You would allow only one out of them to create an account. 您只允许其中一个创建一个帐户。

Your planned solution would lead to situations where valid users cannot create an account but hackers could easily circumvent the restriction and even better prevent others from creating an account. 您计划的解决方案将导致以下情况:有效用户无法创建帐户,但黑客可以轻松绕开限制,甚至更好地阻止其他人创建帐户。 Again, don't try this! 再次,不要尝试这个!

IP Address Information IP地址信息

First you should be looking in these two server variables for your client IP address, the first one below is normally the most accurate and commonly used, you might also want to use the second however be aware that this can be spoofed by your clients. 首先,您应该在这两个服务器变量中查找您的客户端IP地址,下面的第一个通常是最准确且最常用的变量,您可能还想使用第二个变量,但是请注意,这可能被您的客户端欺骗。

$_SERVER['REMOTE_ADDR'] // Normally here
$_SERVER['HTTP_X_FORWARDED_FOR'] // Sometimes if behind proxy

Next, IP addresses regularly change for internet clients for a few reasons; 接下来,由于一些原因,IP地址对于Internet客户端会定期更改。 dynamic IP's from ISP's broadband services, a users normal mobility on the internet, or people using evasive tactics to get past your IP limitation security (normally using a type of internet proxy service). 来自ISP宽带服务的动态IP,用户在Internet上的正常移动性,或使用规避策略来超越IP限制安全性的人员(通常使用一种Internet代理服务)。

Because of this you will normally want to store the IP when the users signs up, and also update this list each time that they login to keep a IP history for that user. 因此,您通常希望在用户注册时存储IP,并在每次登录时也更新此列表,以保留该用户的IP历史记录。

Next when another person signs up for your service you will need to compare their IP address to that of your database contents, however you need to be careful here. 接下来,当另一个人注册您的服务时,您需要将其IP地址与数据库内容的IP地址进行比较,但是在这里您需要小心。 There are plenty of valid reasons for a user sharing the same IP address, for example a work place or university will normally have thousands of users using a single public IP address. 用户共享相同的IP地址有很多充分的理由,例如,工作场所或大学通常会使用单个公共IP地址让成千上万的用户使用。

Fingerprinting 指纹识别

Finally, something that I know a few services do is try to capture more identifiable information from the client than just the public IP address that they are using. 最后,我知道一些服务所做的事情是尝试从客户端捕获比他们正在使用的公共IP地址更多的可识别信息。

For example from PHP you should be able to capture information such as the User Agent: 例如,从PHP您应该能够捕获诸如用户代理之类的信息:

Mozilla/5.0 (Macintosh; Intel Mac OS X 10_8_4) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/27.0.1453.116 Safari/537.36

Other information like timezone, HTTP supported headers, flash version, system fonts etc... can be captured using a mizture of PHP, Flash and Javascript. 可以使用PHP,Flash和Javascript捕获其他信息,例如时区,支持的HTTP标头,Flash版本,系统字体等。 Here is a great website that will give more information on this: http://panopticlick.eff.org 这是一个很棒的网站,它将提供有关此的更多信息: http : //panopticlick.eff.org

As you can see this information saved into your database can create quite an accurate and unique representation of a user's computer, a fingerprint. 正如您所看到的,将这些信息保存到数据库中可以创建用户计算机的相当准确且唯一的表示形式,即指纹。 Even if your users change their IP address if you see the same combination of fingerprints in quick succession there is probably something dodgy going on. 即使您的用户连续快速地看到相同的指纹组合而更改了其IP地址,也可能会发生一些麻烦。

Thoughts 思想

So it really depends on your application, some you will want to just try discourage people from signing up for multiple accounts in which case simply logging the IP address on signup and comparing would do the job. 因此,这实际上取决于您的应用程序,您将只想尝试阻止人们注册多个帐户,在这种情况下,只需在注册时记录IP地址并进行比较即可。

Others like Online games you want to really ensure that no person would ever be allowed to create more than one account, in which case your going to need to do host fingerprinting and have some cleaver algorithms to try score how unique a specific person is, and their likely hood of been one of your other users alter logins. 其他人喜欢在线游戏,您想要真正确保任何人都不能创建多个帐户,在这种情况下,您将需要进行主机指纹识别,并需要使用一些砍刀算法来尝试计算特定人的独特性,以及他们可能是您的其他用户之一改变了登录名。

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

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