0

我需要使用 cm 10.1 nightly rom 在我的 Android 三星 Galaxy S2 上禁用系统应用程序的签名检查,以开发防盗应用程序。因此,我通过使用本教程反编译 Services.jar 来尝试此解决方案

替换文件并重新启动后,我的手机“忘记”了我所有的应用程序(只有 rom 应用程序还在这里),我无法安装其他应用程序(通过 USB 调试)。所以我尝试直接在一个新的 rom (zip) 文件中编辑文件,并出现同样的问题。

你知道问题出在哪里吗?或者也许是另一种安装具有系统签名应用程序权限的应用程序的方法?我们知道 cm 的私钥吗?所以也许我可以用密钥签署我的应用程序?(但我知道这个密钥,这是一个安全问题,所以我认为我们不能)

谢谢

4

1 回答 1

0

I've check the logcat when the installation problem occur, and i have this error

"Cannot install platform packages to user storage"

I look into the cm github and i found this part of code

Signature[] s1 = null;
if (obj instanceof SharedUserSetting) {
    s1 = ((SharedUserSetting)obj).signatures.mSignatures;
}
if ((compareSignatures(pkg.mSignatures, s1) == PackageManager.SIGNATURE_MATCH)) {
    Slog.w(TAG, "Cannot install platform packages to user storage");
    mLastScanError = PackageManager.INSTALL_FAILED_INVALID_INSTALL_LOCATION;
    return null;
}

Previously, with the tutorial I've edit the compareSignatures() function to make it return SIGNATURE_MATCH. But in this code, the error occurs when the function return this value.

It's seem this code is a security added, to be sure a system app will not be installed in the "user storage". The only way to fix my problem was to make the error never append (and I don't think this is a big vulnerability, but maybe i'm wrong, and if you have a better solution tell me)

So in addition to the first tutorial, I've replace

invoke-static {v3, v0}, Lcom/android/server/pm/PackageManagerService;->compareSignatures([Landroid/content/pm/Signature;[Landroid/content/pm/Signature;)I

move-result v3

if-nez v3, :cond_1d1
.line 3715
const-string v3, "PackageManager"
const-string v4, "Cannot install platform packages to user storage"
invoke-static {v3, v4}, Landroid/util/Slog;->w(Ljava/lang/String;Ljava/lang/String;)I

by

invoke-static {v3, v0}, Lcom/android/server/pm/PackageManagerService;->compareSignatures([Landroid/content/pm/Signature;[Landroid/content/pm/Signature;)I

const/4 v3, -0x3

if-nez v3, :cond_1d1
.line 3715
const-string v3, "PackageManager"
const-string v4, "Cannot install platform packages to user storage"
invoke-static {v3, v4}, Landroid/util/Slog;->w(Ljava/lang/String;Ljava/lang/String;)I

And it work :) I've never work in decompiled Java bytecode before so if I've made some mistakes, tell me.

Hope it will help !

于 2013-08-18T01:31:41.197 回答