我可以免费下载Android应用,其中包含应用内购买商品(非消耗品)
最近,我发现几个黑市都带有我的Android应用程序,所有应用内购买项目都可以自由访问。
我在想,这些饼干是如何做到的?这就是我在我身边所做的。
onCreate
会触发updateIsPremium
。代码如下
private void updateIsPremium() {
if (mHelper != null) {
return;
}
/* base64EncodedPublicKey should be YOUR APPLICATION'S PUBLIC KEY
* (that you got from the Google Play developer console). This is not your
* developer public key, it's the *app-specific* public key.
*
* Instead of just storing the entire literal string here embedded in the
* program, construct the key at runtime from pieces or
* use bit manipulation (for example, XOR with some other string) to hide
* the actual key. The key itself is not secret information, but we don't
* want to make it easy for an attacker to replace the public key with one
* of their own and then fake messages from the server.
*/
String base64EncodedPublicKey = "...";
base64EncodedPublicKey = decrypt(base64EncodedPublicKey);
mHelper = new IabHelper(MyApplication.instance(), base64EncodedPublicKey);
// enable debug logging (for a production application, you should set this to false).
mHelper.enableDebugLogging(false);
mHelper.startSetup(new IabHelper.OnIabSetupFinishedListener() {
public void onIabSetupFinished(IabResult result) {
Log.d(TAG, "Setup finished.");
if (!result.isSuccess()) {
// Oh no, there was a problem.
// (Do not use alert dialog. It is difficult to handle it
// correctly due to bug in v4)
//Utils.showLongToast(getString(R.string.problem_setting_up_in_app_billing_template, result.toString()));
return;
}
// Have we been disposed of in the meantime? If so, quit.
if (mHelper == null) return;
// IAB is fully set up. Now, let's get an inventory of stuff we own.
Log.d(TAG, "Setup successful. Querying inventory.");
//mHelper.queryInventoryAsync(mGotInventoryListener);
// http://stackoverflow.com/questions/15471131/in-app-billing-v3-unable-to-query-items-without-network-connection-or-in-airplan/15471951#15471951
// Not sure this is going to help to solve the problem :
// In-app billing v3 unable to query items without network
// connection or in airplane/flight mode
List<String> skulist = new ArrayList<String>();
for (Shop shop : Shop.values()) {
skulist.add(shop.sku);
}
try {
mHelper.queryInventoryAsync(true, skulist, mGotInventoryListener);
} catch (java.lang.IllegalStateException exp) {
// Ugly fix on mystery crash :
// java.lang.IllegalStateException: Can't start async operation (refresh inventory) because another async operation(launchPurchaseFlow) is in progress.
Utils.showLongToast(getString(R.string.failed_to_query_inventory_template, exp.getMessage()));
}
}
});
}
// Listener that's called when we finish querying the items and subscriptions we own
IabHelper.QueryInventoryFinishedListener mGotInventoryListener = new IabHelper.QueryInventoryFinishedListener() {
public void onQueryInventoryFinished(IabResult result, Inventory inventory) {
Log.d(TAG, "Query inventory finished.");
// Have we been disposed of in the meantime? If so, quit.
if (mHelper == null) return;
// Is it a failure?
if (result.isFailure()) {
return;
}
Log.d(TAG, "Query inventory was successful.");
final MyOptions myOptions = MyApplication.instance().getMyOptions();
myOptions.setInventory(inventory);
/*
* Check for items we own. Notice that for each purchase, we check
* the developer payload to see if it's correct! See
* verifyDeveloperPayload().
*/
// Update shop information.
boolean atLeastBoughtOne = false;
for (Shop shop : Shop.values()) {
final Purchase purchase0 = inventory.getPurchase(shop.sku);
final boolean mIsPurchase0 = (purchase0 != null && org.gui.billing.Utils.verifyDeveloperPayload(purchase0));
if (mIsPurchase0) {
atLeastBoughtOne = true;
myOptions.bought(shop);
} else {
myOptions.cancel(shop);
}
}
myOptions.turnOnShopChecked();
}
};
// We're being destroyed. It's important to dispose of the helper here!
@Override
public void onDestroy() {
super.onDestroy();
if (this.isFinishing()) {
// very important:
Log.d(TAG, "Destroying helper.");
if (mHelper != null) {
try {
mHelper.dispose();
} catch (java.lang.IllegalArgumentException ex) {
Log.e(TAG, "", ex);
}
mHelper = null;
}
}
}
// The helper object
public static IabHelper mHelper;
我可以知道,破解者如何对我混淆的代码进行逆向工程?
我很想知道,为了避免我的应用内购买项目被破解,我还有更多的预警措施吗? App Licensing会有帮助吗?我对App Licensing
的理解是,它仅适用于&#34;付费应用&#34;,而不是&#34;免费应用与应用内购买商品&#34;
答案 0 :(得分:1)
反向工程混淆代码实际上并不那么困难。我之所以这样做是出于合理的原因,比如弄清楚如何使用一个非常难以记录的库,某些诉讼已经让我们使用而没有咨询开发团队。您只需反编译应用程序或库并在IDE中加载它。公共方法的名称不能被混淆,所以你从那里开始,弄清楚是什么,并使用你的IDE的重构工具开始给出一切有意义的名字。您可以在大约一天内完全对应用程序进行逆向工程。
出于所有实际目的,你无法阻止这种黑客行为。如果您的应用程序可以运行,则可以对其进行反编译。如果可以查看您的媒体,则可以复制该媒体。阻止这种情况的唯一方法是加密您的软件,使其只能在具有嵌入式密钥,篡改传感器和自毁机制的专有设备上运行。这就是为什么软件和媒体行业一直在寻求合法而非技术解决方案 - 或混合解决方案,他们提出了一些完全没有价值的技术解决方案,然后向任何规避它的人发出法律挑战。
答案 1 :(得分:1)
您应该自己调查这些更改。我假设你的应用程序被黑客修改,所以你可以下载它。然后你应该反编译你的自己,然后反编译你的原始应用程序,并使用diff工具查找差异。我就是这样做的:
我使用sony的apkanalyzer来生成smali代码:
http://developer.sonymobile.com/knowledge-base/tools/analyse-your-apks-with-apkanalyser/
将所有smali代码保存在一个文件夹中,用于黑客入侵apk。并为原始apk做同样的事情。然后使用一些文件夹差异工具。
通过这种方式,您可以找到黑客对您的应用所做的事情,并且能够(可能)添加固定的黑客(可能)不满意。
答案 2 :(得分:0)
你必须先了解如何破解Android应用程序。
互联网上有很多教程,这是我最近编写的一个工具: http://forum.exetools.com/showthread.php?t=16538
答案 3 :(得分:0)
混淆是最小的保护。而且您使用的与Google示例完全相同。每个人都知道。你必须修改它!
遵循这些准则,您将是安全的。这是一件好事。 http://developer.android.com/google/play/billing/billing_best_practices.html
另外,我认为App Licensing不会让它更安全。如果cracker可以读取您的代码,那就是同样的事情。只需绕过许可证检查并共享apk。