您可以从 UUID 中提取什么类型的数据?
我知道我们可以轻松提取 uuid 版本号。有没有可靠的方法来提取时间戳、MAC 地址等信息?
谢谢!
I know that we could easily extract the uuid version number. Is there a reliable way to extract information like timestamp, MAC address?
Thanks!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(6)
符合标准的 UUID 可能是多个变体之一,它看起来像这样:
AAAAAAAA-BBBB-CCCC-DDDD-FFFFFFFFFFFF
DDDD 部分的第一个(十六进制)数字决定了变体。
如果它是 8,9,A,B 之一,则符合当前规范
(0-7保留用于向后兼容,C、D保留给Microsoft,E、F保留供将来使用)
如果符合当前规范,请检查确定UUID版本的CCCC部分的第一位数字:
名称(SHA-1 哈希)版本 4 是随机选择的。
版本 3 和版本 5 是通过散列并丢弃一些位生成的,这意味着您基本上没有机会从中恢复任何信息。有关如何构建它的详细信息,请参阅 RFC4122 或 UUID 生成器网页。
我找不到任何版本 2 UUID,因此我没有检查如何提取数据。
版本 1 是根据时间戳和当前主机 MAC 地址生成的。
(如果您设置 MAC 地址的“广播/多播”位,该标准还允许使用随机地址。)
以下 perl 片段从版本 1 uuid 解析 MAC 地址和时间:
最后但并非最不重要的一点是,有是几个分配的 UUID,例如 GPT 分区。
A standard-conforming UUID may be one of several variants, it looks like this:
AAAAAAAA-BBBB-CCCC-DDDD-FFFFFFFFFFFF
The first (hex)digit of the DDDD part determines the variant.
If it is one of 8,9,A,B it is conforming to the current spec
(0-7 are reserved for backward compatibility, C,D are reserved for Microsoft, and E,F are reserved for future use)
If it conforms to the current spec, check the first digit of the CCCC part which determines the UUID version:
Version 4 is simply randomly chosen.
Version 3 and 5 are generated by hashing and throwing away some bits which means you have basically no chance in recovering any information from it. Details on how to build it can be found in RFC4122 or at the UUID Generator webpage.
I could not find any version 2 UUIDs so I didn't check how to extract the data.
Version 1 is generated from a time-stamp and current host MAC address.
(The standard also allows to use a random address instead if you set the "broadcast/multicast" bit of the MAC address.)
The following perl snipped parses the MAC address and Time from a version 1 uuid:
And last but not least, there are several assigned UUIDs, for example for GPT partitions.
不一定是可靠的方式,因为根据 UUID 的类型,它可能完全由随机位生成,或者基于时间戳,或者基于 MAC 地址。因此,您也许可以获得其中一些信息,但不能保证您可以获得任何信息。
官方参考是 RFC 4122,它可能会为您提供足够的信息来提取数据,尽管您可能不应该过于依赖它。
Not necessarily a reliable way, because depending on the kind of UUID it is, it may be generated totally from random bits, or be timestamp-based, or be based on the MAC address. So you may be able to get some of that information, but you can't guarantee you can get anything.
The official reference for this is RFC 4122, which should probably give you enough information to extract data, although you probably shouldn't rely on it too heavily.
OSSP uuid工具可以解码所有版本的UUID。在基于 Debian 的 Linux 系统上,您可以使用 apt-get install uuid 来安装它;对于其他发行版,包名称可能不同。
要解码 UUID,请使用
-d
(解码)标志:对于版本 1 UUID,这给出了 MAC 地址和时间戳 - 因为这是 v1 uuid 中的内容。
The OSSP uuid tool can decode UUIDs of all versions. On Debian-based Linux systems you can use
apt-get install uuid
to install it; for other distributions, the package name might be different.To decode a UUID, use the
-d
(decode) flag:For version 1 UUIDs, this gives the MAC address and timestamp -- since that's what's in a v1 uuid.
我知道我们可以轻松提取 uuid 版本号。有没有可靠的方法来提取时间戳、MAC 地址等信息?
是的,是的;如果 UUID 是版本 1 或版本 2(如 RFC 4122 中所述)。还有一个替代(非 RFC 4122)版本 4,称为“COMB”,其中包含可以解析的时间戳(以及随机值),并且可以显示创建日期/时间。
奖励:Mahonri Moriancumer 的 UUID 和 GUID 生成器和取证。
I know that we could easily extract the uuid version number. Is there a reliable way to extract information like timestamp, MAC address?
Yes, and Yes; if the UUID is version 1 or version 2 (as described in RFC 4122). There is also an alternate (non-RFC 4122) version 4, dubbed "COMB" that includes a time-stamp (as well as random values) that can be parsed, and the creation date/time can be revealed.
Bonus: Mahonri Moriancumer's UUID and GUID Generator and Forensics.
如果它是版本 1 UUID,则 MAC 地址将为最后 12 位十六进制数字。
If it's a version 1 UUID, the MAC address will be the last twelve hex digits.
您可以查看 Uuid 的版本,但只有在确定 Uuid 有效的情况下才可以信任(请参阅 https://www.rfc-editor.org/rfc/rfc4122)。该版本将告诉您拥有哪种 Uuid,并使用它您可以提取特定的信息位。
You could look at the version of the Uuid, but that can only be trusted if you are sure the Uuid is valid (see https://www.rfc-editor.org/rfc/rfc4122). The version will tell you what kind of Uuid you have, and using that you can extract specific bits of information.