如何在客户端二进制文件中保留敏感信息?

发布于 2024-12-23 16:19:15 字数 216 浏览 4 评论 0原文

我期待开发一个 Android / iPhone 应用程序,这些应用程序将使用带有嵌入式客户端密钥的私有 API(非免费)。

现在,因为可以对应用程序二进制文件进行逆向工程并删除字符串。我担心会丢失客户端密钥,并将私有 API 暴露给攻击者。

如何管理这个?您能否提供讨论此类情况的文章链接?

考虑到我可以开发私有 API,我可以在其中内置什么机制来保护整个系统的隐私。

I look forward to develop an Android / iPhone application, those will be using a private API (Non-Free) with embedded client-key.

Now, since it is possible to reverse-engineer application binaries and scrap out strings. I am worried of losing my client-key and there by exposing the private API to the attacker.

How to manage this ? Can you provide links to articles discussing such situations ?

Considering I have development access to the private API, what mechanism can I built in to that to preserve the privacy of the whole system.

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

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

发布评论

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

评论(1

雅心素梦 2024-12-30 16:19:15

如果您有权访问应用程序代码,则始终可以使用私有 API(请参阅 这个线程也是如此)。不过,你可以让它变得更难。您可以通过以下选项限制 API 的使用

1) 如果它不是“您的”API,请勿将密钥放入应用程序中,而是放入您正在运行的服务器中,以充当外部服务的代理(您可能仍然需要另一个密钥让您的服务器进入应用程序,然后)

2)加密/扰乱密钥,使其不易被获取:

  • 扰乱的简单示例:将密钥放入文件中;生成相同长度的随机文件;将密钥文件与随机文件进行异或(然后再次将其写入磁盘);每当您需要密钥时,请读取这两个文件并再次对它们进行异或(任何可逆操作而不是异或都可以 - 更复杂的操作,分布在您的代码中将使逆向工程师变得更加困难)
  • 使用分布在您的应用程序上的密码加密您的密钥(在部署时,Android 应用程序无论如何都会被混淆,因此找到它会变得有点困难)

3)如果这是您的服务或者您设置了代理,请限制每个客户端/IP 的使用次数或通过代理仅提供部分服务

注意, 选项如果您有禁止公开密钥的合同,甚至可能需要 1。

It will always be possible to use the private API if you have access to your applications code (see this thread as well). You can make it harder, though. And you can restrict the use of the API with the following options

1) if it's not "your" API, don't put the key into the app but into a server you are running to serve as proxy for the foreign service (you probably still want another key for your server to go into the app then)

2) encrypt/scramble the key so it is not grabbed easily:

  • simple example for scrambling: put the key into a file; generate a random file of same length; xor the key file with the random file (and write it to disk again); whenever you need the key read both files and xor them again (any reversable operation instead of xor will do - more complex operation, spread over your code will make it harder for the reverse engineer)
  • encrypt your key using a passphrase spread over you app (on deployment android apps are obfuscated anyways, so finding it gets a bit harder)

3) if it's your service or you have a proxy set up, restrict the number of uses per client/IP or offer only parts of the service over your proxy

Note, option 1 may even be required if you have a contract which forbids to make your key public.

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