当前位置: 首页>>技术教程>>正文


如何为Ubuntu 10.04生成/etc/shadow兼容密码?

, , ,

问题描述

Ubuntu 10.04如何使用生成的密码?我知道他们使用SHA 512作为哈希算法,但是我认为已经完成了某种形式的加盐处理。我需要自己生成这样的密码。我怎样才能做到这一点?是否有用于此的命令行工具?

最佳方法

破解一个快速的python /perl /任何脚本并调用crypt(3)函数应该很简单。

The glibc2 version of this function supports additional encryption algorithms.

If salt is a character string starting with the characters "$id$" followed by
a string terminated by "$":

      $id$salt$encrypted

then instead of using the DES machine, id identifies the encryption method
used and this then determines how the rest of the password string is
interpreted.  The following values of id are supported:

      ID  | Method
      ---------------------------------------------------------
      1   | MD5
      2a  | Blowfish (not in mainline glibc; added in some
          | Linux distributions)
      5   | SHA-256 (since glibc 2.7)
      6   | SHA-512 (since glibc 2.7)

So $5$salt$encrypted is an SHA-256 encoded password and $6$salt$encrypted is
an SHA-512 encoded one.

"salt" stands for the up to 16 characters following "$id$" in the salt.  The
encrypted part of the password string is the actual computed password.  The
size of this string is fixed:

MD5     | 22 characters
SHA-256 | 43 characters
SHA-512 | 86 characters

The characters in "salt" and "encrypted" are drawn from the set [a-zA-Z0-9./].
In the MD5 and SHA implementations the entire key is significant (instead of
only the first 8 bytes in DES).

您仍然可以在默认为sha-512或其他版本的系统中的影子文件中使用md5密码。像工具makepasswd这样的命令可用于生成MD5哈希。

您可以使用mkpasswd,它奇怪地是Debian /Ubuntu上的whois软件包的一部分。 mkpasswd -m sha-512。 (找到here)

参考资料

本文由Ubuntu问答整理, 博文地址: https://ubuntuqa.com/article/11000.html,未经允许,请勿转载。