windows 是否可以创建无法复制的文件?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/3362271/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Is it possible to create a file that cannot be copied?
提问by xport
To restrict the scope, let assume we are in Windows world only.
为了限制范围,假设我们仅在 Windows 世界中。
Also assume we don't want to play with permission policy.
还假设我们不想玩权限策略。
Is it possible for us to create a file that cannot be copied?
我们可以创建一个无法复制的文件吗?
Thank you in advance.
先感谢您。
回答by Pablo Santa Cruz
No. You can't create a file that a SYSADMIN can't copy. You could encrypt it, though.
不能。您不能创建 SYSADMIN 不能复制的文件。不过,你可以加密它。
回答by mocybin
"Trying to make digital files uncopyable is like trying to make water not wet." ~ Bruce Schneier
“试图使数字文件不可复制就像试图使水不湿。” ~ 布鲁斯·施奈尔
回答by SoundAdvice
Well, how about creating a file that uses up more than 50% of the total spaceon that machine and that is not compressible?
For instance, let us assume that you want to save a boolean (true or false) in such a fashion.
Depending on its value, you could then write a bit stream of one
s or zero
es and encrypt said stream using some kind of encryption algorith, such as AES in CBC mode. This gives you the added advantage of error correction. Even in case of massive data corruption, you should be able to recover your boolean by checking whether one
s or zero
es are prevalent in the decrypted stream.
In that case you cannot copy it around (completely) on the machine...
Of course, any type of external memory that can be added to the system would pose a problem in this scenario. But the file would be already encrypted, so don't worry about it too much...
那么,创建一个占用该机器总空间 50% 以上且不可压缩的文件如何?例如,让我们假设您想以这种方式保存布尔值(真或假)。根据其值,您可以编写one
s 或zero
es的位流,并使用某种加密算法(例如 CBC 模式下的 AES)加密所述流。这为您提供了纠错的额外优势。即使在大量数据损坏的情况下,您也应该能够通过检查one
s 或zero
es 在解密流中很普遍。在这种情况下,您不能在机器上(完全)复制它……当然,在这种情况下,可以添加到系统中的任何类型的外部存储器都会造成问题。但是文件已经加密了,所以不要太担心......
回答by Drew Noakes
Any file that can be read can have its contents written to another location (such as another file, i.e. copied).
任何可以读取的文件都可以将其内容写入另一个位置(例如另一个文件,即复制)。
The only thing you can do is limit who/what can read the file.
您唯一能做的就是限制谁/什么可以读取文件。
回答by Fadrian Sudaman
What is the motivation behind? If it is a read-only file, you can have it as embedded resources within your assembly.
背后的动机是什么?如果它是只读文件,您可以将其作为程序集中的嵌入资源。
回答by rapadura
Nice try, RIAA.
不错的尝试,RIAA。
But seriously, no you can not. It is always possible to copy, you can just make it it more difficult for people to make sense of the file or try to hide it using like encryption. Spotify does it.
但说真的,不,你不能。始终可以复制,您可以使人们更难以理解文件或尝试使用加密等方法隐藏它。Spotify 做到了。
If you really try hard thou, you cold make a root-kit for windows and use it to prevent windows from even knowing about the file and also prevent copies. The file will still be there and copy-able by other tools, or Linux accessing the ntfs.
如果你真的很努力,你可以为 Windows 制作一个 root-kit 并使用它来防止 Windows 甚至知道该文件并防止复制。该文件仍然存在并且可以被其他工具或访问 ntfs 的 Linux 复制。
回答by Daniel Rose
If in a running process you open a file and hold an exclusive lock, then other processes cannot read the file until you close the handle or your process terminates. However, as admin you could forcibly remove the lock handle.
如果在一个正在运行的进程中您打开一个文件并持有一个排他锁,那么在您关闭句柄或您的进程终止之前,其他进程无法读取该文件。但是,作为管理员,您可以强行移除锁柄。
回答by Jay
Short answer: No.
简短的回答:没有。
You can, of course, use security settings to limit who can read the file. But if someone can read it, then they can copy it. Even if you found some operating system trick to disable "ordinary" copying, if someone can read the file, they can extract the contents, store it in memory, and then write it somewhere else.
当然,您可以使用安全设置来限制谁可以读取文件。但如果有人可以阅读它,那么他们就可以复制它。即使您发现了一些禁用“普通”复制的操作系统技巧,如果有人可以读取文件,他们也可以提取内容,将其存储在内存中,然后将其写入其他地方。
You can encrypt the contents so it's only useful to your own program, that knows how to decrypt it.
您可以加密内容,因此它只对您自己的程序有用,知道如何解密它。
That's about it.
就是这样。
回答by supercat
When using Windows 7 to copy some files from a hard drive, certain files popped up a message saying they could not be copied in their entirety; certain data would be omitted from the copy. I suspect that had something to do with slack space at the end of the files, though I thought the message was curious. I would have expected the copy operation to just ignore the slack space.
使用Windows 7从硬盘复制某些文件时,某些文件会弹出一条消息说它们无法全部复制;某些数据将从副本中省略。我怀疑这与文件末尾的空闲空间有关,尽管我认为该消息很奇怪。我原以为复制操作会忽略松弛空间。
回答by Wes
If you are running old (OLD) versions of windows, there are certain characters you can put in the filename that make it invalid, not listed in folders, etc. They were used a lot in the old pub ftp days of filesharing ;)
如果您运行的是旧 (OLD) 版本的 windows,则可以在文件名中放入某些字符使其无效,而不是在文件夹中列出等。它们在旧的 pub ftp 文件共享时代被大量使用;)