最近我一直关注我的WPF应用程序的安全性。我刚刚开始,所以安全性不是我的主要关注点,但现在我有点担心有人可能会在Programs文件夹中打开.exe.config文件并在那里使用凭据。使用这个基本CRUD应用程序的人不会知道如何处理它,即使他们达到它但我不想冒任何机会。
我只是想通过使用外部配置文件或加密它来寻找隐藏它的最简单方法。我已经在stackoverflow上尝试了所有可能的答案,但我只能找到一种直接的方法。
这是我的app.config文件的样子:
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<configSections>
<!-- For more information on Entity Framework configuration, visit http://go.microsoft.com/fwlink/?LinkID=237468 -->
<section name="entityFramework" type="System.Data.Entity.Internal.ConfigFile.EntityFrameworkSection, EntityFramework, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b77a5c666935e080" requirePermission="false" />
</configSections>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.6.1" />
</startup>
<entityFramework>
<defaultConnectionFactory type="System.Data.Entity.Infrastructure.LocalDbConnectionFactory, EntityFramework">
<parameters>
<parameter value="mssqllocaldb" />
</parameters>
</defaultConnectionFactory>
<providers>
<provider invariantName="System.Data.SqlClient" type="System.Data.Entity.SqlServer.SqlProviderServices, EntityFramework.SqlServer" />
</providers>
</entityFramework>
<connectionStrings>
<add name="DailyEntities" connectionString="metadata=res://*/Model.MyModel.csdl|res://*/Model.MyModel.ssdl|res://*/Model.MyModel.msl;provider=System.Data.SqlClient;provider connection string="data source=xx.xxx.xx.xx,port;initial catalog=MyDB;user id=testsubject;password=password;MultipleActiveResultSets=True;App=EntityFramework"" providerName="System.Data.EntityClient" />
</connectionStrings>
</configuration>
这是我已经尝试过的:Protect App.Config file or Encrypt
我遇到的问题是它加密了文件,它在我的机器上工作得很好,但我不能在另一台机器上部署。
有人可以帮助一些简单,愚蠢的建议/例子吗?我不想使用Windows身份验证或编写大量代码来实现这一目标。只是为了让获取凭据更难一点。
简短的回答:你不能 - 你在WPF代码中放置的东西都不会安全。
当然,您可以采取类似编码配置文件中的值,然后让您的代码解密它们的步骤。问题是,潜在的攻击者可能只是将你的应用程序转储到反编译器(如DotPeek)中,并确切地看到你的解密方法是什么。基本上,它会停止的唯一人是那些进入你的系统最不危险的人。
通常,您希望在应用程序和数据库之间放置一个层,以便反汇编您的WPF应用程序的攻击者没有与数据库的原始连接。这样,他们只需获得WebService的地址,而不是直接进入数据库的攻击者。最糟糕的情况是,他们开始尝试自己调用WebService ABC - 但这比他们直接访问数据库要好得多。
我只是想说这绝对是荒谬的,毫无意义的是微软会为ASP.Net中的Web.config文件提供自动加密,但不会在WPF /桌面应用程序中提供自动加密?
认真的微软?基本上没有好的答案