如何在 Windows 中保护文件

发布于 2024-07-15 07:41:34 字数 936 浏览 11 评论 0原文

更新 3:现在可以使用安全选项卡来限制访问。 (这是手动的) 现在希望以编程方式(使用 Visual C#)执行此操作,以及如何在简单的用户帐户中使用管理员帐户访问文件。 提示-我注意到Windows中有这个功能,右键单击并使用“执行为”,输入管理员密码,然后就可以访问该文件。

更新2:找到了如何显示安全选项卡

显示“安全”选项卡

在控制面板中打开文件夹选项。 (单击“开始”,单击“控制面板”, 单击外观和主题,然后 单击文件夹选项。)

在“视图”选项卡上的“高级”下 设置,清除使用简单文件 分享[推荐]。

更新1:我发现了以下文章,它建议如何授予文件权限,但是当我单击“属性”时没有找到“安全”选项卡,您有吗? 任何想法如何获取它

我有一个文件,我想保护它不被修改。 不要对我说加密它,这不能解决问题,我希望用户不能更改文件,但只有我(我的程序)。 Windows 文件是否有任何类型的身份验证,我知道我所说的身份验证是愚蠢的,但是某些 Windows 文件无法访问,例如用户配置文件中的“ntuser.dat.LOG”。 当我尝试打开该文件时,它打不开。

我想要类似的东西,对于这个文件,似乎是因为 Windows 正在使用它。 正确的。 但是,如果我的程序关闭了,我也不希望在这种情况下更改文件。 我该怎么办?

我不要求完整详细的解决方案,我想要想法、建议、技巧或任何你知道会有所帮助的东西,因为它似乎很复杂:p

Update 3: the restrict access, using the security tab works now. (that's manually)
now looking to do it programatically (using Visual C#) and also how to access a file using administrator account in a simple user account.
hint - I noticed this feature in Windows, right click and use 'Execute as', enter the administrator password and then you can access the file.

Update 2: Found how to display the security tab

To display the Security tab

Open Folder Options in Control Panel.
(Click Start, click Control Panel,
click Appearance and Themes, and then
click Folder Options.)

On the View tab, under Advanced
settings, clear Use simple file
sharing [Recommended].

Update 1: I found the following article, which suggests how to give permissions to files, however I don't find the security tab when I click properties, do you have it? Any ideas how to get it

I have a file that I want to protect from bein modified.
Don't say to me encrypt it, this don't solve the problem, I want that users can't change the file, BUT only me (my program).
Is there any type of authentication for Windows files, I know that what I say is stupid about authentication, but some Windows files are inaccessible like 'ntuser.dat.LOG' in the user profile. When I try to open this file it doesn't open.

I want something like that, for this file it seems because Windows is using it. Right.
But what about if my program shutdown, I don't want the file to be changed in this case also.
How shall i do?

I don't ask for the complete detailed solution, I want ideas, suggestions, tips, or any thing you know that it'll help, as it seems to be complicated :p

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(12

想挽留 2024-07-22 07:41:35

这是不可能的!

很抱歉这个直率的答案,但尽管有任何建议的软件措施来“保护”文件,但它不会有帮助。

如果用户确实想要访问该文件,只需将硬盘插入另一台计算机并修改该文件即可。 或者,她可以使用独立于安装的操作系统运行的 Linux Live CD。

It can't be done!

Sorry for this blunt answer, but despite any suggested software measure to "protect" the file, it will not help.

If the user really wants to access the file, he can simply insert the hard disk into another computer and modify the file. Or she can use a Linux live CD that runs independent of the installed operating system.

勿挽旧人 2024-07-22 07:41:35

使用应用程序中嵌入的私钥对文件进行签名,并在加载文件之前检查签名。 每次写入文件时都必须重新签名,以便签名反映任何更改(如果文件在未经签名的情况下被修改,那么当您尝试加载文件时会很明显)。

注意这并不完全安全。 可以想象,破解者可以从您的应用程序中提取密钥,并用它来签署文件的修改版本。 它不能防止恶意攻击,但可以防止普通用户修改文件。

编辑:嗯,似乎您并不关心检测文件是否被修改,您实际上想阻止文件被修改。 抱歉,我认为没有办法做到这一点。 用户可以轻松地终止任何“锁定”文件的进程,甚至可以使用 Live CD 或其他东西启动并以这种方式编辑文件。

Sign the file with a private key embedded in your application, and check the signature before loading the file. You'll have to re-sign every time you write the file so that the signature reflects any changes (if the file is modified without being signed, it will be obvious when you try to load the file).

NB this isn't totally secure. A cracker could conceivably extract the key from your application, and use it to sign his modified version of the file. It doesn't protect against a malicious attack, but will keep your average user from modifying the file.

EDIT: Hmm, seems you don't care about DETECTING if the file is modified, you want to actually PREVENT the file from being modified. Sorry, I don't think there is a way to do this. The user could easily kill off any process "locking" the file, or even boot up with a Live CD or something and edit the file that way.

漫漫岁月 2024-07-22 07:41:35

我敢说...“NTFS 备用数据流” - 请不要开枪打我!

是的,它们很容易修改,但普通的瘾君子不容易找到。

Dare I say it... "NTFS Alternate Data Streams" - please don't shoot me!

Yes their easy to modify, but not easily located by your average junkie.

伊面 2024-07-22 07:41:35

该文件必须由 SYSTEM 用户拥有,并且只具有常规 USERS 组的读取权限。

您的安装程序应该能够创建该文件,对系统进行完全控制,然后消除本地用户对其的权限。 除了阅读权。

The file would have to be owned by the SYSTEM user and only have read rights given to the regular USERS group.

Your installer should be able to create the file, give full control to system, then eliminate local user rights to it. Except for the right to read.

清音悠歌 2024-07-22 07:41:35

由于大多数版本的 Windows 不采用密码保护文件和文件夹的方式,因此本页面提供了加密文件和文件夹的步骤。 要在 Windows 中对文件和文件夹进行密码保护,您需要使用第三方程序。

Microsoft Windows Vista、7、8 和 10 用户

不幸的是,Windows vista、Windows 7 、Windows 8 和 Windows 10 不提供任何密码保护文件或文件夹的选项。 您想使用第三方软件包程序来完成此操作。
如果您想要对文件或文件夹进行编码,可以按照以下步骤完成:

  1. 选择您想要编码的文件或文件夹。
  2. 右键单击文件或文件夹并选择属性。
  3. 在常规选项卡上,单击高级按钮。
  4. 选中“加密内容以保护数据”选项的框。
  5. 单击“应用”,然后单击“确定”。

Microsoft Windows XP Professional 用户

以下在 Windows XP Professional 上加密文件的步骤适用于使用拥有 2 个或多个帐户的笔记本电脑的用户。 如果您使用单个帐户,请参阅相反的安全解决方案部分。

  1. 选择您想要编码的文件或文件夹。
  2. 右键单击文件或文件夹,然后单击“属性”。
  3. 在常规选项卡上,单击高级按钮。
  4. 选中“加密内容以保护数据”选项。
  5. 单击“应用”,然后单击“确定”。

Microsoft Windows XP Home 用户

  1. 选择您要编码的文件或文件夹。
  2. 右键单击文件或文件夹,然后单击“属性”。
  3. 单击共享选项卡。
  4. 选中使该文件夹私有的框,
  5. 单击“应用”,然后单击“确定”。

要了解有关此主题的更多信息,请访问 密码学windows

来源:-
技术

Because most versions of Windows don't embrace a way of password protective your files and folders, this page provides steps on encrypting files and folders instead. To password shield your files and folders in Windows, you would like to use a third-party program.

Microsoft Windows Vista, 7, 8, and 10 users

Unfortunately, Windows vista, Windows 7, Windows 8 and windows 10 don't offer any options for password protective files or folders. you would like to use a third-party software package program to accomplish this.
If you would like to encode a file or folder, this may be done by following these steps:

  1. Choose the file or folder you would like to encode.
  2. Right-click the file or folder and choose Properties.
  3. On the general tab, click the Advanced button.
  4. Check the box for the "Encrypt contents to secure data" choice.
  5. Click Apply then OK.

Microsoft Windows XP Professional users

The steps below for encrypting the files on Windows XP professional apply to users who are using a laptop that has 2 or a lot of accounts. If you're using a single account, see the opposite security solutions section.

  1. Choose the file or folder you would like to encode.
  2. Right-click the file or folder and click on Properties.
  3. On the general tab, click the Advanced button.
  4. Check "Encrypt contents to secure data" choice.
  5. Click Apply then OK.

Microsoft Windows XP Home users

  1. Choose the file or folder you would like to encode.
  2. Right-click the file or folder and click on Properties.
  3. Click the Sharing tab.
  4. Check the box make this folder private
  5. Click Apply then OK.

To learn more about this topic go to cryptography in windows

Source :-
Technology

━╋う一瞬間旳綻放 2024-07-22 07:41:34

您是在 Windows 域中还是只是在工作组中? 这是什么版本的 Windows? 您是计算机的管理员吗?

您应该能够获得文件的所有权,然后设置权限,以便您是唯一可以访问该文件的人。 在 Windows XP 上(Vista 类似),右键单击该文件并查看属性。 选择安全选项卡,然后您可以设置文件的特定权限。 您可以点击高级并设置更具体的选项。

如果您位于域中,域管理员将始终能够查看/编辑您的任何文件。

编辑:
来自 知识库 290403

在 Windows XP Home Edition 和 Windows XP Professional 中,如果在工作组中工作,则默认情况下会隐藏“安全”选项卡。 出现此行为的原因是,在 Windows XP Home Edition 和 Windows XP Professional 中,来宾被迫登录到工作组。

因此,如果您想实现此目的,可以将计算机启动到安全模式,然后您将看到“安全”选项卡。

您还可以在高级选项中取消选中简单文件共享

Are you on a Windows domain, or just a workgroup? What version of Windows is this? Are you an administrator of the computer?

You should be able to take ownership of a file, and then set the permissions so that you're the only one that can access that file. On Windows XP (Vista is similar) Right-click on the file and view Properties. Select the Security tab and then you can set specific permissions on a file. You can click Advanced and set even more specific options.

If you're on a domain, the domain administrators will always be able to view/edit any of your files.

Edit:
From KB 290403:

In Windows XP Home Edition and Windows XP Professional, if working in a workgroup, the Security tab is hidden by default. This behavior occurs because in Windows XP Home Edition and Windows XP Professional, guests are forced to log on to a workgroup.

So if you want to pursue this, you can boot your computer into Safe mode and then you'll see the Security tab.

You can also uncheck Simple file sharing in the Advanced options.

花开浅夏 2024-07-22 07:41:34

你可以运行一个 Windows 服务来锁定文件或其他东西

you can run a windows service that locks the files or something

驱逐舰岛风号 2024-07-22 07:41:34

撤销除您自己(或程序运行所用的帐户)之外的所有用户的访问权限。
右键单击 Windows 资源管理器、属性、安全。

Revoke access for all users but yourself (or the account that the program is running as).
Right-click in Windows Explorer, Properties, Security.

爱人如己 2024-07-22 07:41:34

那么,想法是:修改您的文件,以便只有一个用户可以访问它。 删除所有其他用户权限。 将您的应用程序作为服务运行,并由唯一有权访问该文件的用户进行身份验证。

Idea, then: modify your file so that only one user can have access to it. Remove all other users permissions. Run your application as a service authenticated with the only user who has access to the file.

尾戒 2024-07-22 07:41:34

您可以更改文件的权限,使所有者成为您的应用程序在安装时创建的用户。 但无论如何,管理员汽车会覆盖这一点,我看不到成功锁定它的方法。

即使Windows服务可以关闭,据我所知,没有绝对的解决方案。

You can change de rights of the file to make is owner a user created by your application at installation time. But anyway an administrator car override this, i can't see a way to succesfully lock it.

Even a windows service can be shutdown, there will be no absolute solution as far as I can see.

独木成林 2024-07-22 07:41:34

使用文件的内容创建 MD5 或类似的哈希值。 重新打开文件时,检查存储的哈希值以确保文件未更改。

Create an MD5 or similar hash using the file's contents. When reopening the file, check the stored hash to make sure that the file hasn't changed.

爱已欠费 2024-07-22 07:41:34

这是我的想法! 可能不是很有用!

限制文件的权限(这很常见)并确保只有您的程序有权访问它。 但这并不是万无一失的,因为管理员用户可以更改文件的安全性。

读取前 n 个字节或一些随机字节并将其存储在注册表中。 下次当您的程序启动时,请检查字节是否匹配(如果文件未更改)。 如果是这样,您尝试重新创建该文件。

This is my idea! May be not very useful!

Restrict permission to the file (This is common) and make sure only your porgram has access to it. BUt this is not fail proof as the admin user can change the security of the file.

Read the first n bytes or some random bytes and store it in the registry. Next time when your program starts check whether the bytes match if not the file was changed. If so you try to recreate the file.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文