问题描述
GUID 在为 Web 应用程序创建会话密钥时被大量使用.我一直想知道这种做法的安全性.由于 GUID 是根据来自机器的信息、时间以及其他一些因素生成的,因此猜测未来可能出现的 GUID 的难度有多大.假设您启动了 1000 或 10000 个新会话,以获取生成的 GUID 的良好数据集.这是否会使生成可能用于另一个会话的 GUID 变得更容易.您甚至不必猜测特定的 GUID,只需继续尝试可能在特定时间段生成的 GUID.
GUIDs get used a lot in creating session keys for web applications. I've always wondered about the safety of this practice. Since the GUID is generated based on information from the machine, and the time, along with a few other factors, how hard is it to guess of likely GUIDs that will come up in the future. Let's say you started 1000, or 10000 new sessions, to get a good dataset of the GUIDs being generated. Would this make it any easier to generate a GUID that might be used for another session. You wouldn't even have to guess a specific GUID, but just keep on trying GUIDs that might be generated at a specific period of time.
推荐答案
.NET Web 应用程序调用 Guid.NewGuid() 来创建 GUID,而 GUID 最终调用 CoCreateGuid() COM 函数在堆栈中更深几帧.
.NET Web Applications call Guid.NewGuid() to create a GUID which is in turn ends up calling the CoCreateGuid() COM function a couple of frames deeper in the stack.
来自 MSDN 库:
CoCreateGuid 函数调用RPC 函数 UuidCreate,它创建一个 GUID,一个全球唯一的 128 位整数.使用 CoCreateGuid 函数当你需要一个绝对独特的您将用作的号码分布式中的持久标识符环境.以非常高的程度可以肯定,这个函数返回一个唯一值——没有其他调用,在相同或任何其他系统(联网与否),应返回相同的值.
如果您查看 UuidCreate 上的页面:
And if you check the page on UuidCreate:
UuidCreate 函数生成一个UUID 无法追溯到以太网/令牌环地址生成它的计算机.它也不能与其他在同一台计算机上创建的 UUID.
最后一个包含句子是您问题的答案.所以我想说,除非 Microsoft 的实施中存在错误,否则很难猜测.
The last contains sentence is the answer to your question. So I would say, it is pretty hard to guess unless there is a bug in Microsoft's implementation.
这篇关于您猜出可能生成的 GUID 有多容易?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!