REAndroid / APKEditor

Powerful android apk editor - aapt/aapt2 independent
Apache License 2.0
645 stars 95 forks source link

ApplicationInfo.metaData very strange error #65

Closed kiber-io closed 10 months ago

kiber-io commented 10 months ago

Describe the bug The application has metadata specified in the application tag. In the original apk, you can get the value of the key com.push server.android.serverparyid with the ApplicationInfo.metaData.getString method. But after recompiling without making changes, this method starts returning null and only ApplicationInfo.metaData.getInt works. And I can't figure out why...

To Reproduce Steps to reproduce the behavior:

  1. Used version: 1.2.9
  2. Operating system: WSL Ubuntu 22.04
  3. Command: java -jar apkeditor.jar d -i app.apk & java -jar apkeditor.jar b -i app_decompiled_xml

The problem appears in the method Lcom/edna/android/push_lite/repo/config/NetworkConfiguration;->initPrimaryServer(Landroid/os/Bundle;)V at line invoke-virtual {p1, v0}, Landroid/os/BaseBundle;->getString(Ljava/lang/String;)Ljava/lang/String; (it returns null on recompiled apk) The value itself is specified in the manifest:

<application android:theme="@style/FaceliftTheme"
...
<meta-data android:name="com.pushserver.android.serverPrimaryId" android:value="@string/mfms_primary_id" />
...
</application>

Used apk file Original apk: https://drive.google.com/file/d/1VGqz-vIoa70ESahvQTuIs0EqIq-vp2b1/view?usp=sharing

Additional context I wrote a simple program that requests metadata from the application and shows the problematic key (the first line), and also outputs the entire contents of the Bundle: https://drive.google.com/file/d/14Xh4xnmDz5wcJx9a0v1TDp_ACw1WkCEi/view?usp=sharing There you need to click on the FAB at the bottom to get the data. the original application must be installed accordingly изображение

kiber-io commented 10 months ago

so, I found out the reason a little more precisely. if you decompile the original apk in json mode, then in the resources.arsc.json can see that the mfms_primary_id key has value_type = STRING. and in the recompiled apk value_type is already DEC.

apparently, a compilation error in xml mode.

REAndroid commented 10 months ago

I wrote a simple program that requests metadata from the application and shows the problematic key (the first line), and also outputs the entire contents of the Bundle: https://drive.google.com/file/d/14Xh4xnmDz5wcJx9a0v1TDp_ACw1WkCEi/view?usp=sharing

Google drive says:

Sorry, this file is infected with a virus.
Only the owner is allowed to download infected files.

I got similar issue (not with google) when i try to send protected (custom) apk. My primary guess is that google drive's parser/scanner is failed to parse the apk, can you check again your file ?

kiber-io commented 10 months ago

yes, Google blocked the file, because it is signed with a test-key :)) I have uploaded a new file with custom sign: https://drive.google.com/file/d/1YeQ9epTdNFo3i5xpN9sdQc0Ejlo4jWDC/view?usp=sharing

REAndroid commented 10 months ago

yes, Google blocked the file, because it is signed with a test-key :)) I have uploaded a new file with custom sign: https://drive.google.com/file/d/1YeQ9epTdNFo3i5xpN9sdQc0Ejlo4jWDC/view?usp=sharing

Same result. You can see it yourself by opening your link in private-mode browser

kiber-io commented 10 months ago

yes, Google blocked the file, because it is signed with a test-key :)) I have uploaded a new file with custom sign: https://drive.google.com/file/d/1YeQ9epTdNFo3i5xpN9sdQc0Ejlo4jWDC/view?usp=sharing

Same result. You can see it yourself by opening your link in private-mode browser

Tested, everything opens and gives download. Let's try mega: https://mega.nz/file/Vlt10A4J#Nxe5_k65AafQSVMN98mFdhULLE_1iU6VLUmiEbQU1jE

REAndroid commented 10 months ago

so, I found out the reason a little more precisely. if you decompile the original apk in json mode, then in the resources.arsc.json can see that the mfms_primary_id key has value_type = STRING. and in the recompiled apk value_type is already DEC.

You are right fixed with :https://github.com/REAndroid/APKEditor/commit/4d776e386ca04164d801f5f39848078488f47751

Build yourself and let me know your result, If possible upload the edited apk to google, just want to see the difference .

kiber-io commented 10 months ago

yes, everything is fixed :) do you just need a recompiled apk? if yes, then here: https://mega.nz/file/x4UAXbQZ#bA9ZTORlvWivzfWZ87gsLlh52JbGo6qikgo0NZP9Sqg

REAndroid commented 10 months ago

yes, everything is fixed :) do you just need a recompiled apk? if yes, then here: https://mega.nz/file/x4UAXbQZ#bA9ZTORlvWivzfWZ87gsLlh52JbGo6qikgo0NZP9Sqg

The reason I asked you for re-compiled apk was to see the reaction of google-drive, I was guessing gdrive's software report as a "virus" if it can't parse AndroidManifest file.