标题: 非正经硬盘脱密方式 创建: 2020-11-02 11:51 更新: 2022-08-31 11:41 链接: https://scz.617.cn/windows/202011021151.txt 考虑一种常见场景,旧电脑不想用了,旧硬盘数据已经迁移完毕,想彻底清空旧硬盘, 不想哪天被人从旧硬盘中找到跟自己相关的蛛丝马迹。强调一下,本文只对付硬盘报 废这种场景,不考虑开着飞机修飞机式的安全擦除部分文件、目录。 如果你不是IT人士,想办法把旧硬盘拆下来,到楼下打个空地用铁榔头砸坏它,请认 真点砸,至少像罗永浩砸西门子电冰箱那样砸。扔水里泡着、浇上油烧、买个消磁器? 你开心就好。然后,就可以了,不要往下看了,徒增茫然。 如果有相应技术能力,把这块硬盘挂到Linux系统中,假设目标盘是"/dev/sdb",如下 命令之一擦除没毛病: dd if=/dev/urandom of=/dev/sdb status=none dd if=/dev/zero of=/dev/sdb status=none Windows用户可能装有VMware,可能有个Guest是Linux,直接在VMware中添加物理硬盘、 物理分区,然后在Guest中dd。问个题外话,WSL1中有可能这样dd吗,没去尝试过, 主要是"/dev/sdb"的等价物在哪里? 不用dd,那就考虑其他Windows工具。 这种场景下,不要针对现存文件、目录进行安全删除,直接快速格式化清空再说。按 说完全格式化(与快速格式化相对)会擦除硬盘数据、检查并标记硬盘坏扇区(sector), 是不是这里选完全格式化就可以了?我不确定,只是一想。后来在一款恢复软件的帮 助手册中看到,从Vista开始,完全格式化会用零覆写整个分区,因此普通用户可以 用完全格式化来软脱密。 NTFS、ext3、ext4、HFS+等都是全日志(journal)文件系统,会在日志中记录曾经存 在的文件以及它们在硬盘上的位置。快速格式化只是简单擦除这些日志,不会重建文 件系统,不会检查坏扇区,不会擦除文件内容。 快速格式化之后,如果只是避免被R-Studio、WinHex、winfr这类工具恢复原来的数 据,可以用sysinternals的sdelete。 https://docs.microsoft.com/en-us/sysinternals/downloads/sdelete $ sdelete SDelete v2.02 - Secure file delete Copyright (C) 1999-2018 Mark Russinovich Sysinternals - www.sysinternals.com usage: sdelete [-p passes] [-r] [-s] [-q] [...] sdelete [-p passes] [-z|-c [percent free]] sdelete [-p passes] [-z|-c] -c Clean free space. Specify an option amount of space to leave free for use by a running system. -p Specifies number of overwrite passes (default is 1) -r Remove Read-Only attribute -s Recurse subdirectories -z Zero free space (good for virtual disk optimization) -nobanner Do not display the startup banner and copyright message. Disks must not have any volumes in order to be cleaned. 假设目标盘是T盘,如下命令就可以了: $ sdelete -p 1 -z T: 这是微软自己认可的工具,免费,下载点安全可靠。 后来发现Win10自带的manage-bde.exe有个功能: -WipeFreeSpace or -w Wipes the free space on the volume. 那么理论上快速格式化目标盘之后可以这样干: $ manage-bde.exe -w T: 帮助信息如下: $ manage-bde.exe -w -h BitLocker Drive Encryption: Configuration Tool version 10.0.19041 Copyright (C) 2013 Microsoft Corporation. All rights reserved. manage-bde {-WipeFreeSpace|-w} Volume [-Cancel] [{-ComputerName|-cn} ComputerName] [{-?|/?}] [{-Help|-h}] Description: Wipes the free space on the volume removing any data fragments that may have existed in the space. If used with a volume that was encrypted using the data only option provides the same level of protection as if the volume had been encrypted with the full encryption option. Parameter List: Volume A drive letter followed by a colon, a volume GUID path or a mounted volume. Example: "C:", \\?\Volume{26a21bda-a627-11d7-9931-806e6f6e6963}\ or "C:\MountVolume" -Cancel Cancels wipe of free space. -ComputerName or -cn Runs on another computer. Examples: "ComputerX", "127.0.0.1" -? or /? Displays brief help. Example: "-ParameterSet -?" -Help or -h Displays complete help. Example: "-ParameterSet -h" Examples: manage-bde -w C: manage-bde -w -Cancel C: 假设目标硬盘1T,有人可能这样干过: fsutil.exe file createnew temp.dat 0 dir temp.dat del temp.dat fsutil.exe file createnew temp.dat 1000064053248 fsutil.exe file setzerodata offset=0 length=1000064053248 temp.dat dir del temp.dat 不要这样干!官方文档里对setzerodata的描述有一句 If the file is a sparse file, the underlying allocation units are decommitted. 前面那条sdelete命令只会擦除文件内容,不会擦除MFT。假设已用sdelete处理过目 标硬盘,用WinHex F9打开目标硬盘,仍会看到很多文件名、目录名,这是MFT中的残 像。文件内容不可恢复(对一般人来说)只是第一步,你大概率也不想让人看到你的文 件目录结构,比如"和小芳的合影"、"和冠希的合影",这种文件名、目录名残像还是 让它消失得了。 sdelete有局限性,好在有不少成熟工具可以同时擦除文件内容、文件目录结构,包 括但不限于 -------------------------------------------------------------------------- CCleaner https://en.wikipedia.org/wiki/CCleaner https://zh.wikipedia.org/wiki/CCleaner https://www.ccleaner.com/ccleaner/download https://www.ccleaner.com/ccleaner/download/standard BCWipe https://www.jetico.com/data-wiping/wipe-files-bcwipe https://www.jetico.com/downloads/data-wiping https://www.jetico.com/download/bcwipe https://www.jetico.com/serve/bcwipe-help-file-windows -------------------------------------------------------------------------- 这样用CCleaner: Options Settings Wipe MFT Free Space Tools Drive Wiper CCleaner本身是个流氓软件,它的官方免费版会自动安装"AVG AntiVirus FREE",没 有机会选择不装!可以马上卸载,但要求重启。由于这个SB反病毒软件的安装,导致 Win10自带的Windows Defender被禁用。其实维基条目提到2018年就有人吐槽此事, 但官方否认过,现在看来这也是一家没节操的公司。 可以先安装再卸载,从而实现CCleaner的绿色化,我们只需要它的部分功能。 后来发现CCleaner的流氓程度挺高,已经绿色化了,还悄悄往"任务计划程序"中插入 项目,干掉它。 $ schtasks /query | findstr CClean CCleanerSkipUAC N/A Ready $ schtasks /delete /f /tn CCleanerSkipUAC 这样用BCWipe: Wipe drive free space Wiping options MFT Records (残留数/总数) View Dirty Records (查看残像) NTFS Transactions Log File BCWipe没有永久免费版本,官方这个免费试用版有21天时间限制,功能上也有限制, 但免费版已经可以彻底清空MFT。网上有破解,我没用。我在虚拟机中用BCWipe,安 装前建了快照,以便重装BCWipe恢复试用。 假设硬盘之前已被sdelete或其他工具擦除过,只是MFT还有残像,WinHex还能看到文 件名、目录名,此时可以用BCWipe补刀。当然,可以一开始就用BCWipe进行硬盘擦除, 并不需要先sdelete再BCWipe,我只是说一种特定场景下的补救措施。BCWipe首先就 会彻底擦除MFT,第一步的进度条一结束,如果是初刀需求,此时可以点击Cancel中 止擦除,因为MFT之外的空间早被其他工具擦除过,BCWipe只是来初刀,没必要再擦 除一遍。你会发现"MFT Records"处的残留数已变成0,"View Dirty Records"看到的 是空列表,WinHex再也看不到文件名、目录名残像。 重复强调,可以用CCleaner、BCWipe等软件完整擦除硬盘,不需要先sdelete。如果 已经先sdelete过,为了给sdelete补刀,最简单的办法不是CCleaner、BCWipe,而是 非法证版WinHex! http://www.x-ways.net/winhex/ http://www.x-ways.net/winhex.zip http://www.x-ways.net/winhex-x64-addon.zip http://www.x-ways.net/winhex/manual.pdf 这样用非法证版WinHex: F9打开目标硬盘 Tools Disk Tools Initialize Free Space (法证版没有) Initialize Slack Space (法证版没有) Initialize MFT Records (法证版没有) Initialize Directory Entries (法证版没有) Scan For Lost Partitions Interpret as Partition Start "Initialize MFT Records"就是擦除MFT,用WinHex看,用WinHex擦,不必再找其他 工具。当然,非sdelete补刀场景时,应该先用"Initialize Free Space"、 "Initialize Slack Space",再用"Initialize MFT Records"。 关于WinHex有个巨坑。先看一下其各种版本的功能对比: Comparison of WinHex License Types and Related Products http://www.x-ways.net/winhex/comparison.html 之前误以为法证版WinHex(xwforensics)是其左侧所有版本的超集,所以一般用 xwforensics打开硬盘。但是,官方帮助里明确写了,前面那四个功能只有非法证版 WinHex才有,这太反直觉了。用xwforensics打开硬盘时,菜单里没有前面那四个功 能,所以才一度去找别的方案。 有网友指出,将法证版xwforensics64.exe改名成WinHex64.exe,就有前面那四个功 能。实测确实如此,说明法证版xwforensics确实是WinHex的超集,只是从UI上隐藏 了一些功能,这奇葩的功能限制机制。 有些二把刀工具,不推荐,包括但不限于: -------------------------------------------------------------------------- PriVazer https://privazer.com/index.php https://privazer.com/download.php https://privazer.com/PrivaZer_free.exe https://privazer.com/PrivaZer.exe (portable version) Revo Uninstaller https://www.revouninstaller.com/revo-uninstaller-free-download/ https://www.revouninstaller.com/start-freeware-download-portable Tools Evidence Remover -------------------------------------------------------------------------- bluerust用这个: Free Open-Source Data Wiping Software for Personal Use https://dban.org/ 还有很多其他符合要求的工具,也有很多其他二把刀工具,不再讨论。 给个简单结论,苍茫的dd是你的爱,爱不起了就这样干,快速格式化、sdelete、 WinHex。sdelete、WinHex都可以绿色化,U盘、WinPE什么的,到哪擦哪。 本文并未讨论硬盘软脱密最优解,但充分考虑了占比很大的常见场景,比如突然被人 找去,说我要离职了,你帮我处理一下这块硬盘,而这个人并不是IT同行,此时最易 获取的工具、最易使用的套路,是本文考虑的重点。 有些SB根本就没试过WinHex F9打开硬盘,想当然地展示它们用过的擦除方案。建议 无论你多NB地擦除过硬盘,至少最后用WinHex F9打开一次硬盘,最后确认一下无敏 感信息残留。 对于单杠、双杠爱好者提到的电钻,多说一句,软脱密后的硬盘还可以当成普通下载 盘用用,另有些场景只允许软脱密,不允许物理损坏。 最后的最后,这是对付一班人,不是对付二班、三班人,严肃硬盘脱密场景请按保密 标准处理,除了dd,不要使用本文提及的其他工具软件。 2021-12-20 09:56 Using Diskpart to create, delete, clean or extend disk partitions - [2021-07-20] https://www.techtarget.com/searchwindowsserver/tip/Using-Diskpart-to-create-extend-or-delete-a-disk-partition Cleaning a disk using diskpart When you have an entire disk to wipe clean, you can use the diskpart clean command to convert all the stored data into unallocated space. This operation deletes all data on the disk by writing zeros on each disk sector. Diskpart also removes all partition and volume information from the selected drive. To clean a disk: At a command prompt, type diskpart At the DISKPART prompt, type select disk 0 At the DISKPART prompt, type clean all At the DISKPART prompt, type exit 从描述看,或可用这招软脱密,但我没试过。对于Vista之后的OS来说,这招相比完 全格式化没啥特别优势,不推荐普通用户使用。再就是,"select disk n",应该无 法热擦除系统盘,只适用于非系统盘。 2019-9-22 12:12 tk https://weibo.com/1401527553/I85XwecHH 现代Windows的format有个/P参数,"format /P:count"会将每个扇区清零,再用随机 数覆写count次,count为0时只清零扇区不用随机数覆写。 /P:count Zero every sector on the volume. After that, the volume will be overwritten count times using a different random number each time. If count is zero, no additional overwrites are made after zeroing every sector. This switch is ignored when /Q is specified. 如何用Windows自带功能在不格式化磁盘的情况下安全删除文件呢?cipher.exe本来 是用于磁盘加密的,但其/W参数可对磁盘上未使用的空间进行覆写。假设你刚刚删除 "D:\private"目录下几个文件,执行"cipher.exe /W:D:\private",D盘所有未使用 空间会被覆写三次,第一次0x00,第二次0xFF,第三次随机数,所有被删除文件无法 被恢复。/W指定directory意义不大,实际擦除目录所在卷的自由空间。 /W:directory Removes data from available unused disk space on the entire volume. If this option is chosen, all other options are ignored. The directory specified can be anywhere in a local volume. If it is a mount point or points to a directory in another volume, the data on that volume will be removed. 下面两条Windows自带工具效果不等价,后者应该只擦一遍,填零?我不确认。 cipher.exe /W:D: manage-bde.exe -w D: 2022-08-31 10:33 现在笔记本多是SSD硬盘,默认情况下天然对抗"反删除"。 参看 《SSD盘如何抢救被删除的文件》 https://scz.617.cn/windows/202203161423.txt 《文件删除后的恢复实验》 https://scz.617.cn/windows/202010301445.txt