在BillingService模块中,需要修改哪些内容来提高安全性?

发布于 2024-12-25 20:42:59 字数 369 浏览 1 评论 0原文

BillingService 的注释建议:

在使用此代码之前,您应该对其进行修改和混淆。

好的,但是什么必须修改?

班级名称?用于记录的TAG?方法名称和数据成员?逻辑和程序流程本身?其他?

换句话说,我可以理解混淆的必要性,但是我如何才能在不从头开始重写所有内容的情况下实现建议(可能会出现比不修改任何内容更糟糕的错误)?

The comment for the class BillingService recommends that:

You should modify and obfuscate this code before using it.

OK, but what must be modified?

The class name? The TAG used for logging? Method names and data members? The logic and program flow itself? Other?

In other words, I can understand the need for obfuscation, but how can I get away with implementing the recommendation without rewriting everything from scratch (potentially with bugs that are worse than not modifying anything)?

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

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

发布评论

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

评论(3

○闲身 2025-01-01 20:42:59

我目前正在研究这个问题,到目前为止,我的方法如下:

  1. 我使用 BillingReceiver、Billing Service、PurchaseObserver 和 ResponseHandler。
  2. 我已将所有常量移至我自己的 Constants 类中,并且上述所有类都包含在我自己的包中。
  3. 我已经取消了 PurchaseDatabase 类,并将其部分集成到我自己的 SQLite 数据库、DBAdapter 和数据访问类中。
  4. 我已将 CatalogEntry 更改为我自己的模型对象,并且我的 UI 将与示例完全不同,例如 RadioButton 组而不是产品项的 Spinner(我只有 4 个)。
  5. 它在安全类中说“为了安全实现,所有这些代码都应该在与应用程序通信的服务器上实现”。我很“幸运”,我的应用程序无论如何都必须联系我的服务器,因此我将在服务器上实施这些安全措施,并且我将对传递到服务器的购买信息进行自己的验证。我希望使用 SSL 来保护这部分通信的安全,并且我已经需要存储在我的服务器上的先前用户名/密码(经过哈希处理和加盐处理)。
  6. 我正在删除任何其他我没有使用的多余代码,例如有效负载编辑。
  7. 有些方法的签名中有 5 或 6 个参数,例如 onPurchasestateChanged() - 我正在考虑将它们组合到单个包装对象中(但尚未这样做)。
  8. 我正在缓慢而彻底地测试它,以便我了解发生了什么,并遵循建议。我首先使用完整的示例来确保它有效并测试了静态响应。然后我开始进行自己的更改,同时仍然进行静态测试。我仍在使用静态响应进行测试,并且我将跟踪消息流以了解正在进行的交换。一旦我对此感到满意,我将使用我自己的产品 ID 进行测试,并尝试让自己对数据及其安全性感到满意。
  9. 我认为developerPayload字符串也可以被签名和加密,并且当返回到我的服务器时,被解密并检查完整性。
  10. 最后,我将使用 ProGuard 对代码进行混淆,并遵循 StackOverflow 上提供的一些提示进行操作。

希望这有帮助。

I'm working on this at this moment and my approach, so far, is as follows:

  1. I'm using the BillingReceiver, Billing Service, PurchaseObserver and ResponseHandler.
  2. I've moved all the Constants into my own Constants class and all the above classes are included in my own package.
  3. I've done away with the PurchaseDatabase class and integrated parts of it into my own SQLite database, DBAdapter and data access classes.
  4. I've changed the CatalogEntry into my own model object and my UI will be quite different to the example e.g. RadioButton group rather than Spinner for product items (I only have 4).
  5. It says in the Security class 'For a secure implementation, all of this code should be implemented on a server that communicates with the application'. I'm 'fortunate' that my app has to contact my server anyway so I'll be implementing these security measures on the server and I'll be doing my own validation of the purchase info passed to the server. I'm looking to secure this part of the comms using SSL and I already require a prior username/password (hashed and salted) which is stored on my server.
  6. I'm cutting out any other superfluous code which I'm not using e.g. payload editing.
  7. Some of the methods have 5 or 6 parameters in their signature e.g. onPurchasestateChanged() - I was thinking about combining these into a single wrapper object (but haven't done so yet).
  8. I'm testing it slowly and thoroughly, so that I understand what's going on, and following the recommendations. I used the complete sample at first to make sure it worked and tested the static responses. Then I started making my own changes while still doing static testing. I'm still testing with static responses and I will follow the flow of messages to understand the interchanges going on. Once I'm happy with this I'll test with my own product Id's and try and satisfy myself on the data and its security.
  9. I've thought that the developerPayload string could also be signed and encypted and when returned to my server, decrypted and checked for integrity.
  10. Finally, I'll obfuscate the code using ProGuard and follow some of the tips for doing so which are available on StackOverflow.

Hope this helps.

柏拉图鍀咏恒 2025-01-01 20:42:59

这里没有好消息:除了使用 Proguard 之外,您还需要进行任何可以更改的操作。这包括合并类、拆分类、将某些方法从一个模块移动到另一个模块,特别是对存储到数据库中的购买信息进行加密,如 PurchaseDatabase 类的描述所示:

在将任何信息存储到
持久存储。混淆器应该使用特定的密钥
给设备和/或用户。否则攻击者可以复制数据库
充满有效购买并将其分发给其他人。

原因是,使用 AntiLVL 这样的工具,可以很容易地将反编译(混淆!)的代码与原始示例进行比较,并从中推断出破坏它所需的任何内容。完全防止开裂是不可能的,但应该尽量让它变得困难。

No good news here: You need to change anything you can, in addition to using Proguard. This includes merging classes, splitting them, moving certain methods from one module to another, and especially encrypting the purchase information stored into the database, as the description for the PurchaseDatabase class suggests:

You should use an obfuscator before storing any information to
persistent storage. The obfuscator should use a key that is specific
to the device and/or user. Otherwise an attacker could copy a database
full of valid purchases and distribute it to others.

The reason is that with tools like AntiLVL it is very easy to compare your decompiled (obfuscated!) code to the original sample and deduct from it whatever needed to compromise it. It is impossible to completely prevent cracking, but you should try to make it as difficult as possible.

岁月静好 2025-01-01 20:42:59

他们解释如下:

应用内结算示例应用程序是公开分发的,可以
任何人都可以下载,这意味着对于
如果您使用该示例,攻击者将对您的应用程序进行逆向工程
代码与发布时完全相同。该示例应用程序旨在
仅用作示例。如果您使用示例的任何部分
应用程序,您必须在发布它或将其发布为之前对其进行修改
生产应用程序的一部分。

特别是,攻击者寻找已知的入口点和出口点
在应用程序中,因此修改这些部分很重要
您的代码与示例应用程序相同。

这意味着不要使用所提供的代码,而是更改其中的某些部分,以便黑客无法知道您使用的代码。

基本上,我认为它们不是指 billingService 本身,而是指您在应用程序中使用它的方式。

They explain it as follows:

The in-app billing sample application is publicly distributed and can
be downloaded by anyone, which means it is relatively easy for an
attacker to reverse engineer your application if you use the sample
code exactly as it is published. The sample application is intended to
be used only as an example. If you use any part of the sample
application, you must modify it before you publish it or release it as
part of a production application.

In particular, attackers look for known entry points and exit points
in an application, so it is important that you modify these parts of
your code that are identical to the sample application.

It means don't use the code as provided, change some part of it so that hackers won't be able to know what code you use.

Basically, I don't think they meant the billingService itself, but the way you use it in your application.

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