尽管全盘加密,仍可恢复已删除的文件

信息安全 加密
2021-08-12 04:01:12

这可能是一个愚蠢的问题,但我还是会继续问。

假设我在 Windows 上,我创建了一个文件 secret_financial_plan.txt,其中存储了我公司所有的黑市金融业务。完成所有操作后,我删除文件并清空回收站以掩盖我的踪迹。

几天后,我意识到 Windows 中“永久”删除的文件很容易恢复。因此,我决定在我的设备上应用全盘加密 (FDE),方法是切换到 Linux 并使用 LUKS,或者在 Windows 中使用 Veracrypt 或使用其他 FDE 软件加密驱动器。无法访问解密密钥的取证专家是否有可能在应用 FDE 后恢复 secret_financial_plan.txt 文件?

4个回答

除了Moshe 的回答,我将提供一个 LUKS 的例子,因为有些人似乎不相信。此外,请参阅此处了解为什么覆盖可能不是 100% 有效(尽管它肯定有帮助)。

例子

创建一个稀疏文件,创建一个文件系统,然后挂载它:

$ truncate -s 100G /tmp/device
$ mkfs.ext4 /tmp/device
$ sudo mount /tmp/device /mnt
$ sudo chown user:user -R /mnt

制作一些机密文件:

$ echo "super secret data" > /mnt/secret
$ echo "super secret data" > /mnt/confidential
$ echo "super secret data" > /mnt/top-secret

获取文件的 inode:

$ ls -li /mnt
total 28
13 -rw-rw-r-- 1 user user    18 Nov 10 11:34 confidential
11 drwx------ 2 user user 16384 Nov 10 11:33 lost+found
12 -rw-rw-r-- 1 user user    18 Nov 10 11:34 secret
14 -rw-rw-r-- 1 user user    18 Nov 10 11:34 top-secret

确保将文件写入磁盘,然后获取 inode 的范围:

$ sync /mnt/*
$ debugfs -R "stat <12>" /tmp/device
...
EXTENTS:
(0):33793
$ debugfs -R "stat <13>" /tmp/device
...
EXTENTS:
(0):33794
$ debugfs -R "stat <14>" /tmp/device
...
EXTENTS:
(0):33795

检查这些块以确保数据存在:

$ dd if=/tmp/device bs=4096 skip=33793 count=1
super secret data
1+0 records in
1+0 records out
4096 bytes (4.1 kB, 4.0 KiB) copied, 1.9034e-05 s, 215 MB/s
$ dd if=/tmp/device bs=4096 skip=33794 count=1
super secret data
1+0 records in
1+0 records out
4096 bytes (4.1 kB, 4.0 KiB) copied, 1.888e-05 s, 217 MB/s
$ dd if=/tmp/device bs=4096 skip=33795 count=1
super secret data
1+0 records in
1+0 records out
4096 bytes (4.1 kB, 4.0 KiB) copied, 7.1178e-05 s, 57.5 MB/s

删除文件:

$ rm /mnt/secret
$ rm /mnt/confidential
$ rm /mnt/top-secret
$ ls -l /mnt
total 16
drwx------ 2 user user 16384 Nov 12 17:34 lost+found

使用 LUKS 格式化设备,然后创建一个新的文件系统:

$ sudo umount /mnt
$ sudo cryptsetup luksFormat /tmp/device

WARNING!
========
This will overwrite data on /tmp/device irrevocably.

Are you sure? (Type uppercase yes): YES
Enter passphrase:
Verify passphrase:

$ sudo cryptsetup luksOpen /tmp/device encrypted_device
Enter passphrase for /tmp/device:

$ sudo mkfs.ext4 /dev/mapper/encrypted_device
mke2fs 1.42.13 (17-May-2015)
Creating filesystem with 26213888 4k blocks and 6553600 inodes
Filesystem UUID: 279e6c3b-a183-4a94-b06e-78db1665b2a0
Superblock backups stored on blocks: 
    32768, 98304, 163840, 229376, 294912, 819200, 884736, 1605632, 2654208, 
    4096000, 7962624, 11239424, 20480000, 23887872

Allocating group tables: done                            
Writing inode tables: done                            
Creating journal (32768 blocks): done
Writing superblocks and filesystem accounting information: done

现在我们有了一个新的文件系统:

$ sudo mount /dev/mapper/encrypted_device /mnt
$ sudo ls -lR /mnt
/mnt:
total 16
drwx------ 2 root root 16384 Nov 10 11:37 lost+found

/mnt/lost+found:
total 0

但是我们的秘密数据还在吗?

$ dd if=/tmp/device bs=4096 skip=33793 count=1
super secret data
1+0 records in
1+0 records out
4096 bytes (4.1 kB, 4.0 KiB) copied, 1.8944e-05 s, 216 MB/s
$ dd if=/tmp/device bs=4096 skip=33794 count=1
super secret data
1+0 records in
1+0 records out
4096 bytes (4.1 kB, 4.0 KiB) copied, 2.2056e-05 s, 186 MB/s
$ dd if=/tmp/device bs=4096 skip=33795 count=1
super secret data
1+0 records in
1+0 records out
4096 bytes (4.1 kB, 4.0 KiB) copied, 8.7082e-05 s, 47.0 MB/s

结论

除非您擦除磁盘,否则至少有一些旧数据可能未加密。

归结为以下问题:secret_financial_plan.txt的内容的明文字节是否仍存储在磁盘上?

让我们来看看这些步骤:

我创建了一个文件 secret_financial_plan.txt,我在其中存储了我公司的所有黑市金融业务

明文写入磁盘

我删除文件并清空回收站以掩盖我的踪迹。

文件被重命名,然后 NTFS 主文件表中的条目被标记为已删除。明文仍在磁盘上。

我决定在我的设备上应用全盘加密 (FDE)

那里有不同的配置选项。如果您指定加密整个磁盘,包括未分配的空间,明文字节将被加密数据覆盖。如果您只加密分配的空间,则不会覆盖已删除的文件*,因此明文可能仍然存在,具体取决于它是否被后来写入磁盘的内容覆盖。

* 注意:这些是 Bitlocker 提供的选择。我不知道其他 FDE 工具是如何操作的。

简短回答:即使覆盖整个磁盘,您也不能 100% 确定所有痕迹都已删除

现代硬盘的扇区通常比显示的扇区多,尤其是出于抗磨损均衡原因的 SSD。根据磁盘控制器中的算法,它可能会决定带有secret_financial_plan.txt数据的扇区将成为备用扇区,并将数据写入先前的备用扇区。

下一点要注意:副本可能已写入其他位置,例如临时文件。

下一点:希望它没有上传到云端。否则,您的老板可能会接到来自 NSA 的老板的电话,以色列特勤局向他们报告说,他们秘密入侵并看到一家俄罗斯防病毒软件供应商通过他们的云扫描技术上传您的超级新秘密间谍病毒,因为您使用了受病毒感染的破解程序你的盗版办公套件。

转换为 FDE 后可以恢复文件,但不能保证。关键是FDE只在开启后才提供保护。在此之前它不会保护任何东西。如果驱动器上的块在转换为 FDE 时没有被覆盖(加密),那么它们仍然存在并且可以恢复。可以在转换为 FDE 之前擦除驱动器,但是是擦除导致以前的数据无法访问,而不是 FDE。即便如此,也很难正确擦除驱动器。