如何保护 Windows .net 应用程序中的静态字符串?

发布于 2024-11-04 08:40:41 字数 214 浏览 0 评论 0原文

我们正准备部署一个 Windows .NET 客户端应用程序,它将向我们的中央服务器发出 Web 服务调用。我们需要验证对 Web 服务的所有调用均来自我们的客户端应用程序,而不是来自任何其他调用者。有人建议我们传递一个对我们的应用程序的所有安装都通用的安全令牌。但是,我们现在可以在应用程序安装中保护这个通用字符串。有没有一种有效的方法可以合理地保护这样的字符串不被黑客发现?

感谢您的任何建议。

We are preparing to deploy a Windows .NET client app that will make web service calls back to our central server. We've been given the requirement to validate that all calls made to the web service come from our client apps and not from any other caller. It's been proposed that we pass along a security token that is common to all installations of our application. However we now have this common string to secure within the application installation. Is there an effective way to reasonably protect such a string from being discovered by a hacker?

Thanks for any and all advice.

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

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

发布评论

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

评论(3

明明#如月 2024-11-11 08:40:41
  • 始终使用 SecureString 处理令牌。这样从内存中检索令牌就会变得更加困难。
  • 将令牌作为连接字符串存储在 app.config 中,并加密“connectionStrings”部分。这样,令牌将受到除用户帐户(通过 DPAPI)之外的任何人的保护。
  • 使用SslStream 进行客户端服务通信。这样,您的连接将被加密。与令牌相结合,您的通信现在将经过身份验证(即您了解您的客户)并受到保护。
  • Use SecureString to deal with the token at all times. This way it will be a lot harder to retrieve the token from the memory.
  • Store the token as a connection string in app.config and encrypt the 'connectionStrings' section. This way the token will be secured from anyone except the user's account (through DPAPI).
  • Use SslStream to do the client-service communications. This way, your connection will be both encrypted. Coupled with the token, your communications will now be both authenticated (i.e. you know your client) and secured.
策马西风 2024-11-11 08:40:41

这称为公钥加密。

  • 您的应用程序将其公钥发送到服务器
  • 服务器返回必须添加到某个前缀的加密字符串
  • 您的应用程序询问服务器他的公钥
  • 您的应用程序解密字符串,添加前缀
  • 使用服务器公钥加密
  • 将密钥发送到服务器
  • 服务器验证

如果黑客知道二进制文件中的前缀,它将不知道服务器提供的后缀,并且无法解密您发送回服务器的内容,因为黑客没有服务器私钥。漏洞是黑客可以提取应用程序中的私钥来解密后缀。但如果需要,服务器可以每隔几秒更改一次,或者它可以与时间相关。然而,可以利用时间相关性,如果您选择此选项,最好更改可变的时间相关后缀。在某些时候,经过大量的努力和一台可用的超级计算机,黑客也可以通过搜索可以解密所有发回的结果字符串的密钥来破解它,这就是为什么您不应该在服务器,但回收其中很少。

如果您认为这工作量太大,您可以使用 SecureString 和加密的连接字符串。但这肯定是可以利用一些时间来破解的,因为所需的一切都在客户端,并且黑客不需要 x*2 暴力解密。

It's called public key encryption.

  • your app send its public key to the server
  • server gives back encrypted string that must be added to some prefix
  • your app asks the server his public key
  • you app decrypts the string, add the prefix
  • encrypts with the server public key
  • send the key to the server
  • server validates

If the hacker knows your prefix that is in your binary file it wont know the suffix that the server provides, and wont be able to decrypt what you send back to the server because the hacker doesn't have the servers private key. Vulnerability is that the hacker could extract the private key in the app to decrypt the suffix. But the server can change that every few seconds if required or it can be timedependent. However time dependent can be exploited, it is better to have a variable time dependent suffix change if you choose this. At some point and with a lot of effort and a supercomputer at disposal the hacker could hack that too, by searching for a key that can decrypt all of the resulting strings that are sent back, that is why you should not generate random suffixes on the server but recycle few of them.

If you think that is too much work, you could use SecureString and encrypted connection strings. But that sure is hackable with some time at disposal because everything needed is on client side, and the hacker does not need x*2 bruteforce decrypt-ions..

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