我需要找出一种方法,唯一地识别每台计算机访问我正在创建的网站。有人有什么建议吗?
因为我想解决方案工作在所有机器和所有浏览器(在合理的范围内),我试图使用javascript创建一个解决方案。
饼干可不行。
我需要基本上创建一个guid的能力,这是唯一的计算机和可重复的,假设没有硬件变化发生在计算机上。我正在考虑的方向是获得网卡的MAC和这种性质的其他信息,这将id访问网站的机器。
我需要找出一种方法,唯一地识别每台计算机访问我正在创建的网站。有人有什么建议吗?
因为我想解决方案工作在所有机器和所有浏览器(在合理的范围内),我试图使用javascript创建一个解决方案。
饼干可不行。
我需要基本上创建一个guid的能力,这是唯一的计算机和可重复的,假设没有硬件变化发生在计算机上。我正在考虑的方向是获得网卡的MAC和这种性质的其他信息,这将id访问网站的机器。
当前回答
假设您不希望用户拥有控制权,那么您就不能这样做。网络并不是这样工作的,你能期望的最好的是一些启发式。
如果你可以强迫访问者安装一些软件并使用TCPA,你可能会成功。
其他回答
与前面的解决方案一样,cookie是一个很好的方法,但要注意它们可以识别浏览器。如果我先用火狐浏览器访问一个网站,然后再用ie浏览器访问,两次访问都会分别存储cookie。一些用户也禁用cookie(但更多的人禁用JavaScript)。
另一种需要考虑的方法是IP和主机名标识(请注意,对于拨号/非静态IP用户,这些可能有所不同,AOL也使用通用IP)。然而,由于这只识别网络,这可能不像cookie那样工作。
有一种流行的方法叫做“画布指纹”,在这篇科学文章《网络永不遗忘》中有描述: 野外的持久跟踪机制。一旦你开始寻找它,你会惊讶于它被使用的频率。该方法创建一个唯一的指纹,该指纹对于每个浏览器/硬件组合都是一致的。
本文还介绍了其他持久跟踪方法,如evercookie、respawning http和Flash cookie以及cookie同步。
更多关于画布指纹的信息:
完美像素:HTML5中的指纹画布 https://en.wikipedia.org/wiki/Canvas_fingerprinting
这些人开发了一种指纹识别方法,可以非常准确地识别用户:
https://panopticlick.eff.org/static/browser-uniqueness.pdf
We investigate the degree to which modern web browsers are subject to “device fingerprinting” via the version and configuration information that they will transmit to websites upon request. We implemented one possible fingerprinting algorithm, and collected these fingerprints from a large sample of browsers that visited our test side, panopticlick.eff.org. We observe that the distribution of our finger- print contains at least 18.1 bits of entropy, meaning that if we pick a browser at random, at best we expect that only one in 286,777 other browsers will share its fingerprint. Among browsers that support Flash or Java, the situation is worse, with the average browser carrying at least 18.8 bits of identifying information. 94.2% of browsers with Flash or Java were unique in our sample.
通过观察回访用户,我们估计浏览器指纹随时间变化的速度。在我们的样本中,指纹变化很大 很快,但即使是一个简单的启发式通常也能猜出指纹是先前观察到的浏览器的“升级”版本 指纹,99.1%的猜测正确率和假阳性率只有 0.86%。
We discuss what privacy threat browser fingerprinting poses in practice, and what countermeasures may be appropriate to prevent it. There is a tradeoff between protection against fingerprintability and certain kinds of debuggability, which in current browsers is weighted heavily against privacy. Paradoxically, anti-fingerprinting privacy technologies can be self- defeating if they are not used by a sufficient number of people; we show that some privacy measures currently fall victim to this paradox, but others do not.
假设您不希望用户拥有控制权,那么您就不能这样做。网络并不是这样工作的,你能期望的最好的是一些启发式。
如果你可以强迫访问者安装一些软件并使用TCPA,你可能会成功。
简介
我不知道是否有一种方法可以单独使用浏览器来唯一地识别机器。主要原因有:
您需要在用户计算机上保存数据。这个数据可以是 用户可以随时删除。除非你有办法重现这个 每台机器的数据都是独一无二的,那么你就会陷入困境。 验证。您需要防范欺骗、会话劫持等。
即使有不使用cookie的方法来跟踪计算机,也总有办法绕过它,软件会自动做到这一点。如果你真的需要在计算机上跟踪一些东西,你就必须写一个本地应用程序(苹果商店/安卓商店/ Windows程序等)。
我可能不能给你你问的问题的答案,但我可以告诉你如何实现会话跟踪。使用会话跟踪,您可以尝试跟踪浏览会话,而不是计算机访问您的网站。通过跟踪会话,您的数据库模式将如下所示:
sesssion:
sessionID: string
// Global session data goes here
computers: [{
BrowserID: string
ComputerID: string
FingerprintID: string
userID: string
authToken: string
ipAddresses: ["203.525....", "203.525...", ...]
// Computer session data goes here
}, ...]
基于会话跟踪的优点:
对于已登录的用户,您总是可以从用户的用户名/密码/电子邮件生成相同的会话id。 您仍然可以使用sessionID跟踪来宾用户。 即使几个人使用同一台电脑(例如网吧),如果他们登录,你也可以分别跟踪他们。
基于会话跟踪的缺点:
会话是基于浏览器而不是基于计算机的。如果一个用户使用2个不同的浏览器,它将导致2个不同的会话。如果这是一个问题,你可以停止阅读这里。 如果用户没有登录,会话将过期。如果用户没有登录,那么他们将使用一个来宾会话,如果用户删除cookie和浏览器缓存,该会话将失效。
实现
有许多方法可以实现这一点。我不认为我能涵盖所有,我只列出我最喜欢的,这将使这成为一个固执己见的答案。记住这一点。
基础知识
我将使用所谓的永久cookie来跟踪会话。即使用户删除了他的cookie或更新了他的浏览器,这些数据也会自动恢复。然而,当用户删除他们的cookie和浏览缓存时,它将无法存活。
为了实现这一点,我将使用浏览器缓存机制(RFC), WebStorage API (MDN)和浏览器cookie (RFC,谷歌Analytics)。
法律
为了使用跟踪id,您需要将它们添加到您的隐私政策和使用条款中,最好是在跟踪子标题下。我们将在两个文档上使用以下键。cookie和window.localStorage:
_ga:谷歌分析数据 __utma:谷歌分析跟踪cookie 席德:SessionID
确保在所有使用跟踪功能的页面上包含指向您的隐私政策和使用条款的链接。
会话数据存储在哪里?
您可以将会话数据存储在网站数据库中或用户计算机上。因为我通常在使用第三方应用程序(谷歌Analytics / Clicky / etc)的较小网站(让超过10,000个连续连接)上工作,所以对我来说,最好将数据存储在客户端计算机上。这样做有以下优点:
没有数据库查找/开销/负载/延迟/空间等。 用户可以随时删除他们的数据,而无需给我写烦人的电子邮件。
优缺点:
必须对数据进行加密/解密和签名/验证,这会在客户端和服务器上产生cpu开销(不是很糟糕)。 当用户删除他们的cookie和缓存时,数据将被删除。(这是我真正想要的) 当用户离线时,数据无法用于分析。(仅针对当前浏览用户的分析)
UUIDS
BrowserID: Unique id generated from the browsers user agent string. Browser|BrowserVersion|OS|OSVersion|Processor|MozzilaMajorVersion|GeckoMajorVersion ComputerID: Generated from users IP Address and HTTPS session key. getISP(requestIP)|getHTTPSClientKey() FingerPrintID: JavaScript based fingerprinting based on a modified fingerprint.js. FingerPrint.get() SessionID: Random key generated when user 1st visits site. BrowserID|ComputerID|randombytes(256) GoogleID: Generated from __utma cookie. getCookie(__utma).uniqueid
机制
前几天,我和女朋友一起看wendy williams的节目,主持人建议她的观众至少每月删除一次浏览器历史记录,这让我完全震惊了。删除浏览器历史记录通常有以下效果:
删除访问网站的历史记录。 删除cookie和窗口。localStorage (aww man)。
Most modern browsers make this option readily available but fear not friends. For there is a solution. The browser has a caching mechanism to store scripts / images and other things. Usually even if we delete our history, this browser cache still remains. All we need is a way to store our data here. There are 2 methods of doing this. The better one is to use a SVG image and store our data inside its tags. This way data can still be extracted even if JavaScript is disabled using flash. However since that is a bit complicated I will demonstrate the other approach which uses JSONP (Wikipedia)
Example.com/assets/js/tracking.js(实际上是tracking.php)
var now = new Date();
var window.__sid = "SessionID"; // Server generated
setCookie("sid", window.__sid, now.setFullYear(now.getFullYear() + 1, now.getMonth(), now.getDate() - 1));
if( "localStorage" in window ) {
window.localStorage.setItem("sid", window.__sid);
}
现在我们可以在任何时候获得会话密钥:
窗口。__sid || window.localStorage.getItem("sid") || getCookie("sid") || "" "
我如何让跟踪。js坚持在浏览器?
我们可以使用Cache-Control, Last-Modified和ETag HTTP头来实现这一点。我们可以使用SessionID作为etag头的值:
setHeaders({
"ETag": SessionID,
"Last-Modified": new Date(0).toUTCString(),
"Cache-Control": "private, max-age=31536000, s-max-age=31536000, must-revalidate"
})
Last-Modified头文件告诉浏览器这个文件基本上从未被修改过。cache - control告诉代理和网关不缓存文档,但告诉浏览器缓存1年。
下次浏览器请求文档时,它将发送If-Modified-Since和If-None-Match标头。我们可以使用它们返回一个304 Not Modified响应。
example.com/assets/js/tracking.php
$sid = getHeader("If-None-Match") ?: getHeader("if-none-match") ?: getHeader("IF-NONE-MATCH") ?: "";
$ifModifiedSince = hasHeader("If-Modified-Since") ?: hasHeader("if-modified-since") ?: hasHeader("IF-MODIFIED-SINCE");
if( validateSession($sid) ) {
if( sessionExists($sid) ) {
continueSession($sid);
send304();
} else {
startSession($sid);
send304();
}
} else if( $ifModifiedSince ) {
send304();
} else {
startSession();
send200();
}
现在,每次浏览器请求trace .js时,我们的服务器都会响应一个304 Not Modified结果,并强制执行trace .js的本地副本。
我还是不明白。给我解释一下
假设用户清除了他们的浏览历史并刷新了页面。用户计算机上只剩下浏览器缓存中的tracking.js副本。当浏览器请求tracking.js时,它会收到一个304 Not Modified响应,这导致它执行它收到的第一个版本的tracking.js。trace .js执行并恢复被删除的SessionID。
验证
假设Haxor X在客户仍在登录时窃取了他们的cookie。我们如何保护他们?密码学和浏览器指纹来拯救。还记得我们最初对SessionID的定义是:
BrowserID|ComputerID|randomBytes(256)
我们可以更改为:
Timestamp|BrowserID|ComputerID|encrypt(randomBytes(256), hk)|sign(Timestamp|BrowserID|ComputerID|randomBytes(256), hk)
Where hk = sign(时间戳|BrowserID|ComputerID, serverKey)。
现在我们可以使用下面的算法来验证我们的SessionID:
if( getTimestamp($sid) is older than 1 year ) return false;
if( getBrowserID($sid) !== createBrowserID($_Request, $_Server) ) return false;
if( getComputerID($sid) !== createComputerID($_Request, $_Server) return false;
$hk = sign(getTimestamp($sid) + getBrowserID($sid) + getComputerID($sid), $SERVER["key"]);
if( !verify(getTimestamp($sid) + getBrowserID($sid) + getComputerID($sid) + decrypt(getRandomBytes($sid), hk), getSignature($sid), $hk) ) return false;
return true;
为了让哈克索的攻击奏效他们必须:
Have same ComputerID. That means they have to have the same ISP provider as victim (Tricky). This will give our victim the opportunity to take legal action in their own country. Haxor must also obtain HTTPS session key from victim (Hard). Have same BrowserID. Anyone can spoof User-Agent string (Annoying). Be able to create their own fake SessionID (Very Hard). Volume atacks won't work because we use a time-stamp to generate encryption / signing key so basically its like generating a new key for each session. On top of that we encrypt random bytes so a simple dictionary attack is also out of the question.
我们可以通过转发GoogleID和FingerprintID(通过ajax或隐藏字段)并根据它们进行匹配来改进验证。
if( GoogleID != getStoredGoodleID($sid) ) return false;
if( byte_difference(FingerPrintID, getStoredFingerprint($sid) > 10%) return false;