使用 LUKS 收到“此密码无可用密钥”

2024-02-12

我的笔记本电脑有一个加密磁盘。经过一个apt upgrade几个小时后,强制关闭我的密码不再解密我的磁盘。

我从 Debian Live USB 棒启动并尝试了几件事:

  1. Can I decrypt the partition with my passphrase from the live os? enter image description here Answer: No.
  2. Is it a problem with the keyboard layout? enter image description here Answer: No.
  3. Is the partition still an encrypted one? enter image description here Answer: Yes it is and there is still one keyslot.
  4. Is there a problem visible when looking at hexdump output? enter image description here Answer: No.
  5. Is there maybe a problem visibile when looking at the hexdump configuration output? enter image description here Answer: Apart from the fact that a few blog posts say that everything above 1000 should be random characters: No.

我没有 LUKS 标头的备份。我的密码有效了一年多。我如何访问或挽救我的数据?

提前致谢, 卢克


最有可能的是你输错了密码,因为我也遇到了类似的问题并归咎于升级。

您可以转储标头并尝试粗暴地强制它。

以下步骤会有所帮助。

  1. 确认您拥有正确的设备:

    sudo cryptsetup isLuks /dev/sda3 -v
    
  2. 验证标头:

    sudo cryptsetup luksDump /dev/sda3
    
  3. 尝试最初的几个密码(考虑添加--debug以获得更多输出):

    sudo cryptsetup luksOpen --test-passphrase /dev/sda3
    

    Or: tcryptDump,但应该没有什么区别。

  4. 考虑备份标头:

    sudo cryptsetup luksHeaderBackup /dev/sda3 --header-backup-file luksHeader.bin
    

    或者运行(将 count 替换为有效负载偏移在标头转储中找到):

     dd if=/dev/sda3 of=luksHeader.bin bs=512 count=4096
    

    您还可以考虑使用备份整个设备dd.

  5. 使用头文件尝试不同的密码:(比使用实际设备更快)

    sudo cryptsetup luksOpen --test-passphrase luksHeader.bin
    

残酷的力量

拥有一个小头文件(按照上述步骤),您可以尝试粗暴地强制它。

假设您知道原始密码,请创建潜在密码及其排列的列表passes.txt(通过以下方式使列表唯一sort -ou passes.txt).

在 shell 中,您可以使用以下脚本来尝试这些组合:

set -x
while read pass; do
  printf $pass | cryptsetup luksOpen --test-passphrase luksHeader.bin $@ && echo Success && break;
done < passes.txt

Notes:

  • 由于文件很小,您可以将其扩展到许多机器。
  • 考虑添加--key-slot 0以便更快地进行检查。
  • 您可以尝试覆盖--pbkdf-force-iterations(检查标头转储中有多少个),但很可能没有帮助。

Live CD

如果您认为这是由于升级而发生的,请使用不同的Ubuntu https://ubuntu.com/downloadLive CD 使用上述命令(Ubuntu 16、18、20 等)。

从 USB/CD 启动,或安装虚拟机虚拟盒(创建 Ubuntu VM,然后加载 ISO 以从中启动)。

将物理设备连接到虚拟机虚拟盒(不建议):

  • 在您新创建的 Ubuntu VM 中,附加 Ubuntu 的 Live CD.iso file.
  • Use VBoxManage internalcommands createrawvmdk命令来创建.vmdk指向真实设备的文件。附上这些.vmdk进入虚拟机(在启动之前)。
  • 如果您的用户在运行期间无法访问这些特殊设备,请运行VirtualBoxVM作为 root(也不推荐)。

最后步骤,复制头文件,然后使用旧版本测试密码cryptsetup (cryptsetup --version).

Mounting

成功后,使用以下命令挂载文件系统:

sudo cryptsetup isLuks /dev/sdb5 -v
sudo cryptsetup luksOpen /dev/sdb5 newhd
sudo lvscan # Check if LVs are active.
sudo vgchange -ay # Activate LVs if not active.
sudo lvdisplay # List logical volumes (note the LV Path).
sudo mount /dev/ubuntu-vg/root /mnt
mount # List mounted filesystems.
xdg-open /mnt # Open in file explorer

其他有用的命令:

sudo lvmdiskscan # List devices.
sudo vgdisplay # Display volume group information.
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

使用 LUKS 收到“此密码无可用密钥” 的相关文章

随机推荐