安卓逆向:apktool 反编译时报错 Exception in thread "main" org.jf.dexlib2.dexbacked.DexBackedDexFile$NotADexF...

1. 环境

  • Windows 10;
  • apktool 2.4.1;

2. 问题

  • 使用 apktool 反编译时报 Exception in thread "main" org.jf.dexlib2.dexbacked.DexBackedDexFile$NotADexFile: Not a valid dex magic value 错误,详情如下:

I: Using Apktool 2.4.1 on keep.apk
I: Loading resource table...
I: Decoding AndroidManifest.xml with resources...
I: Loading resource table from file: C:\Users\Administrator\AppData\Local\apktool\framework\1.apk
I: Regular manifest package...
I: Decoding file-resources...
I: Decoding values / XMLs...
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 assets/39285EFA.dex...
Exception in thread "main" org.jf.dexlib2.dexbacked.DexBackedDexFileNotADexFile: Not a valid dex magic value: cf 77 4c c7 9b 21 01 cd at org.jf.dexlib2.util.DexUtil.verifyDexHeader(DexUtil.java:93) at org.jf.dexlib2.dexbacked.DexBackedDexFile.getVersion(DexBackedDexFile.java:111) at org.jf.dexlib2.dexbacked.DexBackedDexFile.<init>(DexBackedDexFile.java:78) at org.jf.dexlib2.dexbacked.DexBackedDexFile.<init>(DexBackedDexFile.java:138) at org.jf.dexlib2.dexbacked.ZipDexContainer1.getDexFile(ZipDexContainer.java:181)
at brut.androlib.src.SmaliDecoder.decode(SmaliDecoder.java:90)
at brut.androlib.src.SmaliDecoder.decode(SmaliDecoder.java:39)
at brut.androlib.Androlib.decodeSourcesSmali(Androlib.java:96)
at brut.androlib.ApkDecoder.decode(ApkDecoder.java:164)
at brut.apktool.Main.cmdDecode(Main.java:170)
at brut.apktool.Main.main(Main.java:76)

3. 处理

  • 报错中提示是由于非法 dex,这是因为 apk 里有加密过后的 dex 文件,比如有些 apk 的 assets 目录下有加密后的 dex 文件,添加 –only-main-classes 参数即可;
apktool.bat d -f [需要反编译的目标apk文件名].apk -o [反编译后需要存放的文件] –only-main-classes
  • 问题解决,如下图:


    image.png

你可能感兴趣的:(安卓逆向:apktool 反编译时报错 Exception in thread "main" org.jf.dexlib2.dexbacked.DexBackedDexFile$NotADexF...)