iBotPeaches / Apktool

A tool for reverse engineering Android apk files
https://apktool.org/
Apache License 2.0
20.33k stars 3.59k forks source link

[BUG] Can't decompile altered version of Azur Lane #3503

Open USS-Corvan opened 9 months ago

USS-Corvan commented 9 months ago

Information

  1. Apktool Version (apktool -version) - 2.9.3
  2. Operating System (Mac, Linux, Windows) - Windows
  3. APK From? (Playstore, ROM, Other) - Other
  4. Java Version (java --version) - 18.0.2 2022-07-19

Stacktrace/Logcat

>apktool -f d com.YoStarJP.AzurLane1.apk --only-main-classes
I: Using Apktool 2.9.3 on com.YoStarJP.AzurLane1.apk
I: Loading resource table...
I: Decoding file-resources...
I: Loading resource table from file: C:\Users\Estro\AppData\Local\apktool\framework\1.apk
I: Decoding values */* XMLs...
I: Decoding AndroidManifest.xml with resources...
I: Regular manifest package...
I: Baksmaling classes.dex...
I: Baksmaling classes2.dex...
I: Baksmaling classes3.dex...
I: Baksmaling classes4.dex...
I: Baksmaling classes5.dex...
I: Baksmaling classes6.dex...
I: Baksmaling classes7.dex...
I: Baksmaling classes8.dex...
I: Baksmaling classes9.dex...
I: Baksmaling classes10.dex...
I: Baksmaling classes11.dex...
I: Baksmaling classes12.dex...
I: Baksmaling classes13.dex...
Exception in thread "main" com.android.tools.smali.dexlib2.dexbacked.DexBackedDexFile$NotADexFile: Not a valid dex magic value: 00 00 00 00 00 00 00 00
        at com.android.tools.smali.dexlib2.util.DexUtil.verifyDexHeader(DexUtil.java:92)
        at com.android.tools.smali.dexlib2.dexbacked.DexBackedDexFile.getVersion(DexBackedDexFile.java:172)
        at com.android.tools.smali.dexlib2.dexbacked.DexBackedDexFile.<init>(DexBackedDexFile.java:96)
        at com.android.tools.smali.dexlib2.dexbacked.DexBackedDexFile.<init>(DexBackedDexFile.java:199)
        at com.android.tools.smali.dexlib2.dexbacked.ZipDexContainer$1.getDexFile(ZipDexContainer.java:180)
        at brut.androlib.src.SmaliDecoder.decode(SmaliDecoder.java:88)
        at brut.androlib.src.SmaliDecoder.decode(SmaliDecoder.java:36)
        at brut.androlib.ApkDecoder.decodeSourcesSmali(ApkDecoder.java:220)
        at brut.androlib.ApkDecoder.decode(ApkDecoder.java:147)
        at brut.apktool.Main.cmdDecode(Main.java:217)
        at brut.apktool.Main.main(Main.java:92)

Steps to Reproduce

  1. apktool d [apk]

Frameworks

If this APK is from an OEM ROM (Samsung, HTC, LG). Please attach framework files (.apks that live in /system/framework or /system/priv-app)

APK

If this APK can be freely shared, please upload/attach a link to it. signed version: https://apkadmin.com/zv80h7ocyuw0/com.YoStarJP.AzurLane_7.1.12_signed_mod_YasKashije_platinmods.com.apk.html unsigned version: https://apkadmin.com/sec0yz8f9fyz/com.YoStarJP.AzurLane_7.1.12_unsigned_mod_YasKashije_platinmods.com.apk.html

Questions to ask before submission

  1. Have you tried apktool d, apktool b without changing anything? Couldn't finish decoding.

  2. If you are trying to install a modified apk, did you resign it? I tried both the signed and unsigned version, both failed.

  3. Are you using the latest apktool version? Yes.

USS-Corvan commented 9 months ago

I 've tried searching and found #3251 , I believe the apk mentioned there is created by the same author. The issue mentioned in #3251 still exist in 2.9.3 on my side, I don't know whether it's related with java version or something else like the apk itself. Furthermore, I have tried apktool -f d com.YoStarJP.AzurLane1.apk --only-main-classes . The log is the same with or without the parameter "--only-main-classes".

su1216 commented 9 months ago

I 've tried searching and found #3251 , I believe the apk mentioned there is created by the same author. The issue mentioned in #3251 still exist in 2.9.3 on my side, I don't know whether it's related with java version or something else like the apk itself. Furthermore, I have tried apktool -f d com.YoStarJP.AzurLane1.apk --only-main-classes . The log is the same with or without the parameter "--only-main-classes".

classes13.dex is not a real dex file, you can check it with notepad++. It's not work when you're using parameter "--only-main-classes", because classes in the classes13.dex are all main classes.

iBotPeaches commented 9 months ago

Thanks for report. I believe we could get away with adding handling for detecting NotADexFile, but then we need to adjust build support to have a mix of raw and disassembled files.

YasKashije commented 9 months ago

Skill issue

iBotPeaches commented 8 months ago

I worked a patch to skip dex disassembly errors, but there are many in this application.

I opened an issue upstream at smali for first while I debate what to do. Since after I skipped disassembly of failures then corresponding build method failed badly. Apktool had never had a mix of original/disassembled for dex files so this is a bigger can of worms than I thought.