c# - 在 APK 中保护字符串

标签 c# android security xamarin.android xamarin

我正在使用 Xamarin 的 Mono for Android 开发一个 Android 应用程序。我目前正在使用 Google Play API 添加应用内购买功能。为此,我需要从我的应用程序中向 Google 发送公共(public)许可证 key 。针对此问题,Google 建议如下:

Security Recommendation: It is highly recommended that you do not hard-code the exact public license key string value as provided by Google Play. Instead, you can construct the whole public license key string at runtime from substrings, or retrieve it from an encrypted store, before passing it to the constructor. This approach makes it more difficult for malicious third-parties to modify the public license key string in your APK file.

我从未处理过加密、黑客攻击/破解或任何其他软件安全方面的问题,因此我不确定如何实现 Google 的建议。我的问题是,如何充分保护使用 Mono for Android 制作的 Android APK 中的字符串,而无需成为安全专家?

最佳答案

不要听起来太大胆,但我相信您可以安全地忽略他们的建议。他们所建议的安全优势充其量是最小的。

有关更详细的讨论,请阅读:How to protect Google Play public key when doing InApp Billing

事实上,那里描述的方法都不是绝对安全的。如果有人决心找出您的公钥,他们会的。无论您做什么,公钥最终都会传递给 ctor,因此恶意用户始终可以在此时检查它。他们建议的所有“游戏”只是让这件事变得更加困难,但绝对不是不可能的。

我认为您最好的选择是接受它的真实情况。此 key 是公开是有原因的,您需要忍受它很容易被破坏的事实。既然其他人都知道这一点,晚上睡得很好,我看不出你为什么不应该这样做:)

如果您真的晚上睡不着觉并想做点什么.. 将您的 key 放在您的代码中,并交换前两个字符。然后在运行时,在使用键之前将两个字符切换回来。这应该足以保护您自己免受暴力自动攻击。您无能为力的智能攻击。

编辑:

如果您正在寻找一种行业标准方法来保护您的代码,请使用商业混淆器。这些工具就是为此目的而设计的。一些例子是 Mono for Android, code obfuscation .确保使用包含字符串加密的全功能商业版本。

关于c# - 在 APK 中保护字符串,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17959244/

相关文章:

security - 将 session ID 作为 url 参数传递的危害

c# - 是否有像哈希表这样的 3 个链接值的预定义类?

javascript - 文档.body.style.color = 'blue' ; document.body.style.fontSize = 18px';不适用于 Android WebKit

c# - 获取 IEnumerator 的元素到列表

android - Appium - 无法使用 xpath 定位 android 元素

android - Actionbar 设置主页按钮

javascript - 包含第 3 方 iFrame 的安全风险

php - 如何阻止 Web 应用程序中过多的请求?

c# - 如何像在 C# 中那样在 Java 中使用回调调用函数?

c# - 使用 ASP.NET 网格显示分层 xml 数据