从硬盘驱动器中永久删除文件
我想知道如何编写一个程序来从硬盘驱动器中永久删除文件。我知道我的程序在删除系统与数据的链接方面至少需要具有与“rm”相同的功能,但我也对如何(完全)取消磁盘上的数据感兴趣。
我非常确定C和汇编将提供这种低级功能,但我不太确定如何开始尝试访问磁盘的某些部分,或追踪不同片段的位置磁盘上的文件。
我知道由于我缺乏文件系统知识,这似乎是一个大项目,但我只是想学习。我知道我需要更多地了解硬盘以及我特别尝试使用的驱动器类型。但您可以提供的任何帮助/链接将不胜感激。
I am wondering how to go about writing a program to permanently remove files from my hard drive. I know that my program needs to at least have the same functionality as "rm" in terms of removing the system's links to the data, but I also am interested in how I go about nullifying (entirely) the data on the disk.
I am pretty sure that C and assembly will provide this low level functionality, but I'm not really sure how to even start trying to access parts of the disk, or track down the locations of different fragments of a file on the disk.
I know this might seem like kind of a big project due to my lack of knowledge on filesystems, but I'm just trying to learn. I'm aware that I'll need to learn more about hard drives and what type of drive I'm specifically trying to work with. But any help/links you could provide would be appreciated.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我认为你想要的是使用像 scrub 这样的程序。唯一的问题是,对于许多文件系统来说它不起作用。
提出通用的解决方案可能是不可能的。
I think what you want is to use a program like scrub. The only problem, is that for many file system it does not work.
To come up with a generic solution is probably going to be impossible.
如果您打开文件,获取文件大小,然后将 n 个空字节写入要删除的文件(其中 n 是字节数),则可以。
之后只需删除该文件即可。所有数据都将丢失,如果有人恢复文件节点,他所能看到的只是一堆零。
也就是说:我确信这里有些人会告诉您,您必须用零(或其他某种模式)擦除文件至少 10 到 15 次才能真正删除内容的所有痕迹。永久删除该文件一次。
这是一个都市传说。不要相信他们。没有人,即使是 CSI 电视剧中的人也无法恢复已被擦除一次的文件。
It is okay if you open the file, get the file size and then write n null bytes to the file that you want to delete (where n is the number of bytes).
Afterwards just delete the file. All data will be lost and if someone recovers the file-node all he can see is a bunch of zeroes.
That said: I'm sure that some people here will tell you that you have to wipe the file with zeros (or some other pattern) at least 10 to 15 times to really remove all traces of the content. erase the file once for ever.
This is an urban legend. Don't trust them. Noone, not even the guys from the CSI tv-series can recover a file that has been wiped once.